adding tests for circulating endpoints
This commit is contained in:
@@ -12,13 +12,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(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(typeof response).toBe("number");
|
||||
});
|
||||
|
||||
it("Get circulating supply value", async (): Promise<void> => {
|
||||
const response = await contract.getCirculatingSupplyValue();
|
||||
expect(typeof response).toBe("number");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -12,28 +12,26 @@ describe("Get epoch info", (): void => {
|
||||
|
||||
it("Get epoch reward params", async (): Promise<void> => {
|
||||
const response = await contract.getEpochRewardParams();
|
||||
expect(typeof response.interval.reward_pool).toBe('string');
|
||||
expect(typeof response.interval.staking_supply_scale_factor).toBe('string');
|
||||
expect(typeof response.interval.staking_supply).toBe('string');
|
||||
expect(typeof response.interval.epoch_reward_budget).toBe('string');
|
||||
expect(typeof response.interval.stake_saturation_point).toBe('string');
|
||||
expect(typeof response.interval.sybil_resistance).toBe('string');
|
||||
expect(typeof response.interval.active_set_work_factor).toBe('string');
|
||||
expect(typeof response.interval.interval_pool_emission).toBe('string');
|
||||
expect(typeof response.active_set_size).toBe('number');
|
||||
expect(typeof response.rewarded_set_size).toBe('number');
|
||||
expect(typeof response.interval.reward_pool).toBe("string");
|
||||
expect(typeof response.interval.staking_supply_scale_factor).toBe("string");
|
||||
expect(typeof response.interval.staking_supply).toBe("string");
|
||||
expect(typeof response.interval.epoch_reward_budget).toBe("string");
|
||||
expect(typeof response.interval.stake_saturation_point).toBe("string");
|
||||
expect(typeof response.interval.sybil_resistance).toBe("string");
|
||||
expect(typeof response.interval.active_set_work_factor).toBe("string");
|
||||
expect(typeof response.interval.interval_pool_emission).toBe("string");
|
||||
expect(typeof response.active_set_size).toBe("number");
|
||||
expect(typeof response.rewarded_set_size).toBe("number");
|
||||
});
|
||||
|
||||
it("Get current epoch", async (): Promise<void> => {
|
||||
const response = await contract.getCurrentEpoch();
|
||||
expect(typeof response.id).toBe('number');
|
||||
expect(typeof response.epochs_in_interval).toBe('number');
|
||||
expect(typeof response.current_epoch_id).toBe('number');
|
||||
expect(typeof response.current_epoch_start).toBe('string');
|
||||
expect(typeof response.epoch_length.secs).toBe('number');
|
||||
expect(typeof response.epoch_length.nanos).toBe('number');
|
||||
expect(typeof response.total_elapsed_epochs).toBe('number');
|
||||
expect(typeof response.id).toBe("number");
|
||||
expect(typeof response.epochs_in_interval).toBe("number");
|
||||
expect(typeof response.current_epoch_id).toBe("number");
|
||||
expect(typeof response.current_epoch_start).toBe("string");
|
||||
expect(typeof response.epoch_length.secs).toBe("number");
|
||||
expect(typeof response.epoch_length.nanos).toBe("number");
|
||||
expect(typeof response.total_elapsed_epochs).toBe("number");
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
+14
-16
@@ -14,36 +14,34 @@ describe("Get gateway data", (): void => {
|
||||
const response = await contract.getGateways();
|
||||
response.forEach((gateway) => {
|
||||
//overview
|
||||
expect(typeof gateway.owner).toBe('string');
|
||||
expect(typeof gateway.block_height).toBe('number');
|
||||
expect(typeof gateway.owner).toBe("string");
|
||||
expect(typeof gateway.block_height).toBe("number");
|
||||
|
||||
if (gateway.proxy === null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
expect(typeof gateway.proxy).toBe('string');
|
||||
} else {
|
||||
expect(typeof gateway.proxy).toBe("string");
|
||||
}
|
||||
|
||||
//pledge_amount
|
||||
expect(typeof gateway.pledge_amount.denom).toBe('string');
|
||||
expect(typeof gateway.pledge_amount.amount).toBe('string');
|
||||
expect(typeof gateway.pledge_amount.denom).toBe("string");
|
||||
expect(typeof gateway.pledge_amount.amount).toBe("string");
|
||||
|
||||
//gateway
|
||||
expect(typeof gateway.gateway.host).toBe('string');
|
||||
expect(typeof gateway.gateway.mix_port).toBe('number');
|
||||
expect(typeof gateway.gateway.clients_port).toBe('number');
|
||||
expect(typeof gateway.gateway.location).toBe('string');
|
||||
expect(typeof gateway.gateway.sphinx_key).toBe('string');
|
||||
expect(typeof gateway.gateway.identity_key).toBe('string');
|
||||
expect(typeof gateway.gateway.version).toBe('string');
|
||||
expect(typeof gateway.gateway.host).toBe("string");
|
||||
expect(typeof gateway.gateway.mix_port).toBe("number");
|
||||
expect(typeof gateway.gateway.clients_port).toBe("number");
|
||||
expect(typeof gateway.gateway.location).toBe("string");
|
||||
expect(typeof gateway.gateway.sphinx_key).toBe("string");
|
||||
expect(typeof gateway.gateway.identity_key).toBe("string");
|
||||
expect(typeof gateway.gateway.version).toBe("string");
|
||||
});
|
||||
});
|
||||
|
||||
it("Get blacklisted gateways", async (): Promise<void> => {
|
||||
const response = await contract.getBlacklistedGateways();
|
||||
response.forEach(function (value) {
|
||||
expect(typeof value).toBe('string');
|
||||
expect(typeof value).toBe("string");
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
+153
-84
@@ -15,56 +15,72 @@ describe("Get mixnode data", (): void => {
|
||||
|
||||
response.forEach((mixnode) => {
|
||||
//bond information overview
|
||||
expect(typeof mixnode.bond_information.mix_id).toBe('number');
|
||||
expect(typeof mixnode.bond_information.owner).toBe('string');
|
||||
expect(typeof mixnode.bond_information.original_pledge.amount).toBe('string');
|
||||
expect(typeof mixnode.bond_information.original_pledge.denom).toBe('string');
|
||||
expect(typeof mixnode.bond_information.layer).toBe('number');
|
||||
expect(typeof mixnode.bond_information.bonding_height).toBe('number');
|
||||
expect(typeof mixnode.bond_information.is_unbonding).toBe('boolean');
|
||||
expect(typeof mixnode.bond_information.mix_id).toBe("number");
|
||||
expect(typeof mixnode.bond_information.owner).toBe("string");
|
||||
expect(typeof mixnode.bond_information.original_pledge.amount).toBe(
|
||||
"string"
|
||||
);
|
||||
expect(typeof mixnode.bond_information.original_pledge.denom).toBe(
|
||||
"string"
|
||||
);
|
||||
expect(typeof mixnode.bond_information.layer).toBe("number");
|
||||
expect(typeof mixnode.bond_information.bonding_height).toBe("number");
|
||||
expect(typeof mixnode.bond_information.is_unbonding).toBe("boolean");
|
||||
|
||||
if (mixnode.bond_information.proxy === null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
expect(typeof mixnode.bond_information.proxy).toBe('string');
|
||||
} else {
|
||||
expect(typeof mixnode.bond_information.proxy).toBe("string");
|
||||
}
|
||||
|
||||
//mixnode
|
||||
expect(typeof mixnode.bond_information.mix_node.host).toBe('string')
|
||||
expect(mixnode.bond_information.mix_node.http_api_port).toStrictEqual(8000);
|
||||
expect(typeof mixnode.bond_information.mix_node.verloc_port).toBe('number')
|
||||
expect(typeof mixnode.bond_information.mix_node.mix_port).toBe('number')
|
||||
expect(typeof mixnode.bond_information.mix_node.host).toBe("string");
|
||||
expect(mixnode.bond_information.mix_node.http_api_port).toStrictEqual(
|
||||
8000
|
||||
);
|
||||
expect(typeof mixnode.bond_information.mix_node.verloc_port).toBe(
|
||||
"number"
|
||||
);
|
||||
expect(typeof mixnode.bond_information.mix_node.mix_port).toBe("number");
|
||||
expect(mixnode.bond_information.mix_node.mix_port).toStrictEqual(1789);
|
||||
expect(mixnode.bond_information.mix_node.verloc_port).toStrictEqual(1790)
|
||||
expect(mixnode.bond_information.mix_node.verloc_port).toStrictEqual(1790);
|
||||
|
||||
let identitykey = mixnode.bond_information.mix_node.identity_key
|
||||
if (typeof identitykey === 'string') {
|
||||
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);
|
||||
}
|
||||
|
||||
let sphinx = mixnode.bond_information.mix_node.sphinx_key
|
||||
if (typeof sphinx === 'string') {
|
||||
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
|
||||
expect(typeof mixnode.rewarding_details.cost_params.profit_margin_percent).toBe('string')
|
||||
expect(typeof mixnode.rewarding_details.cost_params.interval_operating_cost.denom).toBe('string')
|
||||
expect(typeof mixnode.rewarding_details.cost_params.interval_operating_cost.amount).toBe('string')
|
||||
expect(typeof mixnode.rewarding_details.operator).toBe('string')
|
||||
expect(typeof mixnode.rewarding_details.delegates).toBe('string')
|
||||
expect(typeof mixnode.rewarding_details.total_unit_reward).toBe('string')
|
||||
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')
|
||||
|
||||
expect(
|
||||
typeof mixnode.rewarding_details.cost_params.profit_margin_percent
|
||||
).toBe("string");
|
||||
expect(
|
||||
typeof mixnode.rewarding_details.cost_params.interval_operating_cost
|
||||
.denom
|
||||
).toBe("string");
|
||||
expect(
|
||||
typeof mixnode.rewarding_details.cost_params.interval_operating_cost
|
||||
.amount
|
||||
).toBe("string");
|
||||
expect(typeof mixnode.rewarding_details.operator).toBe("string");
|
||||
expect(typeof mixnode.rewarding_details.delegates).toBe("string");
|
||||
expect(typeof mixnode.rewarding_details.total_unit_reward).toBe("string");
|
||||
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"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -72,101 +88,154 @@ describe("Get mixnode data", (): void => {
|
||||
const response = await contract.getMixnodesDetailed();
|
||||
response.forEach((mixnode) => {
|
||||
// overview details
|
||||
expect(typeof mixnode.estimated_delegators_apy).toBe('string');
|
||||
expect(typeof mixnode.estimated_operator_apy).toBe('string');
|
||||
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');
|
||||
expect(typeof mixnode.estimated_delegators_apy).toBe("string");
|
||||
expect(typeof mixnode.estimated_operator_apy).toBe("string");
|
||||
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");
|
||||
|
||||
//mixnode details bond info
|
||||
expect(typeof mixnode.mixnode_details.bond_information.mix_id).toBe('number')
|
||||
expect(typeof mixnode.mixnode_details.bond_information.owner).toBe('string');
|
||||
expect(typeof mixnode.mixnode_details.bond_information.original_pledge.amount).toBe('string');
|
||||
expect(typeof mixnode.mixnode_details.bond_information.original_pledge.denom).toBe('string');
|
||||
expect(typeof mixnode.mixnode_details.bond_information.layer).toBe('number');
|
||||
expect(typeof mixnode.mixnode_details.bond_information.bonding_height).toBe('number');
|
||||
expect(typeof mixnode.mixnode_details.bond_information.is_unbonding).toBe('boolean');
|
||||
expect(typeof mixnode.mixnode_details.bond_information.mix_id).toBe(
|
||||
"number"
|
||||
);
|
||||
expect(typeof mixnode.mixnode_details.bond_information.owner).toBe(
|
||||
"string"
|
||||
);
|
||||
expect(
|
||||
typeof mixnode.mixnode_details.bond_information.original_pledge.amount
|
||||
).toBe("string");
|
||||
expect(
|
||||
typeof mixnode.mixnode_details.bond_information.original_pledge.denom
|
||||
).toBe("string");
|
||||
expect(typeof mixnode.mixnode_details.bond_information.layer).toBe(
|
||||
"number"
|
||||
);
|
||||
expect(
|
||||
typeof mixnode.mixnode_details.bond_information.bonding_height
|
||||
).toBe("number");
|
||||
expect(typeof mixnode.mixnode_details.bond_information.is_unbonding).toBe(
|
||||
"boolean"
|
||||
);
|
||||
|
||||
if (mixnode.mixnode_details.bond_information.proxy === null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
expect(typeof mixnode.mixnode_details.bond_information.proxy).toBe('string');
|
||||
} 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(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(mixnode.mixnode_details.bond_information.mix_node.mix_port).toStrictEqual(1789);
|
||||
expect(mixnode.mixnode_details.bond_information.mix_node.verloc_port).toStrictEqual(1790)
|
||||
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(
|
||||
mixnode.mixnode_details.bond_information.mix_node.mix_port
|
||||
).toStrictEqual(1789);
|
||||
expect(
|
||||
mixnode.mixnode_details.bond_information.mix_node.verloc_port
|
||||
).toStrictEqual(1790);
|
||||
|
||||
let identitykey2 = mixnode.mixnode_details.bond_information.mix_node.identity_key
|
||||
if (typeof identitykey2 === 'string') {
|
||||
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
|
||||
if (typeof sphinx2 === 'string') {
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
it("Get blacklisted mixnodes", async (): Promise<void> => {
|
||||
const response = await contract.getBlacklistedMixnodes();
|
||||
response.forEach(function (value) {
|
||||
expect(typeof value).toBe('number');
|
||||
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");
|
||||
@@ -67,7 +67,9 @@ describe("Get mixnode data", (): void => {
|
||||
const identity_key = config.environmnetConfig.mix_id;
|
||||
const response = await status.getMixnodeRewardComputation(identity_key);
|
||||
|
||||
expect(response.reward_params.interval.sybil_resistance).toStrictEqual("0.3");
|
||||
expect(response.reward_params.interval.sybil_resistance).toStrictEqual(
|
||||
"0.3"
|
||||
);
|
||||
expect(response.reward_params.active_set_size).toStrictEqual(240);
|
||||
expect(typeof response.reward_params.interval.reward_pool).toBe("string");
|
||||
});
|
||||
@@ -79,42 +81,54 @@ 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();
|
||||
const array = response.inclusion_probabilities;
|
||||
array.forEach((x) => {
|
||||
expect(typeof x.in_reserve).toBe("number");
|
||||
expect(typeof x.mix_id).toBe("number");
|
||||
});
|
||||
expect(typeof response.elapsed.nanos).toBe("number");
|
||||
});
|
||||
|
||||
it("Get all mixnodes", async (): Promise<void> => {
|
||||
const response = await status.getDetailedMixnodes();
|
||||
|
||||
expect(typeof response.stake_saturation).toBe("string");
|
||||
response.forEach((x) => {
|
||||
expect(typeof x.mixnode_details.bond_information.mix_id).toBe("number");
|
||||
expect(typeof x.mixnode_details.bond_information.layer).toBe("number");
|
||||
expect(typeof x.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");
|
||||
response.forEach((x) => {
|
||||
expect(typeof x.mixnode_details.bond_information.mix_id).toBe("number");
|
||||
expect(typeof x.mixnode_details.bond_information.layer).toBe("number");
|
||||
expect(typeof x.stake_saturation).toBe("string");
|
||||
});
|
||||
});
|
||||
|
||||
it("Get all active mixnodes", async (): Promise<void> => {
|
||||
const response = await status.getDetailedActiveMixnodes();
|
||||
|
||||
expect(typeof response.mixnode_details.bond_information.layer).toBe("number");
|
||||
response.forEach((x) => {
|
||||
expect(typeof x.mixnode_details.bond_information.mix_id).toBe("number");
|
||||
expect(typeof x.mixnode_details.bond_information.layer).toBe("number");
|
||||
expect(typeof x.stake_saturation).toBe("string");
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
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");
|
||||
});
|
||||
|
||||
// TODO Fix this test
|
||||
it.skip("with correct data", async (): Promise<void> => {
|
||||
const response = await status.sendMixnodeRewardEstimatedComputation(8);
|
||||
const body = expect(typeof response.estimation.total_node_reward).toBe(
|
||||
"string"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ class ConfigHandler {
|
||||
|
||||
private constructor() {
|
||||
this.setCommonConfig();
|
||||
this.setEnvironmentConfig(process.env.TEST_ENV || "qa" || "prod" );
|
||||
this.setEnvironmentConfig(process.env.TEST_ENV || "qa" || "prod");
|
||||
}
|
||||
|
||||
public static getInstance(): ConfigHandler {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
Detailed
|
||||
} from "../types/CirculatingSupplyTypes";
|
||||
import { Detailed } from "../types/CirculatingSupplyTypes";
|
||||
import { APIClient } from "./abstracts/APIClient";
|
||||
|
||||
export default class ContractCache extends APIClient {
|
||||
@@ -13,5 +11,19 @@ export default class ContractCache extends APIClient {
|
||||
route: `circulating-supply`,
|
||||
});
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
BlacklistedGateways,
|
||||
BlacklistedMixnodes,
|
||||
CurrentEpoch,
|
||||
Mixnode
|
||||
} from "../types/ContractCacheTypes";
|
||||
import { APIClient } from "./abstracts/APIClient";
|
||||
|
||||
@@ -81,16 +80,15 @@ export default class ContractCache extends APIClient {
|
||||
|
||||
public async getEpochRewardParams(): Promise<EpochRewardParams> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `epoch/reward_params`
|
||||
route: `epoch/reward_params`,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getCurrentEpoch(): Promise<CurrentEpoch> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `epoch/current`
|
||||
route: `epoch/current`,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
ActiveStatus,
|
||||
AvgUptime,
|
||||
ComputeRewardEstimation,
|
||||
CoreCount,
|
||||
DetailedGateway,
|
||||
DetailedMixnodes,
|
||||
@@ -96,7 +95,7 @@ export default class Status extends APIClient {
|
||||
): Promise<RewardEstimation> {
|
||||
const response = await this.restClient.sendPost({
|
||||
route: `/mixnode/${mix_id}/compute-reward-estimation`,
|
||||
data: {
|
||||
data: {
|
||||
// performance: "10",
|
||||
active_in_rewarded_set: true,
|
||||
// pledge_amount: 10,
|
||||
@@ -106,7 +105,7 @@ export default class Status extends APIClient {
|
||||
// amount: "250000000"
|
||||
// },
|
||||
// profit_margin_percent: 10
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return response.data;
|
||||
@@ -120,9 +119,7 @@ export default class Status extends APIClient {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
public async getMixnodeAverageUptime(
|
||||
mix_id: number
|
||||
): Promise<AvgUptime> {
|
||||
public async getMixnodeAverageUptime(mix_id: number): Promise<AvgUptime> {
|
||||
const response = await this.restClient.sendGet({
|
||||
route: `/mixnode/${mix_id}/avg_uptime`,
|
||||
});
|
||||
@@ -150,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`,
|
||||
});
|
||||
@@ -164,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`,
|
||||
});
|
||||
@@ -172,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,26 +1,26 @@
|
||||
export type Detailed = {
|
||||
initial_supply: InitialSupply;
|
||||
mixmining_reserve: MixminingReserve;
|
||||
vesting_tokens: VestingTokens;
|
||||
circulating_supply: CirculatingSupply;
|
||||
};
|
||||
|
||||
export type InitialSupply = {
|
||||
demon: "unym";
|
||||
amount: string;
|
||||
};
|
||||
total_supply: TotalSupply;
|
||||
mixmining_reserve: MixminingReserve;
|
||||
vesting_tokens: VestingTokens;
|
||||
circulating_supply: CirculatingSupply;
|
||||
};
|
||||
|
||||
export type MixminingReserve = {
|
||||
demon: "unym";
|
||||
amount: string;
|
||||
};
|
||||
export type TotalSupply = {
|
||||
demon: "unym";
|
||||
amount: string;
|
||||
};
|
||||
|
||||
export type VestingTokens = {
|
||||
demon: "unym";
|
||||
amount: string;
|
||||
};
|
||||
export type MixminingReserve = {
|
||||
demon: "unym";
|
||||
amount: string;
|
||||
};
|
||||
|
||||
export type CirculatingSupply = {
|
||||
demon: "unym";
|
||||
amount: string;
|
||||
};
|
||||
export type VestingTokens = {
|
||||
demon: "unym";
|
||||
amount: string;
|
||||
};
|
||||
|
||||
export type CirculatingSupply = {
|
||||
demon: "unym";
|
||||
amount: string;
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ export type BondInformation = {
|
||||
proxy: string;
|
||||
bonding_height: number;
|
||||
is_unbonding: boolean;
|
||||
}
|
||||
};
|
||||
|
||||
export type RewardingDetails = {
|
||||
cost_params: CostParams;
|
||||
@@ -22,22 +22,22 @@ export type RewardingDetails = {
|
||||
unit_delegation: string;
|
||||
last_rewarded_epoch: number;
|
||||
unique_delegations: number;
|
||||
}
|
||||
};
|
||||
|
||||
export type CostParams = {
|
||||
profit_margin_percent: string;
|
||||
interval_operating_cost: IntervalOperatingCost;
|
||||
}
|
||||
};
|
||||
|
||||
export type IntervalOperatingCost = {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
};
|
||||
|
||||
export type OriginalPledge = {
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
};
|
||||
|
||||
export type TotalDelegation = {
|
||||
denom: string;
|
||||
@@ -63,23 +63,21 @@ export type MixnodeBond = {
|
||||
mix_node: Mixnode;
|
||||
proxy: string;
|
||||
accumulated_rewards: string;
|
||||
}
|
||||
};
|
||||
|
||||
export type MixnodesDetailed = {
|
||||
mixnode_details: AllMixnodes;
|
||||
stake_saturation: string;
|
||||
uncapped_stake_saturation: string;
|
||||
performance: string;
|
||||
estimated_operator_apy: string
|
||||
estimated_operator_apy: string;
|
||||
estimated_delegators_apy: string;
|
||||
family: string
|
||||
family: string;
|
||||
};
|
||||
|
||||
export type BlacklistedMixnodes = {
|
||||
};
|
||||
export type BlacklistedMixnodes = {};
|
||||
|
||||
export type BlacklistedGateways = {
|
||||
};
|
||||
export type BlacklistedGateways = {};
|
||||
|
||||
export interface Gateway {
|
||||
host: string;
|
||||
@@ -114,7 +112,7 @@ export type Interval = {
|
||||
sybil_resistance: string;
|
||||
active_set_work_factor: string;
|
||||
interval_pool_emission: string;
|
||||
}
|
||||
};
|
||||
|
||||
export type CurrentEpoch = {
|
||||
id: number;
|
||||
@@ -129,4 +127,3 @@ export type EpochLength = {
|
||||
secs: number;
|
||||
nanos: number;
|
||||
};
|
||||
|
||||
|
||||
@@ -48,17 +48,17 @@ export interface RewardParams {
|
||||
}
|
||||
|
||||
export interface ComputeRewardEstimation {
|
||||
performance: string,
|
||||
active_in_rewarded_set: boolean,
|
||||
pledge_amount: number,
|
||||
total_delegation: number,
|
||||
performance: string;
|
||||
active_in_rewarded_set: boolean;
|
||||
pledge_amount: number;
|
||||
total_delegation: number;
|
||||
interval_operating_cost: IntervalOperatingCost;
|
||||
profit_margin_percent: string
|
||||
profit_margin_percent: string;
|
||||
}
|
||||
|
||||
export interface IntervalOperatingCost {
|
||||
denom: string,
|
||||
amount: string
|
||||
denom: string;
|
||||
amount: string;
|
||||
}
|
||||
|
||||
export interface Interval {
|
||||
@@ -123,14 +123,14 @@ export interface History {
|
||||
}
|
||||
|
||||
export interface NodeHistory {
|
||||
mix_id: number,
|
||||
mix_id: number;
|
||||
identity: string;
|
||||
owner: string;
|
||||
history: History[];
|
||||
}
|
||||
|
||||
export interface CoreCount {
|
||||
mix_id: number,
|
||||
mix_id: number;
|
||||
identity: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user