diff --git a/validator-api/tests/functional_test/validator-api/contract_cache/contract-cache-epochs.test.ts b/validator-api/tests/functional_test/validator-api/contract_cache/contract-cache-epochs.test.ts index 861249d5ff..5451478081 100644 --- a/validator-api/tests/functional_test/validator-api/contract_cache/contract-cache-epochs.test.ts +++ b/validator-api/tests/functional_test/validator-api/contract_cache/contract-cache-epochs.test.ts @@ -13,20 +13,27 @@ describe("Get epoch info", (): void => { it("Get epoch reward params", async (): Promise => { const response = await contract.getEpochRewardParams(); - expect(typeof response.epoch_reward_pool).toBe('string'); - expect(typeof response.rewarded_set_size).toBe('string'); - expect(typeof response.active_set_size).toBe('string'); - expect(typeof response.staking_supply).toBe('string'); - expect(typeof response.sybil_resistance_percent).toBe('number'); - expect(typeof response.active_set_work_factor).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 => { const response = await contract.getCurrentEpoch(); expect(typeof response.id).toBe('number'); - expect(typeof response.start).toBe('string'); - expect(typeof response.length.secs).toBe('number'); - expect(typeof response.length.nanos).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'); }); diff --git a/validator-api/tests/functional_test/validator-api/contract_cache/mixnode/contract-cache-mixnode.test.ts b/validator-api/tests/functional_test/validator-api/contract_cache/mixnode/contract-cache-mixnode.test.ts index 695a561152..d3e68a61b9 100644 --- a/validator-api/tests/functional_test/validator-api/contract_cache/mixnode/contract-cache-mixnode.test.ts +++ b/validator-api/tests/functional_test/validator-api/contract_cache/mixnode/contract-cache-mixnode.test.ts @@ -15,32 +15,32 @@ describe("Get mixnode data", (): void => { const response = await contract.getMixnodes(); response.forEach((mixnode) => { - //overview - expect(typeof mixnode.owner).toBe('string'); - expect(typeof mixnode.block_height).toBe('number'); - expect(typeof mixnode.layer).toBe('number'); - expect(typeof mixnode.accumulated_rewards).toBe('string'); + //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('string'); + expect(typeof mixnode.bond_information.bonding_height).toBe('number'); + expect(typeof mixnode.bond_information.is_unbonding).toBe('boolean'); - if (mixnode.proxy === null) { + if (mixnode.bond_information.proxy === null) { return true; } else { - expect(typeof mixnode.proxy).toBe('string'); + expect(typeof mixnode.bond_information.proxy).toBe('string'); } - //pledge - expect(typeof mixnode.pledge_amount.amount).toBe('string'); - expect(mixnode.pledge_amount.denom).toBe('unym'); - - //total_deleglation - expect(typeof mixnode.total_delegation.amount).toBe('string') - expect(mixnode.total_delegation.denom).toBe('unym'); - //mixnode - expect(typeof mixnode.mix_node.host).toBe('string') - expect(typeof mixnode.mix_node.profit_margin_percent).toBe('number'); + expect(typeof mixnode.bond_information.mix_node.host).toBe('string') + expect(typeof 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.sphinx_key).toBe('number') + expect(typeof mixnode.bond_information.mix_node.mix_port).toStrictEqual(1789); + expect(typeof mixnode.bond_information.mix_node.verloc_port).toStrictEqual(1790) - let identitykey = mixnode.mix_node.identity_key + let identitykey = mixnode.bond_information.mix_node.identity_key if (typeof identitykey === 'string') { if (identitykey.length === 43) { return true @@ -48,78 +48,93 @@ describe("Get mixnode data", (): void => { else expect(identitykey).toHaveLength(44); } - let sphinx = mixnode.mix_node.sphinx_key + let sphinx = mixnode.bond_information.mix_node.sphinx_key if (typeof sphinx === 'string') { if (sphinx.length === 43) { return true } else expect(sphinx).toHaveLength(44); } - expect(mixnode.mix_node.verloc_port).toStrictEqual(1790); - expect(mixnode.mix_node.mix_port).toStrictEqual(1789); - expect(mixnode.mix_node.http_api_port).toStrictEqual(8000); - expect(typeof mixnode.mix_node.version).toBe('string'); + + //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') + }); }); it("Get all mixnodes detailed", async (): Promise => { const response = await contract.getMixnodesDetailed(); response.forEach((mixnode) => { - //mixnode_bond.pledge_amount - expect(typeof mixnode.mixnode_bond.pledge_amount.amount).toBe('string'); - expect(mixnode.mixnode_bond.pledge_amount.denom).toBe('unym'); + // 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'); - //mixnode_bond.total_delegation - expect(typeof mixnode.mixnode_bond.total_delegation.amount).toBe('string') - expect(mixnode.mixnode_bond.total_delegation.denom).toBe('unym'); + //mixnode details bond info + expect(typeof mixnode.mixnode_details.bond_information.mix_id).toBe('string') + 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('string'); + expect(typeof mixnode.mixnode_details.bond_information.bonding_height).toBe('number'); + expect(typeof mixnode.mixnode_details.bond_information.is_unbonding).toBe('boolean'); - //mixnode_bond.mix_node - expect(typeof mixnode.mixnode_bond.mix_node.host).toBe('string') - expect(typeof mixnode.mixnode_bond.mix_node.profit_margin_percent).toBe('number'); - - let identitykey = mixnode.mixnode_bond.mix_node.identity_key - if (typeof identitykey === 'string') { - if (identitykey.length === 43) { - return true - } - else expect(identitykey).toHaveLength(44); - } - - let sphinx = mixnode.mixnode_bond.mix_node.sphinx_key - if (typeof sphinx === 'string') { - if (sphinx.length === 43) { - return true - } - else expect(sphinx).toHaveLength(44); - } - - expect(mixnode.mixnode_bond.mix_node.verloc_port).toStrictEqual(1790); - expect(mixnode.mixnode_bond.mix_node.mix_port).toStrictEqual(1789); - expect(mixnode.mixnode_bond.mix_node.http_api_port).toStrictEqual(8000); - expect(typeof mixnode.mixnode_bond.mix_node.version).toBe('string'); - - //mixnode_bond.overview - expect(typeof mixnode.mixnode_bond.owner).toBe('string'); - expect(typeof mixnode.mixnode_bond.block_height).toBe('number'); - expect(typeof mixnode.mixnode_bond.layer).toBe('number'); - expect(typeof mixnode.mixnode_bond.accumulated_rewards).toBe('string'); - - if (mixnode.mixnode_bond.proxy === null) { + if (mixnode.mixnode_details.bond_information.proxy === null) { return true; } else { - expect(typeof mixnode.mixnode_bond.proxy).toBe('string'); + expect(typeof mixnode.mixnode_details.bond_information.proxy).toBe('string'); } - //overview - expect(typeof mixnode.stake_saturation).toBe('number'); - expect(typeof mixnode.uptime).toBe('number'); - expect(typeof mixnode.estimated_operator_apy).toBe('number'); - expect(typeof mixnode.estimated_delegators_apy).toBe('number'); + //mixnode + expect(typeof mixnode.mixnode_details.bond_information.mix_node.host).toBe('string') + expect(typeof 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.sphinx_key).toBe('number') + expect(typeof mixnode.mixnode_details.bond_information.mix_node.mix_port).toStrictEqual(1789); + expect(typeof 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') { + if (identitykey2.length === 43) { + return true + } + else expect(identitykey2).toHaveLength(44); + } + + let 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); + } + + //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') + }); }); - it("Get active mixnodes", async (): Promise => { const response = await contract.getActiveMixnodes(); //TO-DO this test should focus more on checking that the response actually contains active nodes @@ -133,10 +148,8 @@ describe("Get mixnode data", (): void => { it("Get blacklisted mixnodes", async (): Promise => { const response = await contract.getBlacklistedMixnodes(); response.forEach(function (value) { - expect(typeof value).toBe('string'); + expect(typeof value).toBe('number'); }); }); }); - - diff --git a/validator-api/tests/functional_test/validator-api/status/status-mixnode.test.ts b/validator-api/tests/functional_test/validator-api/status/status-mixnode.test.ts index 8e6707139c..a94a038966 100644 --- a/validator-api/tests/functional_test/validator-api/status/status-mixnode.test.ts +++ b/validator-api/tests/functional_test/validator-api/status/status-mixnode.test.ts @@ -37,9 +37,9 @@ describe("Get mixnode data", (): void => { const response = await status.getMixnodeAverageUptime(identity_key); console.log(response.avg_uptime); - console.log(response.identity); + console.log(response.mix_id); - expect(identity_key).toStrictEqual(response.identity); + expect(identity_key).toStrictEqual(response.mix_id); expect(typeof response.avg_uptime).toBe("number"); }); @@ -49,7 +49,7 @@ describe("Get mixnode data", (): void => { response.forEach((mixnode) => { expect(typeof mixnode.avg_uptime).toBe("number"); - expect(typeof mixnode.identity).toBe("string"); + expect(typeof mixnode.mix_id).toBe("string"); }); }); @@ -76,9 +76,9 @@ describe("Get mixnode data", (): void => { const response = await status.getMixnodeCoreCount(identity_key); console.log(response.count); - console.log(response.identity); + console.log(response.mix_id); - expect(identity_key).toStrictEqual(response.identity); + expect(identity_key).toStrictEqual(response.mix_id); expect(typeof response.count).toBe("number"); }); @@ -95,33 +95,35 @@ describe("Get mixnode data", (): void => { const identity_key = config.environmnetConfig.mixnode_identity; const response = await status.getMixnodeRewardComputation(identity_key); - console.log(response.estimated_delegators_reward); - console.log(response.estimated_node_profit); - console.log(response.estimated_operator_cost); - console.log(response.estimated_operator_reward); - console.log(response.estimated_total_node_reward); - console.log(response.reward_params); - console.log(response.as_at); - console.log(response); + //estimation + expect(typeof response.estimation.total_node_reward).toBe("string"); + expect(typeof response.estimation.operator).toBe("string"); + expect(typeof response.estimation.delegates).toBe("string"); + expect(typeof response.estimation.operating_cost).toBe("string"); - //overview - expect(typeof response.estimated_total_node_reward).toBe("number"); - expect(typeof response.estimated_operator_reward).toBe("number"); - expect(typeof response.estimated_delegators_reward).toBe("number"); - expect(typeof response.estimated_node_profit).toBe("number"); - expect(typeof response.estimated_operator_cost).toBe("number"); - expect(typeof response.as_at).toBe("number"); //reward_params - expect(typeof response.reward_params.epoch.epoch_reward_pool).toBe("string"); - expect(typeof response.reward_params.epoch.rewarded_set_size).toBe("string"); - expect(typeof response.reward_params.epoch.active_set_size).toBe("string"); - expect(typeof response.reward_params.epoch.staking_supply).toBe("string"); - expect(typeof response.reward_params.epoch.sybil_resistance_percent).toBe("number"); - expect(typeof response.reward_params.epoch.active_set_work_factor).toBe("number"); - //node - expect(typeof response.reward_params.node.reward_blockstamp).toBe("number"); - expect(typeof response.reward_params.node.uptime).toBe("string"); - expect(typeof response.reward_params.node.in_active_set).toBe("boolean"); + expect(typeof response.reward_params.interval.reward_pool).toBe("string"); + expect(typeof response.reward_params.interval.staking_supply).toBe("string"); + expect(typeof response.reward_params.interval.staking_supply_scale_factor).toBe("string"); + expect(typeof response.reward_params.interval.epoch_reward_budget).toBe("string"); + expect(typeof response.reward_params.interval.stake_saturation_point).toBe("string"); + expect(typeof response.reward_params.interval.sybil_resistance).toBe("string"); + expect(typeof response.reward_params.interval.active_set_work_factor).toBe("string"); + expect(typeof response.reward_params.interval.interval_pool_emission).toBe("string"); + expect(typeof response.reward_params.rewarded_set_size).toBe("string"); + expect(typeof response.reward_params.active_set_size).toBe("string"); + + //epoch + expect(typeof response.epoch.id).toBe("number"); + expect(typeof response.epoch.epochs_in_interval).toBe("number"); + expect(typeof response.epoch.current_epoch_start).toBe("string"); + expect(typeof response.epoch.current_epoch_id).toBe("number"); + expect(typeof response.epoch.epoch_length.secs).toBe("number"); + expect(typeof response.epoch.epoch_length.nanos).toBe("number"); + expect(typeof response.epoch.total_elapsed_epochs).toBe("number"); + + expect(typeof response.as_at).toBe("number"); + }); @@ -140,23 +142,33 @@ describe("Get mixnode data", (): void => { const identity_key = config.environmnetConfig.mixnode_identity; const response = await status.getMixnodeRewardEstimatedComputation(identity_key); - //overview - expect(typeof response.estimated_total_node_reward).toBe("number"); - expect(typeof response.estimated_operator_reward).toBe("number"); - expect(typeof response.estimated_delegators_reward).toBe("number"); - expect(typeof response.estimated_node_profit).toBe("number"); - expect(typeof response.estimated_operator_cost).toBe("number"); - expect(typeof response.as_at).toBe("number"); - //reward_params - expect(typeof response.reward_params.epoch.epoch_reward_pool).toBe("string"); - expect(typeof response.reward_params.epoch.rewarded_set_size).toBe("string"); - expect(typeof response.reward_params.epoch.active_set_size).toBe("string"); - expect(typeof response.reward_params.epoch.staking_supply).toBe("string"); - expect(typeof response.reward_params.epoch.sybil_resistance_percent).toBe("number"); - expect(typeof response.reward_params.epoch.active_set_work_factor).toBe("number"); - //node - expect(typeof response.reward_params.node.reward_blockstamp).toBe("number"); - expect(typeof response.reward_params.node.uptime).toBe("string"); - expect(typeof response.reward_params.node.in_active_set).toBe("boolean"); + //estimation + expect(typeof response.estimation.total_node_reward).toBe("string"); + expect(typeof response.estimation.operator).toBe("string"); + expect(typeof response.estimation.delegates).toBe("string"); + expect(typeof response.estimation.operating_cost).toBe("string"); + + //reward_params + expect(typeof response.reward_params.interval.reward_pool).toBe("string"); + expect(typeof response.reward_params.interval.staking_supply).toBe("string"); + expect(typeof response.reward_params.interval.staking_supply_scale_factor).toBe("string"); + expect(typeof response.reward_params.interval.epoch_reward_budget).toBe("string"); + expect(typeof response.reward_params.interval.stake_saturation_point).toBe("string"); + expect(typeof response.reward_params.interval.sybil_resistance).toBe("string"); + expect(typeof response.reward_params.interval.active_set_work_factor).toBe("string"); + expect(typeof response.reward_params.interval.interval_pool_emission).toBe("string"); + expect(typeof response.reward_params.rewarded_set_size).toBe("string"); + expect(typeof response.reward_params.active_set_size).toBe("string"); + + //epoch + expect(typeof response.epoch.id).toBe("number"); + expect(typeof response.epoch.epochs_in_interval).toBe("number"); + expect(typeof response.epoch.current_epoch_start).toBe("string"); + expect(typeof response.epoch.current_epoch_id).toBe("number"); + expect(typeof response.epoch.epoch_length.secs).toBe("number"); + expect(typeof response.epoch.epoch_length.nanos).toBe("number"); + expect(typeof response.epoch.total_elapsed_epochs).toBe("number"); + + expect(typeof response.as_at).toBe("number"); }) });