WIP
This commit is contained in:
+23
-5
@@ -135,13 +135,31 @@ describe("Get mixnode data", (): void => {
|
||||
|
||||
it("Get active mixnodes", async (): Promise<void> => {
|
||||
const response = await contract.getActiveMixnodes();
|
||||
//TO-DO this test should focus more on checking that the response actually contains active nodes
|
||||
response.forEach(function (mixnode) {
|
||||
expect(mixnode.rewarding_details.cost_params.profit_margin_percent).toBeTruthy()
|
||||
});
|
||||
});
|
||||
|
||||
//TO-DO figure out a similar type of test solution as above for the following:
|
||||
// getActiveMixnodesDetailed
|
||||
// getRewardedMixnodes
|
||||
// getRewardedMixnodesDetailed
|
||||
it("Get active mixnodes detailed", async (): Promise<void> => {
|
||||
const response = await contract.getActiveMixnodesDetailed();
|
||||
response.forEach(function (mixnode) {
|
||||
expect(mixnode.mixnode_details.rewarding_details.cost_params.profit_margin_percent).toBeTruthy()
|
||||
});
|
||||
});
|
||||
|
||||
it("Get rewarded mixnodes", async (): Promise<void> => {
|
||||
const response = await contract.getRewardedMixnodes();
|
||||
response.forEach(function (mixnode) {
|
||||
expect(mixnode.rewarding_details.last_rewarded_epoch).toBeTruthy()
|
||||
});
|
||||
});
|
||||
|
||||
it("Get rewarded mixnodes detailed", async (): Promise<void> => {
|
||||
const response = await contract.getRewardedMixnodesDetailed();
|
||||
response.forEach(function (mixnode) {
|
||||
expect(mixnode.mixnode_details.rewarding_details.last_rewarded_epoch).toBeTruthy()
|
||||
});
|
||||
});
|
||||
|
||||
it("Get blacklisted mixnodes", async (): Promise<void> => {
|
||||
const response = await contract.getBlacklistedMixnodes();
|
||||
|
||||
@@ -15,14 +15,9 @@ describe("Get gateway data", (): void => {
|
||||
const response = await status.getGatewayHistory(identity_key);
|
||||
|
||||
response.history.forEach((x) => {
|
||||
console.log(x.date);
|
||||
console.log(x.uptime);
|
||||
|
||||
expect(typeof x.date).toBe("string");
|
||||
expect(typeof x.uptime).toBe("number");
|
||||
});
|
||||
console.log(response.identity);
|
||||
console.log(response.owner);
|
||||
|
||||
expect(identity_key).toStrictEqual(response.identity);
|
||||
expect(typeof response.owner).toBe("string");
|
||||
@@ -32,9 +27,6 @@ describe("Get gateway data", (): void => {
|
||||
const identity_key = config.environmnetConfig.gateway_identity;
|
||||
const response = await status.getGatewayCoreCount(identity_key);
|
||||
|
||||
console.log(response.count);
|
||||
console.log(response.identity);
|
||||
|
||||
expect(identity_key).toStrictEqual(response.identity);
|
||||
expect(typeof response.count).toBe("number");
|
||||
});
|
||||
|
||||
@@ -11,19 +11,16 @@ describe("Get mixnode data", (): void => {
|
||||
});
|
||||
|
||||
it("Get a mixnode stake saturation", async (): Promise<void> => {
|
||||
const mix_id = config.environmnetConfig.mixnode_identity;
|
||||
const mix_id = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeStakeSaturation(mix_id);
|
||||
|
||||
console.log(response.as_at);
|
||||
console.log(response.saturation);
|
||||
|
||||
expect(typeof response.as_at).toBe("number");
|
||||
expect(typeof response.saturation).toBe("string");
|
||||
expect(typeof response.uncapped_saturation).toBe("string");
|
||||
});
|
||||
|
||||
it("Get a mixnode status report", async (): Promise<void> => {
|
||||
const mix_id = config.environmnetConfig.mixnode_identity;
|
||||
const mix_id = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeStatusReport(mix_id);
|
||||
|
||||
expect(mix_id).toStrictEqual(response.mix_id);
|
||||
@@ -34,57 +31,45 @@ describe("Get mixnode data", (): void => {
|
||||
});
|
||||
|
||||
it("Get a mixnode average uptime", async (): Promise<void> => {
|
||||
const mix_id = config.environmnetConfig.mixnode_identity;
|
||||
const mix_id = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeAverageUptime(mix_id);
|
||||
|
||||
console.log(response.avg_uptime);
|
||||
console.log(response.mix_id);
|
||||
|
||||
expect(mix_id).toStrictEqual(response.mix_id);
|
||||
expect(typeof response.avg_uptime).toBe("number");
|
||||
});
|
||||
|
||||
|
||||
it("Get a mixnode history", async (): Promise<void> => {
|
||||
const mix_id = config.environmnetConfig.mixnode_identity;
|
||||
const mix_id = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeHistory(mix_id);
|
||||
|
||||
response.history.forEach((x) => {
|
||||
console.log(x.date);
|
||||
console.log(x.uptime);
|
||||
|
||||
expect(typeof x.date).toBe("string");
|
||||
expect(typeof x.uptime).toBe("number");
|
||||
});
|
||||
console.log(response.identity);
|
||||
console.log(response.owner);
|
||||
|
||||
expect(mix_id).toStrictEqual(response.mix_id);
|
||||
expect(typeof response.owner).toBe("string");
|
||||
});
|
||||
|
||||
it("Get mixnode core status count", async (): Promise<void> => {
|
||||
const mix_id = config.environmnetConfig.mixnode_identity;
|
||||
const mix_id = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeCoreCount(mix_id);
|
||||
|
||||
console.log(response.count);
|
||||
console.log(response.mix_id);
|
||||
|
||||
expect(mix_id).toStrictEqual(response.mix_id);
|
||||
expect(typeof response.count).toBe("number");
|
||||
});
|
||||
|
||||
it("Get a mixnode status", async (): Promise<void> => {
|
||||
const mix_id = config.environmnetConfig.mixnode_identity;
|
||||
const mix_id = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeStatus(mix_id);
|
||||
|
||||
console.log(response.status);
|
||||
|
||||
expect(response.status).toStrictEqual("active");
|
||||
});
|
||||
|
||||
it("Get a mixnode reward estimation", async (): Promise<void> => {
|
||||
const mix_id = config.environmnetConfig.mixnode_identity;
|
||||
const mix_id = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeRewardComputation(mix_id);
|
||||
|
||||
//estimation
|
||||
@@ -120,18 +105,16 @@ describe("Get mixnode data", (): void => {
|
||||
});
|
||||
|
||||
it("Get a mixnode inclusion probability", async (): Promise<void> => {
|
||||
const mix_id = config.environmnetConfig.mixnode_identity;
|
||||
const mix_id = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeInclusionProbability(mix_id);
|
||||
|
||||
console.log(response.in_active);
|
||||
console.log(response.in_reserve);
|
||||
|
||||
expect(typeof response.in_active).toBe("string");
|
||||
expect(typeof response.in_reserve).toBe("string");
|
||||
});
|
||||
|
||||
it("Post to compute mixnode reward estimation", async ():Promise<void> => {
|
||||
const mix_id = config.environmnetConfig.mixnode_identity;
|
||||
const mix_id = config.environmnetConfig.mix_id;
|
||||
const payload = {"performance": "0.2"}
|
||||
const response = await status.getMixnodeRewardEstimatedComputation(mix_id, payload);
|
||||
|
||||
@@ -167,7 +150,7 @@ describe("Get mixnode data", (): void => {
|
||||
|
||||
|
||||
it.skip("Post to compute mixnode reward estimation", async ():Promise<void> => {
|
||||
const mix_id = config.environmnetConfig.mixnode_identity;
|
||||
const mix_id = config.environmnetConfig.mix_id;
|
||||
const payload = {"performance": "0.7"}
|
||||
const response = await status.getMixnodeRewardEstimatedComputation(mix_id, payload);
|
||||
|
||||
@@ -175,4 +158,11 @@ describe("Get mixnode data", (): void => {
|
||||
expect(response.estimation.total_node_reward).toContain("986360");
|
||||
|
||||
})
|
||||
|
||||
it("Get mixnode history using identity key", async (): Promise<void> => {
|
||||
const identity_key = config.environmnetConfig.identity_key;
|
||||
const response = await status.getMixnodeHistoryWrong(identity_key);
|
||||
expect(response).toEqual(404)
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -4,7 +4,8 @@ common:
|
||||
Content-Type: application/json
|
||||
qa:
|
||||
api_base_url: https://qwerty-validator-api.qa.nymte.ch/api/v1
|
||||
mixnode_identity: 7
|
||||
mix_id: 7
|
||||
identity_key: 4Yr4qmEHd9sgsuQ83191FR2hD88RfsbMmB4tzhhZWriz
|
||||
gateway_identity: 336yuXAeGEgedRfqTJZsG2YV7P13QH1bHv1SjCZYarc9
|
||||
log_level: error
|
||||
prod:
|
||||
|
||||
@@ -16,7 +16,8 @@ class ConfigHandler {
|
||||
log_level: TLogLevelName;
|
||||
time_zone: string;
|
||||
api_base_url: string;
|
||||
mixnode_identity: number;
|
||||
mix_id: number;
|
||||
identity_key: string;
|
||||
gateway_identity: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ import {
|
||||
EpochRewardParams,
|
||||
BlacklistedGateways,
|
||||
BlacklistedMixnodes,
|
||||
CurrentEpoch
|
||||
CurrentEpoch,
|
||||
Mixnode
|
||||
} from "../types/ContractCacheTypes";
|
||||
import { APIClient } from "./abstracts/APIClient";
|
||||
|
||||
@@ -43,6 +44,27 @@ export default class ContractCache extends APIClient {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getActiveMixnodesDetailed(): Promise<MixnodesDetailed[]> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `mixnodes/active/detailed`,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getRewardedMixnodes(): Promise<AllMixnodes[]> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `mixnodes/rewarded`,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getRewardedMixnodesDetailed(): Promise<MixnodesDetailed[]> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `mixnodes/rewarded/detailed`,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getBlacklistedMixnodes(): Promise<BlacklistedMixnodes[]> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `mixnodes/blacklisted`,
|
||||
|
||||
@@ -117,6 +117,15 @@ export default class Status extends APIClient {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getMixnodeHistoryWrong(
|
||||
identity_key: string
|
||||
): Promise<NodeHistory> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/status/mixnode/${identity_key}/history`,
|
||||
});
|
||||
return response.status;
|
||||
}
|
||||
|
||||
public async getMixnodeStatus(mix_id: number): Promise<ActiveStatus> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${mix_id}/status`,
|
||||
|
||||
Reference in New Issue
Block a user