diff --git a/apps/explorer/lib/explorer/staking/contract_state.ex b/apps/explorer/lib/explorer/staking/contract_state.ex index fc4dd2a120..591b4aea4a 100644 --- a/apps/explorer/lib/explorer/staking/contract_state.ex +++ b/apps/explorer/lib/explorer/staking/contract_state.ex @@ -75,12 +75,12 @@ defmodule Explorer.Staking.ContractState do staking_contract_address = Application.get_env(:explorer, __MODULE__)[:staking_contract_address] %{ - "validatorSetContract" => {:ok, [validator_set_contract_address]}, - "erc677TokenContract" => {:ok, [token_contract_address]} + "erc677TokenContract" => {:ok, [token_contract_address]}, + "validatorSetContract" => {:ok, [validator_set_contract_address]} } = Reader.query_contract(staking_contract_address, staking_abi, %{ - "validatorSetContract" => [], - "erc677TokenContract" => [] + "erc677TokenContract" => [], + "validatorSetContract" => [] }) %{"blockRewardContract" => {:ok, [block_reward_contract_address]}} = diff --git a/apps/explorer/test/explorer/staking/contract_state_test.exs b/apps/explorer/test/explorer/staking/contract_state_test.exs index b87a1fc0d4..330959e97c 100644 --- a/apps/explorer/test/explorer/staking/contract_state_test.exs +++ b/apps/explorer/test/explorer/staking/contract_state_test.exs @@ -30,21 +30,18 @@ defmodule Explorer.Staking.ContractStateTest do start_supervised!(ContractState) - set_mox() - Publisher.broadcast([{:blocks, [%Explorer.Chain.Block{number: 6000}]}], :realtime) - Publisher.broadcast([{:blocks, [%Explorer.Chain.Block{number: 5999}]}], :realtime) - Publisher.broadcast([{:blocks, [%Explorer.Chain.Block{number: 6000}]}], :realtime) + Publisher.broadcast([{:blocks, [%Explorer.Chain.Block{number: 76}]}], :realtime) Process.sleep(500) - assert ContractState.get(:epoch_number) == 74 - assert ContractState.get(:epoch_end_block) == 6000 + assert ContractState.get(:epoch_number) == 1 + assert ContractState.get(:epoch_end_block) == 152 assert ContractState.get(:min_delegator_stake) == 1_000_000_000_000_000_000 assert ContractState.get(:min_candidate_stake) == 1_000_000_000_000_000_000 assert ContractState.get(:token_contract_address) == "0x6f7a73c96bd56f8b0debc795511eda135e105ea3" - assert Repo.aggregate(StakingPool, :count, :id) == 7 - assert Repo.aggregate(StakingPoolsDelegator, :count, :id) == 10 + assert Repo.aggregate(StakingPool, :count, :id) == 6 + assert Repo.aggregate(StakingPoolsDelegator, :count, :id) == 16 end defp set_init_mox() do @@ -55,10 +52,12 @@ defmodule Explorer.Staking.ContractStateTest do assert length(requests) == 2 {:ok, - format_responses([ - "0x0000000000000000000000006f7a73c96bd56f8b0debc795511eda135e105ea3", - "0x0000000000000000000000001000000000000000000000000000000000000001" - ])} + format_responses([ + # StakingAuRa.erc677TokenContract + "0x0000000000000000000000006f7a73c96bd56f8b0debc795511eda135e105ea3", + # StakingAuRa.validatorSetContract + "0x0000000000000000000000001000000000000000000000000000000000000001" + ])} end ) @@ -67,12 +66,12 @@ defmodule Explorer.Staking.ContractStateTest do :json_rpc, fn requests, _opts -> assert length(requests) == 1 + # ValidatorSetAuRa.blockRewardContract {:ok, format_responses(["0x0000000000000000000000002000000000000000000000000000000000000001"])} end ) - end - defp set_mox() do + # get_token, fetch_token, MetadataRetriever.get_functions_of expect( EthereumJSONRPC.Mox, :json_rpc, @@ -80,19 +79,22 @@ defmodule Explorer.Staking.ContractStateTest do assert length(requests) == 4 {:ok, - format_responses([ - # 1 decimals - "0x0000000000000000000000000000000000000000000000000000000000000012", - # 2 name - "0x7465737400000000000000000000000000000000000000000000000000000000", - # 3 symbol - "0x5453540000000000000000000000000000000000000000000000000000000000", - # 4 totalSupply - "0x00000000000000000000000000000000000000000000000000000000000f4240" - ])} + format_responses([ + # ERC677BridgeTokenRewardable.decimals + "0x0000000000000000000000000000000000000000000000000000000000000012", + # ERC677BridgeTokenRewardable.name + "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000055354414b45000000000000000000000000000000000000000000000000000000", + # ERC677BridgeTokenRewardable.symbol + "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000055354414b45000000000000000000000000000000000000000000000000000000", + # ERC677BridgeTokenRewardable.totalSupply + "0x000000000000000000000000000000000000000000000001f399b1438a100000" + ])} end ) + end + defp set_mox() do + # ContractReader.global_requests expect( EthereumJSONRPC.Mox, :json_rpc, @@ -100,39 +102,40 @@ defmodule Explorer.Staking.ContractStateTest do assert length(requests) == 14 {:ok, - format_responses([ - # 1 getPools - "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000b2f5e2f3cbd864eaa2c642e3769c1582361caf6000000000000000000000000b916e7e1f4bcb13549602ed042d36746fd0d96c9000000000000000000000000db9cb2478d917719c53862008672166808258577", - # 2 stakingEpochEndBlock - "0x0000000000000000000000000000000000000000000000000000000000001770", - # 3 stakingEpoch - "0x000000000000000000000000000000000000000000000000000000000000004a", - # 4 stakingEpochStartBlock - "0x0000000000000000000000000000000000000000000000000000000000001760", - # 5 getPoolsInactive - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000b6695f5c2e3f5eff8036b5f5f3a9d83a5310e51e", - # 6 candidateMinStake - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", - # 7 delegatorMinStake - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", - # 8 getPoolsLikelihood - "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000514000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000c8000000000000000000000000000000000000000000000000000000000000044c", - # 9 getPoolsToBeElected - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000b916e7e1f4bcb13549602ed042d36746fd0d96c9000000000000000000000000db9cb2478d917719c53862008672166808258577", - # 10 areStakeAndWithdrawAllowed - "0x0000000000000000000000000000000000000000000000000000000000000001", - # 11 erc677TokenContract - "0x0000000000000000000000006f7a73c96bd56f8b0debc795511eda135e105ea3", - # 12 unremovableValidator - "0x0000000000000000000000000b2f5e2f3cbd864eaa2c642e3769c1582361caf6", - # 13 getValidators - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000bbcaa8d48289bb1ffcf9808d9aa4b1d215054c78000000000000000000000000f67cc5231c5858ad6cc87b105217426e17b824bb000000000000000000000000be69eb0968226a1808975e1a1f2127667f2bffb3", - # 14 validatorSetApplyBlock - "0x0000000000000000000000000000000000000000000000000000000000000001" - ])} + format_responses([ + # 1 StakingAuRa.getPools + "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000b2f5e2f3cbd864eaa2c642e3769c1582361caf6000000000000000000000000b6695f5c2e3f5eff8036b5f5f3a9d83a5310e51e000000000000000000000000db9cb2478d917719c53862008672166808258577000000000000000000000000b916e7e1f4bcb13549602ed042d36746fd0d96c9", + # 2 StakingAuRa.stakingEpochEndBlock + "0x0000000000000000000000000000000000000000000000000000000000000098", + # 3 StakingAuRa.stakingEpoch + "0x0000000000000000000000000000000000000000000000000000000000000001", + # 4 StakingAuRa.stakingEpochStartBlock + "0x000000000000000000000000000000000000000000000000000000000000004d", + # 5 StakingAuRa.getPoolsInactive + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + # 6 StakingAuRa.candidateMinStake + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + # 7 StakingAuRa.delegatorMinStake + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + # 8 StakingAuRa.getPoolsLikelihood + "0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000001bc16d674ec8000000000000000000000000000000000000000000000000000098a7d9b8314c000000000000000000000000000000000000000000000000000029a2241af62c0000", + # 9 StakingAuRa.getPoolsToBeElected + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b916e7e1f4bcb13549602ed042d36746fd0d96c9000000000000000000000000db9cb2478d917719c53862008672166808258577000000000000000000000000b6695f5c2e3f5eff8036b5f5f3a9d83a5310e51e", + # 10 StakingAuRa.areStakeAndWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 11 StakingAuRa.erc677TokenContract + "0x0000000000000000000000006f7a73c96bd56f8b0debc795511eda135e105ea3", + # 12 ValidatorSetAuRa.unremovableValidator + "0x0000000000000000000000000b2f5e2f3cbd864eaa2c642e3769c1582361caf6", + # 13 ValidatorSetAuRa.getValidators + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000bbcaa8d48289bb1ffcf9808d9aa4b1d215054c7800000000000000000000000075df42383afe6bf5194aa8fa0e9b3d5f9e869441000000000000000000000000522df396ae70a058bd69778408630fdb023389b2", + # 14 ValidatorSetAuRa.validatorSetApplyBlock + "0x0000000000000000000000000000000000000000000000000000000000000000" + ])} end ) + # get_validator_min_reward_percent expect( EthereumJSONRPC.Mox, :json_rpc, @@ -140,442 +143,520 @@ defmodule Explorer.Staking.ContractStateTest do assert length(requests) == 1 {:ok, - format_responses([ - # 1 validatorMinRewardPercent - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} - end - ) - - expect( - EthereumJSONRPC.Mox, - :json_rpc, - fn requests, _opts -> - assert length(requests) == 3 - - {:ok, - format_responses([ - # 1 stakingByMiningAddress - "0x000000000000000000000000a5063b12c4d6ca73e189ef071f6712d048175055", - # 2 stakingByMiningAddress - "0x0000000000000000000000003efbc7ae3e8f608f1336076a4004aa191d2ca7c7", - # 3 stakingByMiningAddress - "0x0000000000000000000000006f2859f4e38423b85ff2152bdc7c43720171a12f" - ])} - end - ) - - expect( - EthereumJSONRPC.Mox, - :json_rpc, - fn requests, _opts -> - assert length(requests) == 49 - - {:ok, - format_responses([ - # 1 poolDelegators - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 2 poolDelegatorsInactive - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 3 isPoolActive - "0x0000000000000000000000000000000000000000000000000000000000000001", - # 4 miningByStakingAddress - "0x000000000000000000000000bbcaa8d48289bb1ffcf9808d9aa4b1d215054c78", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 stakeAmountTotal - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 7 validatorRewardPercent - "0x000000000000000000000000000000000000000000000000000000000003d090", - - # 1 poolDelegators - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 2 poolDelegatorsInactive - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 3 isPoolActive - "0x0000000000000000000000000000000000000000000000000000000000000001", - # 4 miningByStakingAddress - "0x000000000000000000000000f67cc5231c5858ad6cc87b105217426e17b824bb", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", - # 6 stakeAmountTotal - "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", - # 7 validatorRewardPercent - "0x0000000000000000000000000000000000000000000000000000000000051615", - - # 1 poolDelegators - "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000009d99f80d3b59cca783f11918311fb31212fb7500000000000000000000000008d6867958e1cab5c39160a1d30fbc68ac55b45ef", - # 2 poolDelegatorsInactive - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 3 isPoolActive - "0x0000000000000000000000000000000000000000000000000000000000000001", - # 4 miningByStakingAddress - "0x000000000000000000000000be69eb0968226a1808975e1a1f2127667f2bffb3", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", - # 6 stakeAmountTotal - "0x00000000000000000000000000000000000000000000000098a7d9b8314c0000", - # 7 validatorRewardPercent - "0x0000000000000000000000000000000000000000000000000000000000051615", - - # 1 poolDelegators - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000e4978fac7adfc925352dbc7e1962e6545142eeee", - # 2 poolDelegatorsInactive - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 3 isPoolActive - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 miningByStakingAddress - "0x000000000000000000000000720e118ab1006cc97ed2ef6b4b49ac04bb3aa6d9", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", - # 6 stakeAmountTotal - "0x00000000000000000000000000000000000000000000000029a2241af62c0000", - # 7 validatorRewardPercent - "0x0000000000000000000000000000000000000000000000000000000000051615", - - # 1 poolDelegators - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 2 poolDelegatorsInactive - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 3 isPoolActive - "0x0000000000000000000000000000000000000000000000000000000000000001", - # 4 miningByStakingAddress - "0x00000000000000000000000015b18132380cbc7e200e2c0b46de3cad06f53f36", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 stakeAmountTotal - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 7 validatorRewardPercent - "0x000000000000000000000000000000000000000000000000000000000003d090", - - # 1 poolDelegators - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 2 poolDelegatorsInactive - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 3 isPoolActive - "0x0000000000000000000000000000000000000000000000000000000000000001", - # 4 miningByStakingAddress - "0x0000000000000000000000006defba7208e8fc11d8c7c32e10be08c19b155089", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 stakeAmountTotal - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 7 validatorRewardPercent - "0x000000000000000000000000000000000000000000000000000000000003d090", - - # 1 poolDelegators - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 2 poolDelegatorsInactive - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 3 isPoolActive - "0x0000000000000000000000000000000000000000000000000000000000000001", - # 4 miningByStakingAddress - "0x0000000000000000000000006a8a0060ed0d1c083b34d9122ab61cbe626a59f6", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 stakeAmountTotal - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 7 validatorRewardPercent - "0x000000000000000000000000000000000000000000000000000000000003d090" - ])} - end - ) - - expect( - EthereumJSONRPC.Mox, - :json_rpc, - fn requests, _opts -> - assert length(requests) == 49 - - {:ok, - format_responses([ - # 1 areDelegatorsBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 banReason - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 bannedUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 bannedDelegatorsUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 isValidatorBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 validatorCounter - "0x000000000000000000000000000000000000000000000000000000000000004b", - # 7 banCounter - "0x0000000000000000000000000000000000000000000000000000000000000000", - - # 1 areDelegatorsBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 banReason - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 bannedUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 bannedDelegatorsUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 isValidatorBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 validatorCounter - "0x0000000000000000000000000000000000000000000000000000000000000002", - # 7 banCounter - "0x0000000000000000000000000000000000000000000000000000000000000000", - - # 1 areDelegatorsBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 banReason - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 bannedUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 bannedDelegatorsUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 isValidatorBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 validatorCounter - "0x000000000000000000000000000000000000000000000000000000000000004a", - # 7 banCounter - "0x0000000000000000000000000000000000000000000000000000000000000000", - - # 1 areDelegatorsBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 banReason - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 bannedUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 bannedDelegatorsUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 isValidatorBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 validatorCounter - "0x000000000000000000000000000000000000000000000000000000000000004a", - # 7 banCounter - "0x0000000000000000000000000000000000000000000000000000000000000000", - - # 1 areDelegatorsBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 banReason - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 bannedUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 bannedDelegatorsUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 isValidatorBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 validatorCounter - "0x000000000000000000000000000000000000000000000000000000000000004b", - # 7 banCounter - "0x0000000000000000000000000000000000000000000000000000000000000000", - - # 1 areDelegatorsBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 banReason - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 bannedUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 bannedDelegatorsUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 isValidatorBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 validatorCounter - "0x000000000000000000000000000000000000000000000000000000000000004b", - # 7 banCounter - "0x0000000000000000000000000000000000000000000000000000000000000000", - - # 1 areDelegatorsBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 banReason - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 bannedUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 bannedDelegatorsUntil - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 isValidatorBanned - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 validatorCounter - "0x000000000000000000000000000000000000000000000000000000000000004b", - # 7 banCounter - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} - end - ) - - expect( - EthereumJSONRPC.Mox, - :json_rpc, - fn requests, _opts -> - assert length(requests) == 50 - - {:ok, - format_responses([ - # 1 maxWithdrawOrderAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 maxWithdrawAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 orderedWithdrawAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 orderWithdrawEpoch - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", - - # 1 maxWithdrawOrderAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 maxWithdrawAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 orderedWithdrawAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 orderWithdrawEpoch - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", - - # 1 maxWithdrawOrderAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 maxWithdrawAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 orderedWithdrawAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 orderWithdrawEpoch - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", - - # 1 maxWithdrawOrderAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 maxWithdrawAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 orderedWithdrawAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 orderWithdrawEpoch - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", - - # 1 maxWithdrawOrderAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 maxWithdrawAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 orderedWithdrawAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 orderWithdrawEpoch - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", - - # 1 maxWithdrawOrderAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 maxWithdrawAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 orderedWithdrawAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 orderWithdrawEpoch - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", - - # 1 maxWithdrawOrderAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 maxWithdrawAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 orderedWithdrawAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 orderWithdrawEpoch - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", - - # 1 maxWithdrawOrderAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 maxWithdrawAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 orderedWithdrawAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 orderWithdrawEpoch - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", - - # 1 maxWithdrawOrderAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 maxWithdrawAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 orderedWithdrawAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 orderWithdrawEpoch - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", - - # 1 maxWithdrawOrderAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 maxWithdrawAllowed - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 orderedWithdrawAmount - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 orderWithdrawEpoch - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 stakeAmount - "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" - ])} - end - ) - - expect( - EthereumJSONRPC.Mox, - :json_rpc, - fn requests, _opts -> - assert length(requests) == 7 - - {:ok, - format_responses([ - # 1 validatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 validatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 validatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 validatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 validatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 validatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 7 validatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} - end - ) - - expect( - EthereumJSONRPC.Mox, - :json_rpc, - fn requests, _opts -> - assert length(requests) == 10 - - {:ok, - format_responses([ - # 1 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 4 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 5 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 6 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 7 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 8 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 9 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 10 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} + format_responses([ + # BlockRewardAuRa.validatorMinRewardPercent + "0x000000000000000000000000000000000000000000000000000000000000001e" + ])} + end + ) + + # get_validators + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 2 + + {:ok, + format_responses([ + # ValidatorSetAuRa.getPendingValidators + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000bbcaa8d48289bb1ffcf9808d9aa4b1d215054c78000000000000000000000000f67cc5231c5858ad6cc87b105217426e17b824bb000000000000000000000000be69eb0968226a1808975e1a1f2127667f2bffb3000000000000000000000000720e118ab1006cc97ed2ef6b4b49ac04bb3aa6d9", + # ValidatorSetAuRa.validatorsToBeFinalized + "0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + ])} + end + ) + + # get_mining_to_staking_address + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 6 + + {:ok, + format_responses([ + # 1 ValidatorSetAuRa.stakingByMiningAddress + "0x0000000000000000000000000b2f5e2f3cbd864eaa2c642e3769c1582361caf6", + # 2 ValidatorSetAuRa.stakingByMiningAddress + "0x000000000000000000000000aa94b687d3f9552a453b81b2834ca53778980dc0", + # 3 ValidatorSetAuRa.stakingByMiningAddress + "0x000000000000000000000000312c230e7d6db05224f60208a656e3541c5c42ba", + # 4 ValidatorSetAuRa.stakingByMiningAddress + "0x000000000000000000000000b916e7e1f4bcb13549602ed042d36746fd0d96c9", + # 5 ValidatorSetAuRa.stakingByMiningAddress + "0x000000000000000000000000db9cb2478d917719c53862008672166808258577", + # 6 ValidatorSetAuRa.stakingByMiningAddress + "0x000000000000000000000000b6695f5c2e3f5eff8036b5f5f3a9d83a5310e51e" + ])} + end + ) + + # get_responses, ContractReader.pool_staking_requests + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 6*7 + + {:ok, + format_responses([ + # 1.1 StakingAuRa.poolDelegators + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + # 1.2 StakingAuRa.poolDelegatorsInactive + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + # 1.3 StakingAuRa.isPoolActive + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.4 ValidatorSetAuRa.miningByStakingAddress + "0x000000000000000000000000522df396ae70a058bd69778408630fdb023389b2", + # 1.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.6 StakingAuRa.stakeAmountTotal + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.7 BlockRewardAuRa.validatorRewardPercent + "0x0000000000000000000000000000000000000000000000000000000000000000", + + # 2.1 StakingAuRa.poolDelegators + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000d788829c11f61972c6c43ff6a7aaef4b154006ba", + # 2.2 StakingAuRa.poolDelegatorsInactive + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + # 2.3 StakingAuRa.isPoolActive + "0x0000000000000000000000000000000000000000000000000000000000000001", + # 2.4 ValidatorSetAuRa.miningByStakingAddress + "0x000000000000000000000000720e118ab1006cc97ed2ef6b4b49ac04bb3aa6d9", + # 2.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", + # 2.6 StakingAuRa.stakeAmountTotal + "0x00000000000000000000000000000000000000000000000029a2241af62c0000", + # 2.7 BlockRewardAuRa.validatorRewardPercent + "0x00000000000000000000000000000000000000000000000000000000000a2c2a", + + # 3.1 StakingAuRa.poolDelegators + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + # 3.2 StakingAuRa.poolDelegatorsInactive + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + # 3.3 StakingAuRa.isPoolActive + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.4 ValidatorSetAuRa.miningByStakingAddress + "0x00000000000000000000000075df42383afe6bf5194aa8fa0e9b3d5f9e869441", + # 3.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.6 StakingAuRa.stakeAmountTotal + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.7 BlockRewardAuRa.validatorRewardPercent + "0x0000000000000000000000000000000000000000000000000000000000000000", + + # 4.1 StakingAuRa.poolDelegators + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + # 4.2 StakingAuRa.poolDelegatorsInactive + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + # 4.3 StakingAuRa.isPoolActive + "0x0000000000000000000000000000000000000000000000000000000000000001", + # 4.4 ValidatorSetAuRa.miningByStakingAddress + "0x000000000000000000000000bbcaa8d48289bb1ffcf9808d9aa4b1d215054c78", + # 4.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4.6 StakingAuRa.stakeAmountTotal + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4.7 BlockRewardAuRa.validatorRewardPercent + "0x0000000000000000000000000000000000000000000000000000000000000000", + + # 5.1 StakingAuRa.poolDelegators + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000009000000000000000000000000d5bd381ffd0aba13265a7489f4a141d0ece91054000000000000000000000000682271d71c0412adb8ad7cd027a46da18f220315000000000000000000000000aa6a2866891a5c9046b06abb638bb8030e332724000000000000000000000000e90b1459d82917f1727b656756181b39f807044200000000000000000000000000898d801f6a565503f4df66ecb38292a9744828000000000000000000000000c69fe675984232f239cdfd3a35ad234b2b24988a000000000000000000000000fe9739a22165d48acae6b2385bfe0e43f3ea983000000000000000000000000044c331d263b5e319f34903adfd1621787fda381e000000000000000000000000629c7e8be1b2e0d40850689401ca59ea1769a08e", + # 5.2 StakingAuRa.poolDelegatorsInactive + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + # 5.3 StakingAuRa.isPoolActive + "0x0000000000000000000000000000000000000000000000000000000000000001", + # 5.4 ValidatorSetAuRa.miningByStakingAddress + "0x000000000000000000000000be69eb0968226a1808975e1a1f2127667f2bffb3", + # 5.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", + # 5.6 StakingAuRa.stakeAmountTotal + "0x00000000000000000000000000000000000000000000000098a7d9b8314c0000", + # 5.7 BlockRewardAuRa.validatorRewardPercent + "0x00000000000000000000000000000000000000000000000000000000000493e0", + + # 6.1 StakingAuRa.poolDelegators + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + # 6.2 StakingAuRa.poolDelegatorsInactive + "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", + # 6.3 StakingAuRa.isPoolActive + "0x0000000000000000000000000000000000000000000000000000000000000001", + # 6.4 ValidatorSetAuRa.miningByStakingAddress + "0x000000000000000000000000f67cc5231c5858ad6cc87b105217426e17b824bb", + # 6.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", + # 6.6 StakingAuRa.stakeAmountTotal + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", + # 6.7 BlockRewardAuRa.validatorRewardPercent + "0x00000000000000000000000000000000000000000000000000000000000f4240" + ])} + end + ) + + # get_responses, ContractReader.pool_mining_requests + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 6*7 + + {:ok, + format_responses([ + # 1.1 ValidatorSetAuRa.areDelegatorsBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.2 ValidatorSetAuRa.banReason + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.3 ValidatorSetAuRa.bannedUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.4 ValidatorSetAuRa.bannedDelegatorsUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.5 ValidatorSetAuRa.isValidatorBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.6 ValidatorSetAuRa.validatorCounter + "0x0000000000000000000000000000000000000000000000000000000000000001", + # 1.7 ValidatorSetAuRa.banCounter + "0x0000000000000000000000000000000000000000000000000000000000000000", + + # 2.1 ValidatorSetAuRa.areDelegatorsBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2.2 ValidatorSetAuRa.banReason + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2.3 ValidatorSetAuRa.bannedUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2.4 ValidatorSetAuRa.bannedDelegatorsUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2.5 ValidatorSetAuRa.isValidatorBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2.6 ValidatorSetAuRa.validatorCounter + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2.7 ValidatorSetAuRa.banCounter + "0x0000000000000000000000000000000000000000000000000000000000000000", + + # 3.1 ValidatorSetAuRa.areDelegatorsBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.2 ValidatorSetAuRa.banReason + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.3 ValidatorSetAuRa.bannedUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.4 ValidatorSetAuRa.bannedDelegatorsUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.5 ValidatorSetAuRa.isValidatorBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.6 ValidatorSetAuRa.validatorCounter + "0x0000000000000000000000000000000000000000000000000000000000000001", + # 3.7 ValidatorSetAuRa.banCounter + "0x0000000000000000000000000000000000000000000000000000000000000000", + + # 4.1 ValidatorSetAuRa.areDelegatorsBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4.2 ValidatorSetAuRa.banReason + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4.3 ValidatorSetAuRa.bannedUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4.4 ValidatorSetAuRa.bannedDelegatorsUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4.5 ValidatorSetAuRa.isValidatorBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4.6 ValidatorSetAuRa.validatorCounter + "0x0000000000000000000000000000000000000000000000000000000000000001", + # 4.7 ValidatorSetAuRa.banCounter + "0x0000000000000000000000000000000000000000000000000000000000000000", + + # 5.1 ValidatorSetAuRa.areDelegatorsBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 5.2 ValidatorSetAuRa.banReason + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 5.3 ValidatorSetAuRa.bannedUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 5.4 ValidatorSetAuRa.bannedDelegatorsUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 5.5 ValidatorSetAuRa.isValidatorBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 5.6 ValidatorSetAuRa.validatorCounter + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 5.7 ValidatorSetAuRa.banCounter + "0x0000000000000000000000000000000000000000000000000000000000000000", + + # 6.1 ValidatorSetAuRa.areDelegatorsBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 6.2 ValidatorSetAuRa.banReason + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 6.3 ValidatorSetAuRa.bannedUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 6.4 ValidatorSetAuRa.bannedDelegatorsUntil + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 6.5 ValidatorSetAuRa.isValidatorBanned + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 6.6 ValidatorSetAuRa.validatorCounter + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 6.7 ValidatorSetAuRa.banCounter + "0x0000000000000000000000000000000000000000000000000000000000000000" + ])} + end + ) + + # get_responses, ContractReader.staker_requests + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 16*5 + + {:ok, + format_responses([ + # 1.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 1.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + + # 2.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + + # 3.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + + # 4.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", + + # 5.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 5.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 5.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 5.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 5.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + + # 6.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 6.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 6.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 6.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 6.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", + + # 7.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 7.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 7.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 7.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 7.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", + + # 8.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 8.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 8.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 8.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 8.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + + # 9.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 9.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 9.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 9.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 9.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + + # 10.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 10.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 10.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 10.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 10.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + + # 11.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 11.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 11.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 11.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 11.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + + # 12.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 12.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 12.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 12.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 12.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + + # 13.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 13.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 13.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 13.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 13.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + + # 14.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 14.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 14.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 14.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 14.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + + # 15.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 15.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 15.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 15.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 15.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", + + # 16.1 StakingAuRa.maxWithdrawOrderAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 16.2 StakingAuRa.maxWithdrawAllowed + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 16.3 StakingAuRa.orderedWithdrawAmount + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 16.4 StakingAuRa.orderWithdrawEpoch + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 16.5 StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + ])} end ) + # get_candidate_reward_responses + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 6 + + {:ok, + format_responses([ + # 1 BlockRewardAuRa.validatorShare + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2 BlockRewardAuRa.validatorShare + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3 BlockRewardAuRa.validatorShare + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4 BlockRewardAuRa.validatorShare + "0x00000000000000000000000000000000000000000000000000000000000a2c2a", + # 5 BlockRewardAuRa.validatorShare + "0x00000000000000000000000000000000000000000000000000000000000f4240", + # 6 BlockRewardAuRa.validatorShare + "0x00000000000000000000000000000000000000000000000000000000000493e0" + ])} + end + ) + + # get_delegator_reward_responses + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 16 + + {:ok, + format_responses([ + # 1 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 2 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 3 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000000000", + # 4 BlockRewardAuRa.delegatorShare + "0x00000000000000000000000000000000000000000000000000000000000a2c2a", + # 5 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000051615", + # 6 BlockRewardAuRa.delegatorShare + "0x00000000000000000000000000000000000000000000000000000000000f4240", + # 7 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # 8 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # 9 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # 10 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # 11 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # 12 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # 13 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # 14 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000025fa3", + # 15 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # 16 BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1" + ])} + end + ) + + # invoke at_start_snapshotting() + + ## BalanceReader.get_balances_of expect( EthereumJSONRPC.Mox, :json_rpc, @@ -583,13 +664,14 @@ defmodule Explorer.Staking.ContractStateTest do assert length(requests) == 1 {:ok, - format_responses([ - # 1 balanceOf - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} + format_responses([ + # ERC677BridgeTokenRewardable.balanceOf(BlockRewardAuRa) + "0x0000000000000000000000000000000000000000000000000000000000000000" + ])} end ) + ## MetadataRetriever.get_functions_of expect( EthereumJSONRPC.Mox, :json_rpc, @@ -597,73 +679,195 @@ defmodule Explorer.Staking.ContractStateTest do assert length(requests) == 4 {:ok, - format_responses([ - # 1 decimals - "0x0000000000000000000000000000000000000000000000000000000000000012", - # 2 name - "0x7465737400000000000000000000000000000000000000000000000000000000", - # 3 symbol - "0x5453540000000000000000000000000000000000000000000000000000000000", - # 4 totalSupply - "0x00000000000000000000000000000000000000000000000000000000000f4240" - ])} + format_responses([ + # ERC677BridgeTokenRewardable.decimals + "0x0000000000000000000000000000000000000000000000000000000000000012", + # ERC677BridgeTokenRewardable.name + "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000055354414b45000000000000000000000000000000000000000000000000000000", + # ERC677BridgeTokenRewardable.symbol + "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000055354414b45000000000000000000000000000000000000000000000000000000", + # ERC677BridgeTokenRewardable.totalSupply + "0x000000000000000000000000000000000000000000000001f399b1438a100000" + ])} + end + ) + + # invoke do_snapshotting() + + ## 1 snapshotted_pool_amounts_requests + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 2 + + {:ok, + format_responses([ + # StakingAuRa.stakeAmountTotal + "0x0000000000000000000000000000000000000000000000000000000000000000", + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000000000000000000" + ])} + end + ) + + ## 2 snapshotted_pool_amounts_requests + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 2 + + {:ok, + format_responses([ + # StakingAuRa.stakeAmountTotal + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000", + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000" + ])} + end + ) + + ## 3 snapshotted_pool_amounts_requests + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 2 + + {:ok, + format_responses([ + # StakingAuRa.stakeAmountTotal + "0x00000000000000000000000000000000000000000000000098a7d9b8314c0000", + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000" + ])} + end + ) + + ## 4 snapshotted_pool_amounts_requests + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 2 + + {:ok, + format_responses([ + # StakingAuRa.stakeAmountTotal + "0x00000000000000000000000000000000000000000000000029a2241af62c0000", + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000" + ])} + end + ) + + ## 1 snapshotted_staker_amount_request + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 1 + + {:ok, + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000000000000000000" + ])} + end + ) + + ## 2 snapshotted_staker_amount_request + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 1 + + {:ok, + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000" + ])} + end + ) + + ## 3 snapshotted_staker_amount_request + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 1 + + {:ok, + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + ])} + end + ) + + ## 4 snapshotted_staker_amount_request + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 1 + + {:ok, + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000" + ])} end ) + ## 5 snapshotted_staker_amount_request expect( EthereumJSONRPC.Mox, :json_rpc, fn requests, _opts -> - assert length(requests) == 3 + assert length(requests) == 1 {:ok, - format_responses([ - # 1 poolDelegators - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 2 stakeAmountTotal - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 stakeAmount - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000001bc16d674ec80000" + ])} end ) + ## 6 snapshotted_staker_amount_request expect( EthereumJSONRPC.Mox, :json_rpc, fn requests, _opts -> - assert length(requests) == 3 + assert length(requests) == 1 {:ok, - format_responses([ - # 1 poolDelegators - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 2 stakeAmountTotal - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 stakeAmount - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + ])} end ) + ## 7 snapshotted_staker_amount_request expect( EthereumJSONRPC.Mox, :json_rpc, fn requests, _opts -> - assert length(requests) == 3 + assert length(requests) == 1 {:ok, - format_responses([ - # 1 poolDelegators - "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000", - # 2 stakeAmountTotal - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 stakeAmount - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + ])} end ) + ## 8 snapshotted_staker_amount_request expect( EthereumJSONRPC.Mox, :json_rpc, @@ -671,13 +875,14 @@ defmodule Explorer.Staking.ContractStateTest do assert length(requests) == 1 {:ok, - format_responses([ - # 1 stakeAmount - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + ])} end ) + ## 9 snapshotted_staker_amount_request expect( EthereumJSONRPC.Mox, :json_rpc, @@ -685,13 +890,14 @@ defmodule Explorer.Staking.ContractStateTest do assert length(requests) == 1 {:ok, - format_responses([ - # 1 stakeAmount - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + ])} end ) + ## 10 snapshotted_staker_amount_request expect( EthereumJSONRPC.Mox, :json_rpc, @@ -699,46 +905,132 @@ defmodule Explorer.Staking.ContractStateTest do assert length(requests) == 1 {:ok, - format_responses([ - # 1 stakeAmount - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + ])} end ) + ## 11 snapshotted_staker_amount_request expect( EthereumJSONRPC.Mox, :json_rpc, fn requests, _opts -> - assert length(requests) == 3 + assert length(requests) == 1 {:ok, - format_responses([ - # 1 validatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 validatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 validatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + ])} end ) + ## 12 snapshotted_staker_amount_request expect( EthereumJSONRPC.Mox, :json_rpc, fn requests, _opts -> - assert length(requests) == 3 + assert length(requests) == 1 + + {:ok, + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + ])} + end + ) + + ## 13 snapshotted_staker_amount_request + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 1 + + {:ok, + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + ])} + end + ) + + ## 14 snapshotted_staker_amount_request + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 1 + + {:ok, + format_responses([ + # StakingAuRa.stakeAmount + "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000" + ])} + end + ) + + ## ContractReader.validator_reward_request + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 4 + + {:ok, + format_responses([ + # BlockRewardAuRa.validatorShare + "0x0000000000000000000000000000000000000000000000000000000000000000", + # BlockRewardAuRa.validatorShare + "0x00000000000000000000000000000000000000000000000000000000000a2c2a", + # BlockRewardAuRa.validatorShare + "0x00000000000000000000000000000000000000000000000000000000000f4240", + # BlockRewardAuRa.validatorShare + "0x00000000000000000000000000000000000000000000000000000000000493e0" + ])} + end + ) + + ## ContractReader.delegator_reward_request + expect( + EthereumJSONRPC.Mox, + :json_rpc, + fn requests, _opts -> + assert length(requests) == 14 {:ok, - format_responses([ - # 1 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 2 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000", - # 3 delegatorShare - "0x0000000000000000000000000000000000000000000000000000000000000000" - ])} + format_responses([ + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000000000", + # BlockRewardAuRa.delegatorShare + "0x00000000000000000000000000000000000000000000000000000000000a2c2a", + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000051615", + # BlockRewardAuRa.delegatorShare + "0x00000000000000000000000000000000000000000000000000000000000f4240", + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000025fa3", + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1", + # BlockRewardAuRa.delegatorShare + "0x0000000000000000000000000000000000000000000000000000000000012fd1" + ])} end ) end