From a06c2e40a10f7582ee9d85cbe5788a51d2d670e4 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Tue, 1 Oct 2024 22:09:14 -0300 Subject: [PATCH] add missing queries --- go.sum | 2 - localnet/clear.py | 2 +- localnet/delegate.py | 6 +- localnet/initialize_rewards.py | 20 +- localnet/readme.md | 8 +- localnet/run_auction.py | 20 +- localnet/run_incentivized.py | 8 +- localnet/run_sale.py | 20 +- localnet/start_spn.py | 8 +- localnet/start_testnet.py | 14 +- localnet/undelegate.py | 6 +- localnet/utils.py | 12 +- pkg/types/consensus_state.go | 2 +- pkg/types/consensus_state_test.go | 4 +- pkg/types/signature_counts.go | 2 +- pkg/types/validator_set.go | 2 +- pkg/types/validator_set_test.go | 2 +- x/launch/keeper/query_genesis_account_test.go | 4 - .../keeper/query_genesis_validator_test.go | 4 - x/launch/keeper/query_param_change_test.go | 4 - x/launch/keeper/query_vesting_account_test.go | 4 - .../keeper/msg_server_create_client_test.go | 38 +-- .../query_launch_id_from_channel_id_test.go | 3 - .../keeper/query_monitoring_history_test.go | 4 - .../keeper/query_provider_client_id_test.go | 4 - .../keeper/query_verified_client_id_test.go | 4 - x/monitoringp/types/params.go | 2 +- .../query_auction_used_allocations_test.go | 3 - .../keeper/query_available_allocations.go | 7 +- .../query_available_allocations_test.go | 72 ++++++ .../keeper/query_total_allocations.go | 7 +- .../keeper/query_total_allocations_test.go | 72 ++++++ .../keeper/query_used_allocations_test.go | 3 - x/profile/keeper/query_validator_test.go | 3 - x/profile/types/message_validator_test.go | 6 +- .../keeper/msg_server_burn_vouchers_test.go | 4 +- .../keeper/msg_server_mint_vouchers_test.go | 4 +- .../keeper/msg_server_redeem_vouchers_test.go | 4 +- .../keeper/query_mainnet_account_balance.go | 80 +++++- .../query_mainnet_account_balance_test.go | 240 ++++++++++++++++++ .../keeper/query_mainnet_account_test.go | 7 +- x/project/keeper/query_project_chains_test.go | 4 - .../query_special_allocations_balance.go | 32 ++- .../query_special_allocations_balance_test.go | 95 +++++++ x/project/keeper/query_total_shares.go | 7 +- x/project/keeper/query_total_shares_test.go | 50 ++++ x/project/simulation/helpers_test.go | 4 +- x/reward/keeper/query_reward_pool_test.go | 4 - x/reward/keeper/reward_distribution_test.go | 4 +- 49 files changed, 752 insertions(+), 169 deletions(-) create mode 100644 x/participation/keeper/query_available_allocations_test.go create mode 100644 x/participation/keeper/query_total_allocations_test.go create mode 100644 x/project/keeper/query_mainnet_account_balance_test.go create mode 100644 x/project/keeper/query_special_allocations_balance_test.go create mode 100644 x/project/keeper/query_total_shares_test.go diff --git a/go.sum b/go.sum index 03d35d5f..6b978b8d 100644 --- a/go.sum +++ b/go.sum @@ -923,8 +923,6 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= -github.com/ignite/modules v0.0.3-0.20241001010553-074d16791470 h1:hQyV9fCgRKSRqixQLI30IJd8BW93ML9j96kYmClYeXY= -github.com/ignite/modules v0.0.3-0.20241001010553-074d16791470/go.mod h1:dUUmof5pdx14d7YGRByjzErnaTSHYCFd1Doz+sPIjhs= github.com/ignite/modules v0.0.3-0.20241001010902-46071e4a67ad h1:55iaGD5dHzkr7/VOXz5EncTMDgNw+1zZYSK6SxdFGSI= github.com/ignite/modules v0.0.3-0.20241001010902-46071e4a67ad/go.mod h1:dUUmof5pdx14d7YGRByjzErnaTSHYCFd1Doz+sPIjhs= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= diff --git a/localnet/clear.py b/localnet/clear.py index c71e9add..20cb346d 100644 --- a/localnet/clear.py +++ b/localnet/clear.py @@ -10,7 +10,7 @@ def clear_home(home): os.system('rm {}/node{}/config/write-file-atomic-*'.format(home, i)) os.system('rm {}/node{}/config/genesis.json'.format(home, i)) os.system("rm {}/node{}/config/addrbook.json".format(home, i)) - os.system('spnd tendermint unsafe-reset-all --home {}/node{}'.format(home, i)) + os.system('networkd tendermint unsafe-reset-all --home {}/node{}'.format(home, i)) if __name__ == "__main__": clear_home('spn') diff --git a/localnet/delegate.py b/localnet/delegate.py index 1e7e2267..a47c09f0 100644 --- a/localnet/delegate.py +++ b/localnet/delegate.py @@ -11,7 +11,7 @@ conf = yaml.safe_load(confFile) def delegate_cmd(valNumber, amount): - cmd = ["spnd", "tx", "staking", "delegate"] + cmd = ["networkd", "tx", "staking", "delegate"] cmd.append(conf['validator_addresses'][valNumber]) stake = amount + conf['staking_denom'] @@ -47,7 +47,7 @@ def delegate(amounts): print() print('delegation performed, to show validator set:') - print('spnd q tendermint-validator-set') + print('networkd q tendermint-validator-set') print() print('to show consensus state') - print('spnd q ibc client self-consensus-state') \ No newline at end of file + print('networkd q ibc client self-consensus-state') \ No newline at end of file diff --git a/localnet/initialize_rewards.py b/localnet/initialize_rewards.py index 98a876df..5ff26406 100644 --- a/localnet/initialize_rewards.py +++ b/localnet/initialize_rewards.py @@ -21,11 +21,11 @@ ) def initialize_rewards(lastBlockHeight, selfDelegationVal1, selfDelegationVal2, selfDelegationVal3): - cmd_devnull('spnd tx profile create-coordinator --from alice -y') - cmd_devnull('spnd tx launch create-chain orbit-1 orbit.com 0xaaa --from alice -y') - cmd_devnull('spnd tx project create-project orbit 1000000orbit --from alice -y') - cmd_devnull('spnd tx project mint-vouchers 1 50000orbit --from alice -y') - cmd_devnull('spnd tx reward set-rewards 1 50000v/1/orbit {} --from alice -y'.format(lastBlockHeight)) + cmd_devnull('networkd tx profile create-coordinator --from alice -y') + cmd_devnull('networkd tx launch create-chain orbit-1 orbit.com 0xaaa --from alice -y') + cmd_devnull('networkd tx project create-project orbit 1000000orbit --from alice -y') + cmd_devnull('networkd tx project mint-vouchers 1 50000orbit --from alice -y') + cmd_devnull('networkd tx reward set-rewards 1 50000v/1/orbit {} --from alice -y'.format(lastBlockHeight)) gentx1 = './testnet/node1/config/gentx/gentx.json' gentx2 = './testnet/node2/config/gentx/gentx.json' @@ -37,14 +37,14 @@ def initialize_rewards(lastBlockHeight, selfDelegationVal1, selfDelegationVal2, val2 = 'spn1pkdk6m2nh77nlaep84cylmkhjder3arey7rll5' val3 = 'spn1twckcceyw43da9j247pfs3yhqsv25j38grh68q' - cmd_devnull('spnd tx launch request-add-validator 1 {} {} {} aaa foo.com --validator-address {} --from alice -y'.format(gentx1, pub1, selfDelegationVal1, val1)), - cmd_devnull('spnd tx launch request-add-validator 1 {} {} {} aaa foo.com --validator-address {} --from alice -y'.format(gentx2, pub2, selfDelegationVal2, val2)), - cmd_devnull('spnd tx launch request-add-validator 1 {} {} {} aaa foo.com --validator-address {} --from alice -y'.format(gentx3, pub3, selfDelegationVal3, val3)), + cmd_devnull('networkd tx launch request-add-validator 1 {} {} {} aaa foo.com --validator-address {} --from alice -y'.format(gentx1, pub1, selfDelegationVal1, val1)), + cmd_devnull('networkd tx launch request-add-validator 1 {} {} {} aaa foo.com --validator-address {} --from alice -y'.format(gentx2, pub2, selfDelegationVal2, val2)), + cmd_devnull('networkd tx launch request-add-validator 1 {} {} {} aaa foo.com --validator-address {} --from alice -y'.format(gentx3, pub3, selfDelegationVal3, val3)), # Uncomment for testing incomplete validator set - # cmd_devnull('spnd tx launch request-add-validator 1 ./node3/config/gentx/gentx.json "FyTmyvZhwRjwqhY6eWykTfiE+0mwe+U0aSo3ti8DCW8=" 16000000stake aaa foo.com --validator-address spn1ezptsm3npn54qx9vvpah4nymre59ykr9exx2ul --from alice -y') + # cmd_devnull('networkd tx launch request-add-validator 1 ./node3/config/gentx/gentx.json "FyTmyvZhwRjwqhY6eWykTfiE+0mwe+U0aSo3ti8DCW8=" 16000000stake aaa foo.com --validator-address spn1ezptsm3npn54qx9vvpah4nymre59ykr9exx2ul --from alice -y') - cmd_devnull('spnd tx launch trigger-launch 1 5 --from alice -y') + cmd_devnull('networkd tx launch trigger-launch 1 5 --from alice -y') if __name__ == "__main__": diff --git a/localnet/readme.md b/localnet/readme.md index aaeb5d7a..cbb24eb6 100644 --- a/localnet/readme.md +++ b/localnet/readme.md @@ -24,7 +24,7 @@ p2p: 26654 ### Starting the Localnet -Before running any scripts, `spnd` must be built for the current branch +Before running any scripts, `networkd` must be built for the current branch ``` ignite chain build ``` @@ -63,7 +63,7 @@ python3 start_spn.py Show the validator set ``` -spnd q tendermint-validator-set +networkd q tendermint-validator-set block_height: "3" total: "3" validators: @@ -94,7 +94,7 @@ python3 delegate.py 10000000 0 0 Validator 1 has now more voting power ``` -spnd q tendermint-validator-set +networkd q tendermint-validator-set block_height: "21" total: "3" validators: @@ -125,7 +125,7 @@ python3 undelegate.py 10000000 0 0 Validator 1 voting power is decreased back ``` -spnd q tendermint-validator-set +networkd q tendermint-validator-set block_height: "67" total: "3" validators: diff --git a/localnet/run_auction.py b/localnet/run_auction.py index 25931285..a7a4097f 100644 --- a/localnet/run_auction.py +++ b/localnet/run_auction.py @@ -30,25 +30,25 @@ def set_auction_json(selling_denom, selling_amount, paying_denom, start_price, m # Fundraising set_auction_json('v/1/orbit', '50000', 'uspn', '100', '50', date_f(start), date_f(end)) - cmd('spnd tx fundraising create-batch-auction {} --from alice -y'.format(auction_file)) + cmd('networkd tx fundraising create-batch-auction {} --from alice -y'.format(auction_file)) os.remove(auction_file) - cmd_devnull('spnd tx participation participate 1 4 --from bob -y') - cmd_devnull('spnd tx participation participate 1 4 --from carol -y') - cmd_devnull('spnd tx participation participate 1 4 --from dave -y') + cmd_devnull('networkd tx participation participate 1 4 --from bob -y') + cmd_devnull('networkd tx participation participate 1 4 --from carol -y') + cmd_devnull('networkd tx participation participate 1 4 --from dave -y') # Wait auction start print("waiting for auction start...") time.sleep(15) # Place bid - cmd('spnd tx fundraising bid 1 batch-many 120 10000v/1/orbit --from bob -y') - cmd('spnd tx fundraising bid 1 batch-many 80 20000v/1/orbit --from carol -y') - cmd('spnd tx fundraising bid 1 batch-many 140 20000v/1/orbit --from dave -y') + cmd('networkd tx fundraising bid 1 batch-many 120 10000v/1/orbit --from bob -y') + cmd('networkd tx fundraising bid 1 batch-many 80 20000v/1/orbit --from carol -y') + cmd('networkd tx fundraising bid 1 batch-many 140 20000v/1/orbit --from dave -y') # Wait withdrawal delay print("waiting for withdrawal delay...") time.sleep(5) - cmd_devnull('spnd tx participation withdraw-allocations 1 --from bob -y') - cmd_devnull('spnd tx participation withdraw-allocations 1 --from carol -y') - cmd_devnull('spnd tx participation withdraw-allocations 1 --from dave -y') \ No newline at end of file + cmd_devnull('networkd tx participation withdraw-allocations 1 --from bob -y') + cmd_devnull('networkd tx participation withdraw-allocations 1 --from carol -y') + cmd_devnull('networkd tx participation withdraw-allocations 1 --from dave -y') \ No newline at end of file diff --git a/localnet/run_incentivized.py b/localnet/run_incentivized.py index 4410f114..f0177669 100644 --- a/localnet/run_incentivized.py +++ b/localnet/run_incentivized.py @@ -73,7 +73,7 @@ ) print('rewards initialized') - cmd('spnd q ibc client self-consensus-state --height {} > spncs.yaml'.format(revisionHeight)) + cmd('networkd q ibc client self-consensus-state --height {} > spncs.yaml'.format(revisionHeight)) # Start the testnet print('start network') @@ -96,9 +96,9 @@ # Create verified IBC client on SPN print('create verified client') - cmd('spnd q tendermint-validator-set 2 --node "tcp://localhost:26659" > vs.yaml') - cmd('spnd q ibc client self-consensus-state --height 2 --node "tcp://localhost:26659" > cs.yaml') - cmd('spnd tx monitoring-consumer create-client 1 cs.yaml vs.yaml --unbonding-period {} --revision-height 2 --from alice -y'.format(unbondingTime)) + cmd('networkd q tendermint-validator-set 2 --node "tcp://localhost:26659" > vs.yaml') + cmd('networkd q ibc client self-consensus-state --height 2 --node "tcp://localhost:26659" > cs.yaml') + cmd('networkd tx monitoring-consumer create-client 1 cs.yaml vs.yaml --unbonding-period {} --revision-height 2 --from alice -y'.format(unbondingTime)) # Perform IBC connection cmd('hermes -c ./hermes/config.toml create connection spn-1 --client-a 07-tendermint-0 --client-b 07-tendermint-0') diff --git a/localnet/run_sale.py b/localnet/run_sale.py index aceb606f..d213103c 100644 --- a/localnet/run_sale.py +++ b/localnet/run_sale.py @@ -29,25 +29,25 @@ def set_sale_json(selling_denom, selling_amount, paying_denom, price, start_time # Fundraising set_sale_json('v/1/orbit', '50000', 'uspn', '100', date_f(start), date_f(end)) - cmd_devnull('spnd tx fundraising create-fixed-price-auction {} --from alice -y'.format(sale_file)) + cmd_devnull('networkd tx fundraising create-fixed-price-auction {} --from alice -y'.format(sale_file)) os.remove(sale_file) - cmd_devnull('spnd tx participation participate 1 4 --from bob -y') - cmd_devnull('spnd tx participation participate 1 4 --from carol -y') - cmd_devnull('spnd tx participation participate 1 4 --from dave -y') + cmd_devnull('networkd tx participation participate 1 4 --from bob -y') + cmd_devnull('networkd tx participation participate 1 4 --from carol -y') + cmd_devnull('networkd tx participation participate 1 4 --from dave -y') # Wait auction start print("waiting for auction start...") time.sleep(15) # Place bid - cmd('spnd tx fundraising bid 1 fixed-price 100 10000v/1/orbit --from bob -y') - cmd('spnd tx fundraising bid 1 fixed-price 100 20000v/1/orbit --from carol -y') - cmd('spnd tx fundraising bid 1 fixed-price 100 20000v/1/orbit --from dave -y') + cmd('networkd tx fundraising bid 1 fixed-price 100 10000v/1/orbit --from bob -y') + cmd('networkd tx fundraising bid 1 fixed-price 100 20000v/1/orbit --from carol -y') + cmd('networkd tx fundraising bid 1 fixed-price 100 20000v/1/orbit --from dave -y') # Wait withdrawal delay print("waiting for withdrawal delay...") time.sleep(5) - cmd_devnull('spnd tx participation withdraw-allocations 1 --from bob -y') - cmd_devnull('spnd tx participation withdraw-allocations 1 --from carol -y') - cmd_devnull('spnd tx participation withdraw-allocations 1 --from dave -y') \ No newline at end of file + cmd_devnull('networkd tx participation withdraw-allocations 1 --from bob -y') + cmd_devnull('networkd tx participation withdraw-allocations 1 --from carol -y') + cmd_devnull('networkd tx participation withdraw-allocations 1 --from dave -y') \ No newline at end of file diff --git a/localnet/start_spn.py b/localnet/start_spn.py index fba5c989..a94ba6d4 100644 --- a/localnet/start_spn.py +++ b/localnet/start_spn.py @@ -44,7 +44,7 @@ def start_spn(): # Create the gentxs for i in range(3): - gentxCmd = 'spnd gentx {valName} {selfDelegation} --chain-id {chainID} --moniker="{valName}" --home ./spn/node{i} --output-document ./gentx.json'.format( + gentxCmd = 'networkd gentx {valName} {selfDelegation} --chain-id {chainID} --moniker="{valName}" --home ./spn/node{i} --output-document ./gentx.json'.format( valName=conf['validator_names'][i], selfDelegation=str(conf['validator_self_delegations'][i])+conf['staking_denom'], chainID=conf['chain_id'], @@ -60,9 +60,9 @@ def start_spn(): save_genesis(genesis) print('Starting the network') - subprocess.Popen(["spnd", "start", "--home", "./spn/node2"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - subprocess.Popen(["spnd", "start", "--home", "./spn/node3"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - subprocess.run(["spnd start --home ./spn/node1"], shell=True, check=True) + subprocess.Popen(["networkd", "start", "--home", "./spn/node2"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.Popen(["networkd", "start", "--home", "./spn/node3"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.run(["networkd start --home ./spn/node1"], shell=True, check=True) if __name__ == "__main__": start_spn() \ No newline at end of file diff --git a/localnet/start_testnet.py b/localnet/start_testnet.py index 71a2aaa0..e746fff0 100644 --- a/localnet/start_testnet.py +++ b/localnet/start_testnet.py @@ -108,15 +108,15 @@ def start_testnet( genesis['app_state']['staking']['params']['unbonding_time'] = str(unbondingTime)+"s" # Create the gentxs - cmd_devnull('spnd gentx joe {} --chain-id {} --moniker="joe" --home ./testnet/node1 --output-document ./gentx1.json'.format(selfDelegationVal1, chainID)) + cmd_devnull('networkd gentx joe {} --chain-id {} --moniker="joe" --home ./testnet/node1 --output-document ./gentx1.json'.format(selfDelegationVal1, chainID)) gentx1File = open('./gentx1.json') gentx1 = json.load(gentx1File) - cmd_devnull('spnd gentx steve {} --chain-id {} --moniker="steve" --home ./testnet/node2 --output-document ./gentx2.json'.format(selfDelegationVal2, chainID)) + cmd_devnull('networkd gentx steve {} --chain-id {} --moniker="steve" --home ./testnet/node2 --output-document ./gentx2.json'.format(selfDelegationVal2, chainID)) gentx2File = open('./gentx2.json') gentx2 = json.load(gentx2File) - cmd_devnull('spnd gentx olivia {} --chain-id {} --moniker="olivia" --home ./testnet/node3 --output-document ./gentx3.json'.format(selfDelegationVal3, chainID)) + cmd_devnull('networkd gentx olivia {} --chain-id {} --moniker="olivia" --home ./testnet/node3 --output-document ./gentx3.json'.format(selfDelegationVal3, chainID)) gentx3File = open('./gentx3.json') gentx3 = json.load(gentx3File) @@ -133,12 +133,12 @@ def start_testnet( save_genesis(genesis) print('Starting the network') - subprocess.Popen(["spnd", "start", "--home", "./testnet/node2"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - subprocess.Popen(["spnd", "start", "--home", "./testnet/node3"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.Popen(["networkd", "start", "--home", "./testnet/node2"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.Popen(["networkd", "start", "--home", "./testnet/node3"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) if background: - subprocess.Popen(["spnd", "start", "--home", "./testnet/node1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.Popen(["networkd", "start", "--home", "./testnet/node1"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) else: - subprocess.run(["spnd start --home ./testnet/node1"], shell=True, check=True) + subprocess.run(["networkd start --home ./testnet/node1"], shell=True, check=True) if __name__ == "__main__": diff --git a/localnet/undelegate.py b/localnet/undelegate.py index 2470b8ca..c79d3a07 100644 --- a/localnet/undelegate.py +++ b/localnet/undelegate.py @@ -11,7 +11,7 @@ conf = yaml.safe_load(confFile) def undelegate_cmd(valNumber, amount): - cmd = ["spnd", "tx", "staking", "unbond"] + cmd = ["networkd", "tx", "staking", "unbond"] cmd.append(conf['validator_addresses'][valNumber]) stake = amount + conf['staking_denom'] @@ -48,7 +48,7 @@ def undelegate(amounts): print() print('unbonding performed, to show validator set:') - print('spnd q tendermint-validator-set') + print('networkd q tendermint-validator-set') print() print('to show consensus state') - print('spnd q ibc client self-consensus-state') \ No newline at end of file + print('networkd q ibc client self-consensus-state') \ No newline at end of file diff --git a/localnet/utils.py b/localnet/utils.py index 74f25090..ae45c152 100644 --- a/localnet/utils.py +++ b/localnet/utils.py @@ -12,9 +12,9 @@ def date_f(d): return d.isoformat("T") + "Z" def initialize_project(): - cmd_devnull('spnd tx staking delegate {} 100000uspn --from bob -y'.format(val_address)) - cmd_devnull('spnd tx staking delegate {} 100000uspn --from carol -y'.format(val_address)) - cmd_devnull('spnd tx staking delegate {} 100000uspn --from dave -y'.format(val_address)) - cmd_devnull('spnd tx profile create-coordinator --from alice -y') - cmd_devnull('spnd tx project create-project orbit 1000000orbit --from alice -y') - cmd_devnull('spnd tx project mint-vouchers 1 100000orbit --from alice -y') \ No newline at end of file + cmd_devnull('networkd tx staking delegate {} 100000uspn --from bob -y'.format(val_address)) + cmd_devnull('networkd tx staking delegate {} 100000uspn --from carol -y'.format(val_address)) + cmd_devnull('networkd tx staking delegate {} 100000uspn --from dave -y'.format(val_address)) + cmd_devnull('networkd tx profile create-coordinator --from alice -y') + cmd_devnull('networkd tx project create-project orbit 1000000orbit --from alice -y') + cmd_devnull('networkd tx project mint-vouchers 1 100000orbit --from alice -y') \ No newline at end of file diff --git a/pkg/types/consensus_state.go b/pkg/types/consensus_state.go index fd4483d0..3e362ff7 100644 --- a/pkg/types/consensus_state.go +++ b/pkg/types/consensus_state.go @@ -1,4 +1,4 @@ -// Package types defines types to handle IBC handshakes in SPN modules +// Package types defines types to handle IBC handshakes in Network modules package types import ( diff --git a/pkg/types/consensus_state_test.go b/pkg/types/consensus_state_test.go index c6608dd9..d3566eed 100644 --- a/pkg/types/consensus_state_test.go +++ b/pkg/types/consensus_state_test.go @@ -86,7 +86,7 @@ root: hash: 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= timestamp: "2022-01-12T07:56:35.394367Z" ` - f, err := os.CreateTemp("", "spn_consensus_state_test") + f, err := os.CreateTemp("", "network_consensus_state_test") require.NoError(t, err) t.Cleanup(func() { f.Close() @@ -109,7 +109,7 @@ timestamp: "2022-01-12T07:56:35.394367Z" t.Run("invalid file", func(t *testing.T) { consensusStateYAML := `foo` - f, err := os.CreateTemp("", "spn_consensus_state_test") + f, err := os.CreateTemp("", "network_consensus_state_test") require.NoError(t, err) t.Cleanup(func() { f.Close() diff --git a/pkg/types/signature_counts.go b/pkg/types/signature_counts.go index 7dc633a1..4fb72c1f 100644 --- a/pkg/types/signature_counts.go +++ b/pkg/types/signature_counts.go @@ -67,7 +67,7 @@ func (m SignatureCounts) Validate() error { return nil } -// GetOperatorAddress returns the operator address for the signer with the SPN prefix format +// GetOperatorAddress returns the operator address for the signer with the Network prefix format func (m SignatureCount) GetOperatorAddress(accountPrefix string) (string, error) { _, decoded, err := bech32.DecodeAndConvert(m.OpAddress) if err != nil { diff --git a/pkg/types/validator_set.go b/pkg/types/validator_set.go index cf4d2e03..33c28f5c 100644 --- a/pkg/types/validator_set.go +++ b/pkg/types/validator_set.go @@ -1,4 +1,4 @@ -// Package types defines types to handle IBC handshakes in SPN modules +// Package types defines types to handle IBC handshakes in Network modules package types import ( diff --git a/pkg/types/validator_set_test.go b/pkg/types/validator_set_test.go index c382dbf6..dacb46c9 100644 --- a/pkg/types/validator_set_test.go +++ b/pkg/types/validator_set_test.go @@ -13,7 +13,7 @@ import ( func TestParseValidatorSetFromFile(t *testing.T) { fileFromContent := func(content string) string { - f, err := os.CreateTemp("", "spn_validator_set_test") + f, err := os.CreateTemp("", "network_validator_set_test") require.NoError(t, err) t.Cleanup(func() { os.Remove(f.Name()) diff --git a/x/launch/keeper/query_genesis_account_test.go b/x/launch/keeper/query_genesis_account_test.go index b76aeded..41cf6d2c 100644 --- a/x/launch/keeper/query_genesis_account_test.go +++ b/x/launch/keeper/query_genesis_account_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "context" - "strconv" "testing" "cosmossdk.io/collections" @@ -18,9 +17,6 @@ import ( "github.com/ignite/network/x/launch/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNGenesisAccount(keeper keeper.Keeper, ctx context.Context, n int) []types.GenesisAccount { items := make([]types.GenesisAccount, n) for i := range items { diff --git a/x/launch/keeper/query_genesis_validator_test.go b/x/launch/keeper/query_genesis_validator_test.go index a447735a..702e9f95 100644 --- a/x/launch/keeper/query_genesis_validator_test.go +++ b/x/launch/keeper/query_genesis_validator_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "context" - "strconv" "testing" "cosmossdk.io/collections" @@ -18,9 +17,6 @@ import ( "github.com/ignite/network/x/launch/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNGenesisValidator(keeper keeper.Keeper, ctx context.Context, n int) []types.GenesisValidator { items := make([]types.GenesisValidator, n) for i := range items { diff --git a/x/launch/keeper/query_param_change_test.go b/x/launch/keeper/query_param_change_test.go index 96846c1d..7b89cb77 100644 --- a/x/launch/keeper/query_param_change_test.go +++ b/x/launch/keeper/query_param_change_test.go @@ -3,7 +3,6 @@ package keeper_test import ( "context" "fmt" - "strconv" "testing" "cosmossdk.io/collections" @@ -18,9 +17,6 @@ import ( "github.com/ignite/network/x/launch/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNParamChange(keeper keeper.Keeper, ctx context.Context, n int) []types.ParamChange { items := make([]types.ParamChange, n) launchID := uint64(0) diff --git a/x/launch/keeper/query_vesting_account_test.go b/x/launch/keeper/query_vesting_account_test.go index af1c5a0a..cc5da7bb 100644 --- a/x/launch/keeper/query_vesting_account_test.go +++ b/x/launch/keeper/query_vesting_account_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "context" - "strconv" "testing" "cosmossdk.io/collections" @@ -18,9 +17,6 @@ import ( "github.com/ignite/network/x/launch/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNVestingAccount(keeper keeper.Keeper, ctx context.Context, n int) []types.VestingAccount { items := make([]types.VestingAccount, n) for i := range items { diff --git a/x/monitoringc/keeper/msg_server_create_client_test.go b/x/monitoringc/keeper/msg_server_create_client_test.go index 8207425d..4d7caa2e 100644 --- a/x/monitoringc/keeper/msg_server_create_client_test.go +++ b/x/monitoringc/keeper/msg_server_create_client_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" ignterrors "github.com/ignite/network/pkg/errors" - spntypes "github.com/ignite/network/pkg/types" + networktypes "github.com/ignite/network/pkg/types" testkeeper "github.com/ignite/network/testutil/keeper" "github.com/ignite/network/testutil/sample" launchtypes "github.com/ignite/network/x/launch/types" @@ -26,13 +26,13 @@ func Test_msgServer_CreateClient(t *testing.T) { ctx, tk, ts = testkeeper.NewTestSetup(t) consPubKeyStr = "jP0v8F0e2kSAS367V/QAikddQPze+V36v7lhkv1Iqgg=" - cs = spntypes.NewConsensusState( + cs = networktypes.NewConsensusState( "2022-02-08T15:12:36.161481Z", "A13E761948413E405EA4F09BEC9F37632F739404108FE1635CB3529B61DA9FD7", "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", ) - vs = spntypes.NewValidatorSet( - spntypes.NewValidator(consPubKeyStr, 0, 100), + vs = networktypes.NewValidatorSet( + networktypes.NewValidator(consPubKeyStr, 0, 100), ) ) @@ -98,8 +98,8 @@ func Test_msgServer_CreateClient(t *testing.T) { chainWithInvalidChainID.LaunchID, cs, vs, - spntypes.DefaultUnbondingPeriod, - spntypes.DefaultRevisionHeight, + networktypes.DefaultUnbondingPeriod, + networktypes.DefaultRevisionHeight, ), err: types.ErrInvalidClientState, }, @@ -111,7 +111,7 @@ func Test_msgServer_CreateClient(t *testing.T) { cs, vs, 0, - spntypes.DefaultRevisionHeight, + networktypes.DefaultRevisionHeight, ), err: types.ErrInvalidClientState, }, @@ -120,14 +120,14 @@ func Test_msgServer_CreateClient(t *testing.T) { msg: *types.NewMsgCreateClient( sample.Address(r), resCreateChain.LaunchID, - spntypes.NewConsensusState( + networktypes.NewConsensusState( "", "", "", ), vs, - spntypes.DefaultUnbondingPeriod, - spntypes.DefaultRevisionHeight, + networktypes.DefaultUnbondingPeriod, + networktypes.DefaultRevisionHeight, ), err: ignterrors.ErrCritical, }, @@ -138,8 +138,8 @@ func Test_msgServer_CreateClient(t *testing.T) { invalidChain, cs, vs, - spntypes.DefaultUnbondingPeriod, - spntypes.DefaultRevisionHeight, + networktypes.DefaultUnbondingPeriod, + networktypes.DefaultRevisionHeight, ), err: launchtypes.ErrChainNotFound, }, @@ -149,9 +149,9 @@ func Test_msgServer_CreateClient(t *testing.T) { sample.Address(r), resCreateChain.LaunchID, sample.ConsensusState(0), - spntypes.ValidatorSet{}, - spntypes.DefaultUnbondingPeriod, - spntypes.DefaultRevisionHeight, + networktypes.ValidatorSet{}, + networktypes.DefaultUnbondingPeriod, + networktypes.DefaultRevisionHeight, ), err: ignterrors.ErrCritical, }, @@ -162,8 +162,8 @@ func Test_msgServer_CreateClient(t *testing.T) { resCreateChain.LaunchID, sample.ConsensusState(0), sample.ValidatorSet(1), - spntypes.DefaultUnbondingPeriod, - spntypes.DefaultRevisionHeight, + networktypes.DefaultUnbondingPeriod, + networktypes.DefaultRevisionHeight, ), err: types.ErrInvalidValidatorSet, }, @@ -174,8 +174,8 @@ func Test_msgServer_CreateClient(t *testing.T) { resCreateChain.LaunchID, cs, vs, - spntypes.DefaultUnbondingPeriod, - spntypes.DefaultRevisionHeight, + networktypes.DefaultUnbondingPeriod, + networktypes.DefaultRevisionHeight, ), }, } diff --git a/x/monitoringc/keeper/query_launch_id_from_channel_id_test.go b/x/monitoringc/keeper/query_launch_id_from_channel_id_test.go index 13748a8c..07500340 100644 --- a/x/monitoringc/keeper/query_launch_id_from_channel_id_test.go +++ b/x/monitoringc/keeper/query_launch_id_from_channel_id_test.go @@ -16,9 +16,6 @@ import ( "github.com/ignite/network/x/monitoringc/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNLaunchIDFromChannelID(keeper keeper.Keeper, ctx context.Context, n int) []types.LaunchIDFromChannelID { items := make([]types.LaunchIDFromChannelID, n) for i := range items { diff --git a/x/monitoringc/keeper/query_monitoring_history_test.go b/x/monitoringc/keeper/query_monitoring_history_test.go index a22d22cd..4908f77e 100644 --- a/x/monitoringc/keeper/query_monitoring_history_test.go +++ b/x/monitoringc/keeper/query_monitoring_history_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "context" - "strconv" "testing" "github.com/stretchr/testify/require" @@ -15,9 +14,6 @@ import ( "github.com/ignite/network/x/monitoringc/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNMonitoringHistory(keeper keeper.Keeper, ctx context.Context, n int) []types.MonitoringHistory { items := make([]types.MonitoringHistory, n) for i := range items { diff --git a/x/monitoringc/keeper/query_provider_client_id_test.go b/x/monitoringc/keeper/query_provider_client_id_test.go index 6e702c05..c0e2cfa5 100644 --- a/x/monitoringc/keeper/query_provider_client_id_test.go +++ b/x/monitoringc/keeper/query_provider_client_id_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "context" - "strconv" "testing" "github.com/cosmos/cosmos-sdk/types/query" @@ -16,9 +15,6 @@ import ( "github.com/ignite/network/x/monitoringc/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNProviderClientID(keeper keeper.Keeper, ctx context.Context, n int) []types.ProviderClientID { items := make([]types.ProviderClientID, n) for i := range items { diff --git a/x/monitoringc/keeper/query_verified_client_id_test.go b/x/monitoringc/keeper/query_verified_client_id_test.go index b0861b7f..fb33f86a 100644 --- a/x/monitoringc/keeper/query_verified_client_id_test.go +++ b/x/monitoringc/keeper/query_verified_client_id_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "context" - "strconv" "testing" "github.com/stretchr/testify/require" @@ -15,9 +14,6 @@ import ( "github.com/ignite/network/x/monitoringc/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNVerifiedClientID(keeper keeper.Keeper, ctx context.Context, n int) []types.VerifiedClientID { items := make([]types.VerifiedClientID, n) for i := range items { diff --git a/x/monitoringp/types/params.go b/x/monitoringp/types/params.go index 2d63e915..ea920f43 100644 --- a/x/monitoringp/types/params.go +++ b/x/monitoringp/types/params.go @@ -82,7 +82,7 @@ func validateConsumerConsensusState(i interface{}) error { } // perform the verification only if the Consumer Consensus State is defined - // TODO: remove this check and set an official SPN mainnet consensus state as default + // TODO: remove this check and set an official Network mainnet consensus state as default if ccs.Timestamp != "" { tmConsensusState, err := ccs.ToTendermintConsensusState() if err != nil { diff --git a/x/participation/keeper/query_auction_used_allocations_test.go b/x/participation/keeper/query_auction_used_allocations_test.go index 454c06ed..d276278e 100644 --- a/x/participation/keeper/query_auction_used_allocations_test.go +++ b/x/participation/keeper/query_auction_used_allocations_test.go @@ -18,9 +18,6 @@ import ( "github.com/ignite/network/x/participation/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNAuctionUsedAllocations(keeper keeper.Keeper, ctx context.Context, n int) []types.AuctionUsedAllocations { items := make([]types.AuctionUsedAllocations, n) auctionID := uint64(0) diff --git a/x/participation/keeper/query_available_allocations.go b/x/participation/keeper/query_available_allocations.go index 8eeadd92..e9297799 100644 --- a/x/participation/keeper/query_available_allocations.go +++ b/x/participation/keeper/query_available_allocations.go @@ -14,7 +14,10 @@ func (q queryServer) AvailableAllocations(ctx context.Context, req *types.QueryA return nil, status.Error(codes.InvalidArgument, "invalid request") } - // TODO: Process the query + availableAlloc, err := q.k.GetAvailableAllocations(ctx, req.Address) + if err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } - return &types.QueryAvailableAllocationsResponse{}, nil + return &types.QueryAvailableAllocationsResponse{AvailableAllocations: availableAlloc}, nil } diff --git a/x/participation/keeper/query_available_allocations_test.go b/x/participation/keeper/query_available_allocations_test.go new file mode 100644 index 00000000..7cf35d59 --- /dev/null +++ b/x/participation/keeper/query_available_allocations_test.go @@ -0,0 +1,72 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/ignite/network/testutil/keeper" + "github.com/ignite/network/testutil/nullify" + "github.com/ignite/network/testutil/sample" + "github.com/ignite/network/x/participation/keeper" + "github.com/ignite/network/x/participation/types" +) + +func TestShowAvailableAllocationsQuery(t *testing.T) { + ctx, tk, _ := keepertest.NewTestSetup(t) + qs := keeper.NewQueryServerImpl(tk.ParticipationKeeper) + + allocationPrice := types.AllocationPrice{Bonded: sdkmath.NewInt(100)} + params := types.DefaultParams() + params.AllocationPrice = allocationPrice + err := tk.ParticipationKeeper.Params.Set(ctx, params) + require.NoError(t, err) + + addr := sample.Address(r) + dels, _, err := tk.DelegateN(ctx, r, addr, 100, 10) + require.NoError(t, err) + + for _, tc := range []struct { + name string + request *types.QueryAvailableAllocationsRequest + response *types.QueryAvailableAllocationsResponse + err error + }{ + { + name: "should allow valid case", + request: &types.QueryAvailableAllocationsRequest{ + Address: dels[0].DelegatorAddress, + }, + response: &types.QueryAvailableAllocationsResponse{AvailableAllocations: sdkmath.NewInt(10)}, + }, + + { + name: "should prevent invalid address", + request: &types.QueryAvailableAllocationsRequest{ + Address: strconv.Itoa(100000), + }, + err: status.Error(codes.InvalidArgument, "decoding bech32 failed: invalid bech32 string length 6: invalid participant address"), + }, + { + name: "should return invalid request", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.name, func(t *testing.T) { + response, err := qs.AvailableAllocations(ctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} diff --git a/x/participation/keeper/query_total_allocations.go b/x/participation/keeper/query_total_allocations.go index d98518fa..f56cbebd 100644 --- a/x/participation/keeper/query_total_allocations.go +++ b/x/participation/keeper/query_total_allocations.go @@ -14,7 +14,10 @@ func (q queryServer) TotalAllocations(ctx context.Context, req *types.QueryTotal return nil, status.Error(codes.InvalidArgument, "invalid request") } - // TODO: Process the query + numAlloc, err := q.k.GetTotalAllocations(ctx, req.Address) + if err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } - return &types.QueryTotalAllocationsResponse{}, nil + return &types.QueryTotalAllocationsResponse{TotalAllocations: numAlloc}, nil } diff --git a/x/participation/keeper/query_total_allocations_test.go b/x/participation/keeper/query_total_allocations_test.go new file mode 100644 index 00000000..8f194071 --- /dev/null +++ b/x/participation/keeper/query_total_allocations_test.go @@ -0,0 +1,72 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/ignite/network/testutil/keeper" + "github.com/ignite/network/testutil/nullify" + "github.com/ignite/network/testutil/sample" + "github.com/ignite/network/x/participation/keeper" + "github.com/ignite/network/x/participation/types" +) + +func TestShowTotalAllocationsQuery(t *testing.T) { + ctx, tk, _ := keepertest.NewTestSetup(t) + qs := keeper.NewQueryServerImpl(tk.ParticipationKeeper) + + params := types.DefaultParams() + params.AllocationPrice = types.AllocationPrice{Bonded: sdkmath.NewInt(100)} + + err := tk.ParticipationKeeper.Params.Set(ctx, params) + require.NoError(t, err) + + addr := sample.Address(r) + dels, _, err := tk.DelegateN(ctx, r, addr, 100, 10) + require.NoError(t, err) + + for _, tc := range []struct { + name string + request *types.QueryTotalAllocationsRequest + response *types.QueryTotalAllocationsResponse + err error + }{ + { + name: "should allow valid case", + request: &types.QueryTotalAllocationsRequest{ + Address: dels[0].DelegatorAddress, + }, + response: &types.QueryTotalAllocationsResponse{TotalAllocations: sdkmath.NewInt(10)}, + }, + + { + name: "should prevent invalid address", + request: &types.QueryTotalAllocationsRequest{ + Address: strconv.Itoa(100000), + }, + err: status.Error(codes.InvalidArgument, "decoding bech32 failed: invalid bech32 string length 6: invalid participant address"), + }, + { + name: "should return invalid request", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.name, func(t *testing.T) { + response, err := qs.TotalAllocations(ctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} diff --git a/x/participation/keeper/query_used_allocations_test.go b/x/participation/keeper/query_used_allocations_test.go index d89087a6..7e249e8c 100644 --- a/x/participation/keeper/query_used_allocations_test.go +++ b/x/participation/keeper/query_used_allocations_test.go @@ -16,9 +16,6 @@ import ( "github.com/ignite/network/x/participation/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNUsedAllocations(keeper keeper.Keeper, ctx context.Context, n int) []types.UsedAllocations { items := make([]types.UsedAllocations, n) for i := range items { diff --git a/x/profile/keeper/query_validator_test.go b/x/profile/keeper/query_validator_test.go index e0fd2369..f88c9636 100644 --- a/x/profile/keeper/query_validator_test.go +++ b/x/profile/keeper/query_validator_test.go @@ -17,9 +17,6 @@ import ( "github.com/ignite/network/x/profile/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNValidator(keeper keeper.Keeper, ctx context.Context, n int) []types.Validator { items := make([]types.Validator, n) for i := range items { diff --git a/x/profile/types/message_validator_test.go b/x/profile/types/message_validator_test.go index b747d570..6dc04f9a 100644 --- a/x/profile/types/message_validator_test.go +++ b/x/profile/types/message_validator_test.go @@ -32,14 +32,14 @@ func TestMsgAddValidatorOperatorAddress_ValidateBasic(t *testing.T) { err error }{ { - name: "should validate different addresses for SPN validator and operator address", + name: "should validate different addresses for Network validator and operator address", msg: types.MsgAddValidatorOperatorAddress{ ValidatorAddress: sample.Address(r), OperatorAddress: sample.Address(r), }, }, { - name: "should prevent validate same address for SPN validator and operator address", + name: "should prevent validate same address for Network validator and operator address", msg: types.MsgAddValidatorOperatorAddress{ ValidatorAddress: sampleAddr, OperatorAddress: sampleAddr, @@ -47,7 +47,7 @@ func TestMsgAddValidatorOperatorAddress_ValidateBasic(t *testing.T) { err: types.ErrDupAddress, }, { - name: "should prevent validate invalid SPN validator address", + name: "should prevent validate invalid Network validator address", msg: types.MsgAddValidatorOperatorAddress{ ValidatorAddress: "invalid_address", OperatorAddress: sample.Address(r), diff --git a/x/project/keeper/msg_server_burn_vouchers_test.go b/x/project/keeper/msg_server_burn_vouchers_test.go index 2d347fd2..150df92d 100644 --- a/x/project/keeper/msg_server_burn_vouchers_test.go +++ b/x/project/keeper/msg_server_burn_vouchers_test.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" ignterrors "github.com/ignite/network/pkg/errors" - spntypes "github.com/ignite/network/pkg/types" + networktypes "github.com/ignite/network/pkg/types" testkeeper "github.com/ignite/network/testutil/keeper" "github.com/ignite/network/testutil/sample" "github.com/ignite/network/x/project/types" @@ -24,7 +24,7 @@ func TestMsgBurnVouchers(t *testing.T) { vouchers sdk.Coins err error vouchersTooBig = sdk.NewCoins( - sdk.NewCoin("v/0/foo", sdkmath.NewInt(spntypes.TotalShareNumber+1)), + sdk.NewCoin("v/0/foo", sdkmath.NewInt(networktypes.TotalShareNumber+1)), ) ) diff --git a/x/project/keeper/msg_server_mint_vouchers_test.go b/x/project/keeper/msg_server_mint_vouchers_test.go index 273c888c..b138ad0a 100644 --- a/x/project/keeper/msg_server_mint_vouchers_test.go +++ b/x/project/keeper/msg_server_mint_vouchers_test.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - spntypes "github.com/ignite/network/pkg/types" + networktypes "github.com/ignite/network/pkg/types" testkeeper "github.com/ignite/network/testutil/keeper" "github.com/ignite/network/testutil/sample" profiletypes "github.com/ignite/network/x/profile/types" @@ -23,7 +23,7 @@ func TestMsgMintVouchers(t *testing.T) { shares, _ = types.NewShares("1000foo,500bar,300foobar") sharesTooBig = types.NewSharesFromCoins(sdk.NewCoins( - sdk.NewCoin("foo", sdkmath.NewInt(spntypes.TotalShareNumber+1)), + sdk.NewCoin("foo", sdkmath.NewInt(networktypes.TotalShareNumber+1)), )) ) diff --git a/x/project/keeper/msg_server_redeem_vouchers_test.go b/x/project/keeper/msg_server_redeem_vouchers_test.go index 32ae3bce..b989ce5f 100644 --- a/x/project/keeper/msg_server_redeem_vouchers_test.go +++ b/x/project/keeper/msg_server_redeem_vouchers_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" ignterrors "github.com/ignite/network/pkg/errors" - spntypes "github.com/ignite/network/pkg/types" + networktypes "github.com/ignite/network/pkg/types" testkeeper "github.com/ignite/network/testutil/keeper" "github.com/ignite/network/testutil/sample" "github.com/ignite/network/x/project/types" @@ -27,7 +27,7 @@ func TestMsgRedeemVouchers(t *testing.T) { vouchers sdk.Coins err error vouchersTooBig = sdk.NewCoins( - sdk.NewCoin("v/0/foo", sdkmath.NewInt(spntypes.TotalShareNumber+1)), + sdk.NewCoin("v/0/foo", sdkmath.NewInt(networktypes.TotalShareNumber+1)), ) ) diff --git a/x/project/keeper/query_mainnet_account_balance.go b/x/project/keeper/query_mainnet_account_balance.go index 249fdabe..cc994ddf 100644 --- a/x/project/keeper/query_mainnet_account_balance.go +++ b/x/project/keeper/query_mainnet_account_balance.go @@ -2,7 +2,12 @@ package keeper import ( "context" + "fmt" + "cosmossdk.io/collections" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -14,9 +19,40 @@ func (q queryServer) MainnetAccountBalance(ctx context.Context, req *types.Query return nil, status.Error(codes.InvalidArgument, "invalid request") } - // TODO: Process the query + address, err := q.k.addressCodec.StringToBytes(req.Address) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid address") + } - return &types.QueryMainnetAccountBalanceResponse{}, nil + // get project and share information + totalShareNumber, err := q.k.TotalShares.Get(ctx) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + project, err := q.k.GetProject(ctx, req.ProjectID) + if err != nil { + return nil, status.Error(codes.NotFound, "project not found") + } + + // get account balance + acc, err := q.k.GetMainnetAccount(ctx, req.ProjectID, address) + if err != nil { + return nil, status.Error(codes.NotFound, "account not found") + } + + balance, err := acc.Shares.CoinsFromTotalSupply(project.TotalSupply, totalShareNumber) + if err != nil { + return nil, status.Errorf(codes.Internal, "balance can't be calculated: %s", err.Error()) + } + + mainnetAccountBalance := types.MainnetAccountBalance{ + ProjectID: acc.ProjectID, + Address: acc.Address, + Coins: balance, + } + + return &types.QueryMainnetAccountBalanceResponse{MainnetAccountBalance: mainnetAccountBalance}, nil } func (q queryServer) ListMainnetAccountBalance(ctx context.Context, req *types.QueryListMainnetAccountBalanceRequest) (*types.QueryListMainnetAccountBalanceResponse, error) { @@ -24,7 +60,43 @@ func (q queryServer) ListMainnetAccountBalance(ctx context.Context, req *types.Q return nil, status.Error(codes.InvalidArgument, "invalid request") } - // TODO: Process the query + // get project and share information + totalShareNumber, err := q.k.TotalShares.Get(ctx) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + project, err := q.k.GetProject(ctx, req.ProjectID) + if err != nil { + return nil, status.Error(codes.NotFound, "project not found") + } + + // iterate accounts + mainnetAccountBalances := make([]types.MainnetAccountBalance, 0) + _, pageRes, err := query.CollectionPaginate( + ctx, + q.k.MainnetAccount, + req.Pagination, + func(_ collections.Pair[uint64, sdk.AccAddress], acc types.MainnetAccount) (types.MainnetAccount, error) { + balance, err := acc.Shares.CoinsFromTotalSupply(project.TotalSupply, totalShareNumber) + if err != nil { + return acc, fmt.Errorf("balance can't be calculated for account %s: %s", acc.Address, err.Error()) + } + // add the balance if not zero + if !balance.IsZero() { + mainnetAccountBalance := types.MainnetAccountBalance{ + ProjectID: acc.ProjectID, + Address: acc.Address, + Coins: balance, + } + mainnetAccountBalances = append(mainnetAccountBalances, mainnetAccountBalance) + } + return acc, nil + }, + ) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } - return &types.QueryListMainnetAccountBalanceResponse{}, nil + return &types.QueryListMainnetAccountBalanceResponse{MainnetAccountBalance: mainnetAccountBalances, Pagination: pageRes}, nil } diff --git a/x/project/keeper/query_mainnet_account_balance_test.go b/x/project/keeper/query_mainnet_account_balance_test.go new file mode 100644 index 00000000..317f455d --- /dev/null +++ b/x/project/keeper/query_mainnet_account_balance_test.go @@ -0,0 +1,240 @@ +package keeper_test + +import ( + "context" + "fmt" + "testing" + + "cosmossdk.io/collections" + + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + tc "github.com/ignite/network/testutil/constructor" + keepertest "github.com/ignite/network/testutil/keeper" + "github.com/ignite/network/testutil/sample" + "github.com/ignite/network/x/project/keeper" + "github.com/ignite/network/x/project/types" +) + +func createNMainnetAccountForProjectIDWithTotalSupply( + t *testing.T, + keeper keeper.Keeper, + ctx context.Context, + n int, + projectID uint64, +) []types.MainnetAccountBalance { + totalSupply := tc.Coins(t, "100000foo,200000bar") + totalShares := uint64(100000) + + // create and set project + project := sample.Project(r, projectID) + project.TotalSupply = totalSupply + err := keeper.Project.Set(ctx, projectID, project) + require.NoError(t, err) + err = keeper.TotalShares.Set(ctx, totalShares) + require.NoError(t, err) + + // set account and create n account balance + // shares of accounts are foo and bar shares with random share number + items := make([]types.MainnetAccountBalance, n) + for i := range items { + addr := sample.AccAddress(r) + acc := sample.MainnetAccount(r, projectID, addr.String()) + fooShares := r.Intn(int(totalShares)) + barShares := r.Intn(int(totalShares)) + acc.Shares = tc.Shares(t, fmt.Sprintf("%dfoo,%dbar", fooShares, barShares)) + err = keeper.MainnetAccount.Set(ctx, collections.Join(projectID, addr), acc) + require.NoError(t, err) + + balance, err := acc.Shares.CoinsFromTotalSupply(totalSupply, totalShares) + require.NoError(t, err) + items[i] = types.MainnetAccountBalance{ + ProjectID: projectID, + Address: acc.Address, + Coins: balance, + } + } + return items +} + +func TestMainnetAccountBalanceQuerySingle(t *testing.T) { + var ( + projectID = uint64(5) + k, ctx, _ = keepertest.ProjectKeeper(t) + qs = keeper.NewQueryServerImpl(k) + msgs = createNMainnetAccountForProjectIDWithTotalSupply(t, k, ctx, 5, projectID) + ) + for _, tc := range []struct { + desc string + request *types.QueryMainnetAccountBalanceRequest + response *types.QueryMainnetAccountBalanceResponse + err error + }{ + { + desc: "First", + request: &types.QueryMainnetAccountBalanceRequest{ + ProjectID: msgs[0].ProjectID, + Address: msgs[0].Address, + }, + response: &types.QueryMainnetAccountBalanceResponse{MainnetAccountBalance: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryMainnetAccountBalanceRequest{ + ProjectID: msgs[1].ProjectID, + Address: msgs[1].Address, + }, + response: &types.QueryMainnetAccountBalanceResponse{MainnetAccountBalance: msgs[1]}, + }, + { + desc: "project not found", + request: &types.QueryMainnetAccountBalanceRequest{ + ProjectID: 10000, + Address: sample.Address(r), + }, + err: status.Error(codes.NotFound, "project not found"), + }, + { + desc: "account not found", + request: &types.QueryMainnetAccountBalanceRequest{ + ProjectID: projectID, + Address: sample.Address(r), + }, + err: status.Error(codes.NotFound, "account not found"), + }, + { + desc: "invalid request", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + response, err := qs.MainnetAccountBalance(ctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.Equal(t, tc.response, response) + } + }) + } +} + +func TestMainnetAccountBalanceQueryPaginated(t *testing.T) { + var ( + projectID = uint64(5) + k, ctx, _ = keepertest.ProjectKeeper(t) + qs = keeper.NewQueryServerImpl(k) + msgs = createNMainnetAccountForProjectIDWithTotalSupply(t, k, ctx, 5, projectID) + ) + request := func(projectID uint64, next []byte, offset, limit uint64, total bool) *types.QueryListMainnetAccountBalanceRequest { + return &types.QueryListMainnetAccountBalanceRequest{ + ProjectID: projectID, + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + resp, err := qs.ListMainnetAccountBalance(ctx, request(projectID, nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.MainnetAccountBalance), step) + require.Subset(t, msgs, resp.MainnetAccountBalance) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + resp, err := qs.ListMainnetAccountBalance(ctx, request(projectID, next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.MainnetAccountBalance), step) + require.Subset(t, msgs, resp.MainnetAccountBalance) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := qs.ListMainnetAccountBalance(ctx, request(projectID, nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, msgs, resp.MainnetAccountBalance) + }) + t.Run("invalid request", func(t *testing.T) { + _, err := qs.ListMainnetAccountBalance(ctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) + t.Run("project not found", func(t *testing.T) { + _, err := qs.ListMainnetAccountBalance(ctx, request(10000, nil, 0, 0, true)) + require.ErrorIs(t, err, status.Error(codes.NotFound, "project not found")) + }) +} + +func TestMainnetAccountBalanceAll(t *testing.T) { + var ( + k, ctx, _ = keepertest.ProjectKeeper(t) + qs = keeper.NewQueryServerImpl(k) + + projectID = uint64(5) + totalSupply = tc.Coins(t, "1000foo,1000bar") + totalShares = uint64(100) + addr1 = sample.AccAddress(r) + addr2 = sample.AccAddress(r) + addr3 = sample.AccAddress(r) + project = sample.Project(r, projectID) + ) + + // set project and sample accounts + project.TotalSupply = totalSupply + err := k.Project.Set(ctx, projectID, project) + require.NoError(t, err) + err = k.TotalShares.Set(ctx, totalShares) + require.NoError(t, err) + err = k.MainnetAccount.Set(ctx, collections.Join(projectID, addr1), types.MainnetAccount{ + ProjectID: projectID, + Address: addr1.String(), + Shares: tc.Shares(t, "100foo"), + }) + require.NoError(t, err) + err = k.MainnetAccount.Set(ctx, collections.Join(projectID, addr2), types.MainnetAccount{ + ProjectID: projectID, + Address: addr2.String(), + Shares: tc.Shares(t, "100bar"), + }) + require.NoError(t, err) + err = k.MainnetAccount.Set(ctx, collections.Join(projectID, addr3), types.MainnetAccount{ + ProjectID: projectID, + Address: addr3.String(), + Shares: tc.Shares(t, "100baz"), + }) + require.NoError(t, err) + + t.Run("accounts with empty balance are skipped", func(t *testing.T) { + accountBalances, err := qs.ListMainnetAccountBalance(ctx, &types.QueryListMainnetAccountBalanceRequest{ + ProjectID: projectID, + Pagination: &query.PageRequest{ + CountTotal: true, + }, + }) + require.NoError(t, err) + + // Account 3 must not be included in balances since the total supply doesn't contains baz tokens + balances := accountBalances.MainnetAccountBalance + require.Len(t, balances, 2) + require.Contains(t, balances, types.MainnetAccountBalance{ + ProjectID: projectID, + Address: addr1.String(), + Coins: tc.Coins(t, "1000foo"), + }) + require.Contains(t, balances, types.MainnetAccountBalance{ + ProjectID: projectID, + Address: addr2.String(), + Coins: tc.Coins(t, "1000bar"), + }) + }) +} diff --git a/x/project/keeper/query_mainnet_account_test.go b/x/project/keeper/query_mainnet_account_test.go index 3be4591f..f0283264 100644 --- a/x/project/keeper/query_mainnet_account_test.go +++ b/x/project/keeper/query_mainnet_account_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "context" - "strconv" "testing" "cosmossdk.io/collections" @@ -11,17 +10,13 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/ignite/network/testutil/sample" - keepertest "github.com/ignite/network/testutil/keeper" "github.com/ignite/network/testutil/nullify" + "github.com/ignite/network/testutil/sample" "github.com/ignite/network/x/project/keeper" "github.com/ignite/network/x/project/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNMainnetAccount(keeper keeper.Keeper, ctx context.Context, n int) []types.MainnetAccount { items := make([]types.MainnetAccount, n) for i := range items { diff --git a/x/project/keeper/query_project_chains_test.go b/x/project/keeper/query_project_chains_test.go index 302eaa08..5c6808e3 100644 --- a/x/project/keeper/query_project_chains_test.go +++ b/x/project/keeper/query_project_chains_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "context" - "strconv" "testing" "github.com/stretchr/testify/require" @@ -15,9 +14,6 @@ import ( "github.com/ignite/network/x/project/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNProjectChains(keeper keeper.Keeper, ctx context.Context, n int) []types.ProjectChains { items := make([]types.ProjectChains, n) for i := range items { diff --git a/x/project/keeper/query_special_allocations_balance.go b/x/project/keeper/query_special_allocations_balance.go index 4ac67d4a..907ea0fc 100644 --- a/x/project/keeper/query_special_allocations_balance.go +++ b/x/project/keeper/query_special_allocations_balance.go @@ -14,7 +14,35 @@ func (q queryServer) SpecialAllocationsBalance(ctx context.Context, req *types.Q return nil, status.Error(codes.InvalidArgument, "invalid request") } - // TODO: Process the query + // get the project + totalShareNumber, err := q.k.TotalShares.Get(ctx) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "can't get total shares %s", err.Error()) + } + + project, err := q.k.GetProject(ctx, req.ProjectID) + if err != nil { + return nil, status.Error(codes.NotFound, "project not found") + } + + // calculate special allocations balance from total supply + genesisDistribution, err := project.SpecialAllocations.GenesisDistribution.CoinsFromTotalSupply( + project.TotalSupply, + totalShareNumber, + ) + if err != nil { + return nil, status.Errorf(codes.Internal, "genesis distribution can't be calculated: %s", err.Error()) + } + claimableAirdrop, err := project.SpecialAllocations.ClaimableAirdrop.CoinsFromTotalSupply( + project.TotalSupply, + totalShareNumber, + ) + if err != nil { + return nil, status.Errorf(codes.Internal, "claimable airdrop can't be calculated: %s", err.Error()) + } - return &types.QuerySpecialAllocationsBalanceResponse{}, nil + return &types.QuerySpecialAllocationsBalanceResponse{ + GenesisDistribution: genesisDistribution, + ClaimableAirdrop: claimableAirdrop, + }, nil } diff --git a/x/project/keeper/query_special_allocations_balance_test.go b/x/project/keeper/query_special_allocations_balance_test.go new file mode 100644 index 00000000..8901673d --- /dev/null +++ b/x/project/keeper/query_special_allocations_balance_test.go @@ -0,0 +1,95 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + tc "github.com/ignite/network/testutil/constructor" + keepertest "github.com/ignite/network/testutil/keeper" + "github.com/ignite/network/testutil/sample" + "github.com/ignite/network/x/project/keeper" + "github.com/ignite/network/x/project/types" +) + +func TestSpecialAllocationsBalance(t *testing.T) { + var ( + k, ctx, _ = keepertest.ProjectKeeper(t) + qs = keeper.NewQueryServerImpl(k) + + projectID = uint64(1) + projectIDInvalidGenesisDistribution = uint64(2) + projectIDInvalidClaimableAirdrop = uint64(3) + ) + + err := k.TotalShares.Set(ctx, 100) + require.NoError(t, err) + + // initialize projects + setProject := func(projectID uint64, genesisDistribution, claimableAirdrop types.Shares) { + project := sample.Project(r, projectID) + project.TotalSupply = tc.Coins(t, "1000foo,1000bar,1000baz") + project.SpecialAllocations = types.NewSpecialAllocations( + genesisDistribution, + claimableAirdrop, + ) + project.AllocatedShares = tc.Shares(t, "100foo,100bar,100baz,100bam") + err := k.Project.Set(ctx, projectID, project) + require.NoError(t, err) + } + setProject(projectID, + tc.Shares(t, "50foo,20bar,30bam"), + tc.Shares(t, "50foo,100baz,40bam"), + ) + setProject(projectIDInvalidGenesisDistribution, + tc.Shares(t, "101foo"), + tc.Shares(t, "50foo"), + ) + setProject(projectIDInvalidClaimableAirdrop, + tc.Shares(t, "50foo"), + tc.Shares(t, "101foo"), + ) + + for _, tt := range []struct { + desc string + request *types.QuerySpecialAllocationsBalanceRequest + response *types.QuerySpecialAllocationsBalanceResponse + errStatusCode codes.Code + }{ + { + desc: "should fetch the balance of special allocations", + request: &types.QuerySpecialAllocationsBalanceRequest{ProjectID: projectID}, + response: &types.QuerySpecialAllocationsBalanceResponse{ + GenesisDistribution: tc.Coins(t, "500foo,200bar"), + ClaimableAirdrop: tc.Coins(t, "500foo,1000baz"), + }, + }, + { + desc: "should fail if project not found", + request: &types.QuerySpecialAllocationsBalanceRequest{ProjectID: 10000}, + errStatusCode: codes.NotFound, + }, + { + desc: "should fail if genesis distribution is invalid", + request: &types.QuerySpecialAllocationsBalanceRequest{ProjectID: projectIDInvalidGenesisDistribution}, + errStatusCode: codes.Internal, + }, + { + desc: "should fail if claimable airdrop is invalid", + request: &types.QuerySpecialAllocationsBalanceRequest{ProjectID: projectIDInvalidClaimableAirdrop}, + errStatusCode: codes.Internal, + }, + } { + t.Run(tt.desc, func(t *testing.T) { + response, err := qs.SpecialAllocationsBalance(ctx, tt.request) + if tt.errStatusCode != codes.OK { + require.EqualValues(t, tt.errStatusCode, status.Code(err)) + } else { + require.NoError(t, err) + require.Equal(t, tt.response, response) + } + }) + } +} diff --git a/x/project/keeper/query_total_shares.go b/x/project/keeper/query_total_shares.go index f8530c37..1ac3c2b4 100644 --- a/x/project/keeper/query_total_shares.go +++ b/x/project/keeper/query_total_shares.go @@ -14,7 +14,10 @@ func (q queryServer) TotalShares(ctx context.Context, req *types.QueryTotalShare return nil, status.Error(codes.InvalidArgument, "invalid request") } - // TODO: Process the query + shares, err := q.k.TotalShares.Get(ctx) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "can't get total shares %s", err.Error()) + } - return &types.QueryTotalSharesResponse{}, nil + return &types.QueryTotalSharesResponse{TotalShares: shares}, nil } diff --git a/x/project/keeper/query_total_shares_test.go b/x/project/keeper/query_total_shares_test.go new file mode 100644 index 00000000..b2597a00 --- /dev/null +++ b/x/project/keeper/query_total_shares_test.go @@ -0,0 +1,50 @@ +package keeper_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + networktypes "github.com/ignite/network/pkg/types" + keepertest "github.com/ignite/network/testutil/keeper" + "github.com/ignite/network/x/project/keeper" + "github.com/ignite/network/x/project/types" +) + +func TestTotalSharesQuery(t *testing.T) { + var ( + k, ctx, _ = keepertest.ProjectKeeper(t) + qs = keeper.NewQueryServerImpl(k) + ) + err := k.TotalShares.Set(ctx, networktypes.TotalShareNumber) + require.NoError(t, err) + + for _, tc := range []struct { + desc string + request *types.QueryTotalSharesRequest + response *types.QueryTotalSharesResponse + err error + }{ + { + desc: "should allow valid query", + request: &types.QueryTotalSharesRequest{}, + response: &types.QueryTotalSharesResponse{TotalShares: networktypes.TotalShareNumber}, + }, + { + desc: "should return InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + response, err := qs.TotalShares(ctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, tc.response, response) + } + }) + } +} diff --git a/x/project/simulation/helpers_test.go b/x/project/simulation/helpers_test.go index d4d734d5..2c38cb4e 100644 --- a/x/project/simulation/helpers_test.go +++ b/x/project/simulation/helpers_test.go @@ -10,7 +10,7 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/stretchr/testify/require" - spntypes "github.com/ignite/network/pkg/types" + networktypes "github.com/ignite/network/pkg/types" testkeeper "github.com/ignite/network/testutil/keeper" "github.com/ignite/network/testutil/sample" profilekeeper "github.com/ignite/network/x/profile/keeper" @@ -199,7 +199,7 @@ func TestGetSharesFromProject(t *testing.T) { ) shares, err := projecttypes.NewShares(fmt.Sprintf( "%[1]dfoo,%[1]dbar,%[1]dtoto", - spntypes.TotalShareNumber, + networktypes.TotalShareNumber, )) require.NoError(t, err) prjt.AllocatedShares = shares diff --git a/x/reward/keeper/query_reward_pool_test.go b/x/reward/keeper/query_reward_pool_test.go index 4d847818..a07cf7dc 100644 --- a/x/reward/keeper/query_reward_pool_test.go +++ b/x/reward/keeper/query_reward_pool_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "context" - "strconv" "testing" "github.com/cosmos/cosmos-sdk/types/query" @@ -16,9 +15,6 @@ import ( "github.com/ignite/network/x/reward/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - func createNRewardPool(keeper keeper.Keeper, ctx context.Context, n int) []types.RewardPool { items := make([]types.RewardPool, n) for i := range items { diff --git a/x/reward/keeper/reward_distribution_test.go b/x/reward/keeper/reward_distribution_test.go index d5a33dfa..0f15feeb 100644 --- a/x/reward/keeper/reward_distribution_test.go +++ b/x/reward/keeper/reward_distribution_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" ignterrors "github.com/ignite/network/pkg/errors" - spntypes "github.com/ignite/network/pkg/types" + networktypes "github.com/ignite/network/pkg/types" tc "github.com/ignite/network/testutil/constructor" testkeeper "github.com/ignite/network/testutil/keeper" "github.com/ignite/network/testutil/sample" @@ -218,7 +218,7 @@ func TestKeeper_DistributeRewards(t *testing.T) { type args struct { launchID uint64 - signatureCounts spntypes.SignatureCounts + signatureCounts networktypes.SignatureCounts lastBlockHeight int64 closeRewardPool bool }