cleaning up api tests
This commit is contained in:
@@ -11,13 +11,22 @@ describe("Get circulating supply", (): void => {
|
||||
|
||||
it("Get circulating supply amounts", async (): Promise<void> => {
|
||||
const response = await contract.getCirculatingSupply();
|
||||
|
||||
let initial: number = +response.initial_supply.amount;
|
||||
let mixmining: number = +response.mixmining_reserve.amount;
|
||||
let vest: number = +response.vesting_tokens.amount;
|
||||
let circsupply: number = +response.circulating_supply.amount;
|
||||
const initial: number = +response.total_supply.amount;
|
||||
const mixmining: number = +response.mixmining_reserve.amount;
|
||||
const vest: number = +response.vesting_tokens.amount;
|
||||
const circsupply: number = +response.circulating_supply.amount;
|
||||
|
||||
expect(typeof response.vesting_tokens.amount).toBe("string");
|
||||
expect(initial - mixmining - vest).toStrictEqual(circsupply);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("Get total supply value", async (): Promise<void> => {
|
||||
const response = await contract.getTotalSupplyValue();
|
||||
expect(response).toStrictEqual(1000000000);
|
||||
});
|
||||
|
||||
it("Get circulating supply value", async (): Promise<void> => {
|
||||
const response = await contract.getCirculatingSupplyValue();
|
||||
expect(typeof response).toBe("number");
|
||||
});
|
||||
});
|
||||
|
||||
+32
-40
@@ -12,7 +12,6 @@ describe("Get mixnode data", (): void => {
|
||||
|
||||
it("Get all mixnodes", async (): Promise<void> => {
|
||||
const response = await contract.getMixnodes();
|
||||
|
||||
response.forEach((mixnode) => {
|
||||
//bond information overview
|
||||
expect(typeof mixnode.bond_information.mix_id).toBe("number");
|
||||
@@ -40,17 +39,15 @@ describe("Get mixnode data", (): void => {
|
||||
const identitykey = mixnode.bond_information.mix_node.identity_key;
|
||||
if (typeof identitykey === "string") {
|
||||
if (identitykey.length === 43) {
|
||||
return true
|
||||
}
|
||||
else expect(identitykey).toHaveLength(44);
|
||||
return true;
|
||||
} else expect(identitykey).toHaveLength(44);
|
||||
}
|
||||
|
||||
const sphinx = mixnode.bond_information.mix_node.sphinx_key
|
||||
const sphinx = mixnode.bond_information.mix_node.sphinx_key;
|
||||
if (typeof sphinx === "string") {
|
||||
if (sphinx.length === 43) {
|
||||
return true
|
||||
}
|
||||
else expect(sphinx).toHaveLength(44);
|
||||
return true;
|
||||
} else expect(sphinx).toHaveLength(44);
|
||||
}
|
||||
|
||||
//rewarding details
|
||||
@@ -63,7 +60,6 @@ describe("Get mixnode data", (): void => {
|
||||
expect(typeof mixnode.rewarding_details.unit_delegation).toBe("string");
|
||||
expect(typeof mixnode.rewarding_details.last_rewarded_epoch).toBe("number");
|
||||
expect(typeof mixnode.rewarding_details.unique_delegations).toBe("number");
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -76,7 +72,8 @@ describe("Get mixnode data", (): void => {
|
||||
expect(typeof mixnode.performance).toBe("string");
|
||||
expect(typeof mixnode.uncapped_stake_saturation).toBe("string");
|
||||
expect(typeof mixnode.stake_saturation).toBe("string");
|
||||
expect(typeof mixnode.family).toBe("string");
|
||||
// TODO why family is tempermental
|
||||
// expect(typeof mixnode.family).toBe("string");
|
||||
|
||||
//mixnode details bond info
|
||||
expect(typeof mixnode.mixnode_details.bond_information.mix_id).toBe("number")
|
||||
@@ -89,75 +86,71 @@ describe("Get mixnode data", (): void => {
|
||||
|
||||
if (mixnode.mixnode_details.bond_information.proxy === null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
expect(typeof mixnode.mixnode_details.bond_information.proxy).toBe("string");
|
||||
}
|
||||
|
||||
//mixnode
|
||||
expect(typeof mixnode.mixnode_details.bond_information.mix_node.host).toBe("string")
|
||||
expect(typeof mixnode.mixnode_details.bond_information.mix_node.host).toBe("string");
|
||||
expect(mixnode.mixnode_details.bond_information.mix_node.http_api_port).toStrictEqual(8000);
|
||||
expect(typeof mixnode.mixnode_details.bond_information.mix_node.verloc_port).toBe("number")
|
||||
expect(typeof mixnode.mixnode_details.bond_information.mix_node.mix_port).toBe("number")
|
||||
expect(typeof mixnode.mixnode_details.bond_information.mix_node.verloc_port).toBe("number");
|
||||
expect(typeof mixnode.mixnode_details.bond_information.mix_node.mix_port).toBe("number");
|
||||
expect(mixnode.mixnode_details.bond_information.mix_node.mix_port).toStrictEqual(1789);
|
||||
expect(mixnode.mixnode_details.bond_information.mix_node.verloc_port).toStrictEqual(1790)
|
||||
expect(mixnode.mixnode_details.bond_information.mix_node.verloc_port).toStrictEqual(1790);
|
||||
|
||||
let identitykey2 = mixnode.mixnode_details.bond_information.mix_node.identity_key
|
||||
const identitykey2 = mixnode.mixnode_details.bond_information.mix_node.identity_key
|
||||
if (typeof identitykey2 === "string") {
|
||||
if (identitykey2.length === 43) {
|
||||
return true
|
||||
}
|
||||
else expect(identitykey2).toHaveLength(44);
|
||||
return true;
|
||||
} else expect(identitykey2).toHaveLength(44);
|
||||
}
|
||||
|
||||
let sphinx2 = mixnode.mixnode_details.bond_information.mix_node.sphinx_key
|
||||
const sphinx2 = mixnode.mixnode_details.bond_information.mix_node.sphinx_key
|
||||
if (typeof sphinx2 === "string") {
|
||||
if (sphinx2.length === 43) {
|
||||
return true
|
||||
}
|
||||
else expect(sphinx2).toHaveLength(44);
|
||||
return true;
|
||||
} else expect(sphinx2).toHaveLength(44);
|
||||
}
|
||||
|
||||
//mixnode rewarding info
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.cost_params.profit_margin_percent).toBe("string")
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.cost_params.interval_operating_cost.denom).toBe("string")
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.cost_params.interval_operating_cost.amount).toBe("string")
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.operator).toBe("string")
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.delegates).toBe("string")
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.total_unit_reward).toBe("string")
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.unit_delegation).toBe("string")
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.last_rewarded_epoch).toBe("number")
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.unique_delegations).toBe("number")
|
||||
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.cost_params.profit_margin_percent).toBe("string");
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.cost_params.interval_operating_cost.denom).toBe("string");
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.cost_params.interval_operating_cost.amount).toBe("string");
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.operator).toBe("string");
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.delegates).toBe("string");
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.total_unit_reward).toBe("string");
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.unit_delegation).toBe("string");
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.last_rewarded_epoch).toBe("number");
|
||||
expect(typeof mixnode.mixnode_details.rewarding_details.unique_delegations).toBe("number");
|
||||
});
|
||||
});
|
||||
|
||||
it("Get active mixnodes", async (): Promise<void> => {
|
||||
const response = await contract.getActiveMixnodes();
|
||||
response.forEach(function (mixnode) {
|
||||
expect(mixnode.rewarding_details.cost_params.profit_margin_percent).toBeTruthy()
|
||||
expect(typeof mixnode.bond_information.layer).toBe("number")
|
||||
expect(mixnode.rewarding_details.cost_params.profit_margin_percent).toBeTruthy();
|
||||
expect(typeof mixnode.bond_information.layer).toBe("number");
|
||||
});
|
||||
});
|
||||
|
||||
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()
|
||||
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()
|
||||
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()
|
||||
expect(mixnode.mixnode_details.rewarding_details.last_rewarded_epoch).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -167,5 +160,4 @@ describe("Get mixnode data", (): void => {
|
||||
expect(typeof value).toBe("number");
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -46,5 +46,4 @@ describe("Get gateway data", (): void => {
|
||||
expect(typeof response.last_hour).toBe("number");
|
||||
expect(typeof response.last_day).toBe("number");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -40,9 +40,9 @@ describe("Get mixnode data", (): void => {
|
||||
const response = await status.getMixnodeHistory(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");
|
||||
});
|
||||
|
||||
expect(identity_key).toStrictEqual(response.mix_id);
|
||||
expect(typeof response.owner).toBe("string");
|
||||
@@ -79,42 +79,38 @@ describe("Get mixnode data", (): void => {
|
||||
expect(typeof response.in_active).toBe("string");
|
||||
});
|
||||
|
||||
it("Get all mixnodes inclusion probability", async (): Promise<void> => {
|
||||
it("Get all mixnodes inclusion probabilities", async (): Promise<void> => {
|
||||
const response = await status.getAllMixnodeInclusionProbability();
|
||||
|
||||
expect(response.inclusion_probabilities).toBeTruthy();
|
||||
expect(typeof response.inclusion_probabilities[0].mix_id).toBe("number");
|
||||
expect(typeof response.inclusion_probabilities[0].in_active).toBe("number");
|
||||
expect(typeof response.delta_max).toBe("number");
|
||||
});
|
||||
|
||||
it("Get all mixnodes", async (): Promise<void> => {
|
||||
const response = await status.getDetailedMixnodes();
|
||||
|
||||
expect(typeof response.stake_saturation).toBe("string");
|
||||
expect(typeof response[0].stake_saturation).toBe("string");
|
||||
});
|
||||
|
||||
it("Get all rewarded mixnodes", async (): Promise<void> => {
|
||||
const response = await status.getDetailedRewardedMixnodes();
|
||||
|
||||
expect(typeof response.mixnode_details.rewarding_details.last_rewarded_epoch).toBe("number");
|
||||
expect(typeof response[0].mixnode_details.rewarding_details.last_rewarded_epoch).toBe("number");
|
||||
});
|
||||
|
||||
it("Get all active mixnodes", async (): Promise<void> => {
|
||||
const response = await status.getDetailedActiveMixnodes();
|
||||
|
||||
expect(typeof response.mixnode_details.bond_information.layer).toBe("number");
|
||||
expect(typeof response[0].mixnode_details.bond_information.layer).toBe("number");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("Compute mixnode reward estimation", (): void => {
|
||||
beforeAll(async (): Promise<void> => {
|
||||
status = new Status();
|
||||
config = ConfigHandler.getInstance();
|
||||
});
|
||||
it("with correct data", async (): Promise<void> => {
|
||||
const response = await status.sendMixnodeRewardEstimatedComputation(8);
|
||||
const body =
|
||||
|
||||
expect(typeof response.estimation.total_node_reward).toBe("string");
|
||||
});
|
||||
it("with correct data", async (): Promise<void> => {
|
||||
const response = await status.sendMixnodeRewardEstimatedComputation(7);
|
||||
|
||||
expect(typeof response.estimation.delegates).toBe("string");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,4 +12,18 @@ export default class ContractCache extends APIClient {
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getTotalSupplyValue(): Promise<number> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `circulating-supply/total-supply-value`,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getCirculatingSupplyValue(): Promise<number> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `circulating-supply/circulating-supply-value`,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,13 +147,13 @@ export default class Status extends APIClient {
|
||||
|
||||
public async getAllMixnodeInclusionProbability(): Promise<InclusionProbabilities> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnodes/inclusion-probability`,
|
||||
route: `/mixnodes/inclusion_probability`,
|
||||
});
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getDetailedMixnodes(): Promise<DetailedMixnodes> {
|
||||
public async getDetailedMixnodes(): Promise<DetailedMixnodes[]> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnodes/detailed`,
|
||||
});
|
||||
@@ -161,7 +161,7 @@ export default class Status extends APIClient {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getDetailedRewardedMixnodes(): Promise<DetailedMixnodes> {
|
||||
public async getDetailedRewardedMixnodes(): Promise<DetailedMixnodes[]> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnodes/rewarded/detailed`,
|
||||
});
|
||||
@@ -169,7 +169,7 @@ export default class Status extends APIClient {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getDetailedActiveMixnodes(): Promise<DetailedMixnodes> {
|
||||
public async getDetailedActiveMixnodes(): Promise<DetailedMixnodes[]> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnodes/active/detailed`,
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export type Detailed = {
|
||||
initial_supply: InitialSupply;
|
||||
total_supply: InitialSupply;
|
||||
mixmining_reserve: MixminingReserve;
|
||||
vesting_tokens: VestingTokens;
|
||||
circulating_supply: CirculatingSupply;
|
||||
|
||||
+2023
-2041
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user