diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index c967243a..2e63e278 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -875,8 +875,8 @@ paths: balance is the pool address account balance and indicates - whether or not the valaccount needs additional - funds to + whether or not the pool account needs + additional funds to pay for gas fees commission: @@ -4414,8 +4414,8 @@ paths: balance is the pool address account balance and indicates - whether or not the valaccount needs additional - funds to + whether or not the pool account needs + additional funds to pay for gas fees commission: @@ -7008,8 +7008,8 @@ paths: balance is the pool address account balance and indicates - whether or not the valaccount needs additional funds - to + whether or not the pool account needs additional + funds to pay for gas fees commission: @@ -7670,7 +7670,7 @@ paths: balance is the pool address account balance and indicates - whether or not the valaccount needs additional + whether or not the pool account needs additional funds to pay for gas fees @@ -8436,7 +8436,7 @@ paths: balance is the pool address account balance and indicates - whether or not the valaccount needs additional + whether or not the pool account needs additional funds to pay for gas fees @@ -9111,7 +9111,7 @@ paths: balance is the pool address account balance and indicates - whether or not the valaccount needs additional + whether or not the pool account needs additional funds to pay for gas fees diff --git a/proto/kyve/query/v1beta1/bundles.proto b/proto/kyve/query/v1beta1/bundles.proto index 45849410..7990127d 100644 --- a/proto/kyve/query/v1beta1/bundles.proto +++ b/proto/kyve/query/v1beta1/bundles.proto @@ -182,7 +182,7 @@ message QueryCurrentVoteStatusResponse { } // =================================== -// can_validate/{pool_id}/{valaddress} +// can_validate/{pool_id}/{pool_address} // =================================== // QueryCanProposeRequest is the request type for the Query/CanPropose RPC method. diff --git a/proto/kyve/query/v1beta1/query.proto b/proto/kyve/query/v1beta1/query.proto index 28ac0692..c1e9d51f 100644 --- a/proto/kyve/query/v1beta1/query.proto +++ b/proto/kyve/query/v1beta1/query.proto @@ -137,7 +137,7 @@ message PoolMembership { string pool_address = 4; // balance is the pool address account balance and indicates - // whether or not the valaccount needs additional funds to + // whether or not the pool account needs additional funds to // pay for gas fees uint64 balance = 5; diff --git a/testutil/integration/checks.go b/testutil/integration/checks.go index 9c4f57bd..d4a18fbc 100644 --- a/testutil/integration/checks.go +++ b/testutil/integration/checks.go @@ -126,9 +126,9 @@ func (suite *KeeperTestSuite) VerifyPoolQueries() { valaccounts := suite.App().StakersKeeper.GetAllPoolAccountsOfPool(suite.Ctx(), poolsState[i].Id) stakersByPoolState := make([]querytypes.FullStaker, 0) - for _, valaccount := range valaccounts { - if _, stakerFound := suite.App().StakersKeeper.GetValidator(suite.Ctx(), valaccount.Staker); stakerFound { - stakersByPoolState = append(stakersByPoolState, *suite.App().QueryKeeper.GetFullStaker(suite.Ctx(), valaccount.Staker)) + for _, poolAccount := range valaccounts { + if _, stakerFound := suite.App().StakersKeeper.GetValidator(suite.Ctx(), poolAccount.Staker); stakerFound { + stakersByPoolState = append(stakersByPoolState, *suite.App().QueryKeeper.GetFullStaker(suite.Ctx(), poolAccount.Staker)) } } @@ -474,14 +474,14 @@ func (suite *KeeperTestSuite) verifyFullStaker(fullStaker querytypes.FullStaker, for _, poolMembership := range fullStaker.Pools { poolIds[poolMembership.Pool.Id] = true - valaccount, active := suite.App().StakersKeeper.GetPoolAccount(suite.Ctx(), stakerAddress, poolMembership.Pool.Id) + poolAccount, active := suite.App().StakersKeeper.GetPoolAccount(suite.Ctx(), stakerAddress, poolMembership.Pool.Id) Expect(active).To(BeTrue()) - Expect(poolMembership.PoolAddress).To(Equal(valaccount.PoolAddress)) - Expect(poolMembership.IsLeaving).To(Equal(valaccount.IsLeaving)) - Expect(poolMembership.Points).To(Equal(valaccount.Points)) + Expect(poolMembership.PoolAddress).To(Equal(poolAccount.PoolAddress)) + Expect(poolMembership.IsLeaving).To(Equal(poolAccount.IsLeaving)) + Expect(poolMembership.Points).To(Equal(poolAccount.Points)) - pool, found := suite.App().PoolKeeper.GetPool(suite.Ctx(), valaccount.PoolId) + pool, found := suite.App().PoolKeeper.GetPool(suite.Ctx(), poolAccount.PoolId) Expect(found).To(BeTrue()) Expect(poolMembership.Pool.Id).To(Equal(pool.Id)) Expect(poolMembership.Pool.Logo).To(Equal(pool.Logo)) @@ -496,8 +496,8 @@ func (suite *KeeperTestSuite) verifyFullStaker(fullStaker querytypes.FullStaker, } // Reverse check the pool memberships - for _, valaccount := range suite.App().StakersKeeper.GetPoolAccountsFromStaker(suite.Ctx(), stakerAddress) { - Expect(poolIds[valaccount.PoolId]).To(BeTrue()) + for _, poolAccount := range suite.App().StakersKeeper.GetPoolAccountsFromStaker(suite.Ctx(), stakerAddress) { + Expect(poolIds[poolAccount.PoolId]).To(BeTrue()) } } diff --git a/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go b/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go index bd5d8976..d8e30164 100644 --- a/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go +++ b/x/bundles/keeper/logic_end_block_handle_upload_timeout_test.go @@ -391,8 +391,8 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Expect(poolStakers).To(HaveLen(2)) // check if next uploader received a point - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Points).To(Equal(uint64(1))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Points).To(Equal(uint64(1))) _, found := s.App().StakersKeeper.GetValidator(s.Ctx(), i.STAKER_0) Expect(found).To(BeTrue()) @@ -561,12 +561,12 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Expect(poolStakers).To(HaveLen(2)) // check that staker 0 has no points - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Points).To(Equal(uint64(0))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Points).To(Equal(uint64(0))) // check that staker 1 (next uploader) received a point for not uploading - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_1, 0) - Expect(valaccount.Points).To(Equal(uint64(1))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_1, 0) + Expect(poolAccount.Points).To(Equal(uint64(1))) // check that nobody got slashed expectedBalance := 100 * i.KYVE @@ -621,12 +621,12 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Expect(poolStakers).To(ContainElements(i.STAKER_0, i.STAKER_1)) // check that staker 0 (uploader) has no points - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Points).To(Equal(uint64(0))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Points).To(Equal(uint64(0))) // check that staker 1 received a point for not voting - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_1, 0) - Expect(valaccount.Points).To(Equal(uint64(1))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_1, 0) + Expect(poolAccount.Points).To(Equal(uint64(1))) // check that nobody got slashed expectedBalance := 100 * i.KYVE @@ -715,12 +715,12 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Expect(poolStakers).To(ContainElements(i.STAKER_1, i.STAKER_2)) // check that staker 1 (next uploader) received a point for missing the upload - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_1, 0) - Expect(valaccount.Points).To(Equal(uint64(1))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_1, 0) + Expect(poolAccount.Points).To(Equal(uint64(1))) // check that staker 2 has a no points - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_2, 0) - Expect(valaccount.Points).To(Equal(uint64(0))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_2, 0) + Expect(poolAccount.Points).To(Equal(uint64(0))) // check that staker 0 (uploader) got slashed expectedBalance := 100*i.KYVE - uint64(s.App().StakersKeeper.GetUploadSlash(s.Ctx()).Mul(math.LegacyNewDec(int64(100*i.KYVE))).TruncateInt64()) @@ -845,12 +845,12 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Expect(poolStakers).To(ContainElements(i.STAKER_0, i.STAKER_1)) // check that staker 0 (uploader) has no points - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_1, 0) - Expect(valaccount.Points).To(Equal(uint64(0))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_1, 0) + Expect(poolAccount.Points).To(Equal(uint64(0))) // check that staker 2 has a no points - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_2, 0) - Expect(valaccount.Points).To(Equal(uint64(0))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_2, 0) + Expect(poolAccount.Points).To(Equal(uint64(0))) // check that staker 0 (uploader) didn't get slashed expectedBalance := 100 * i.KYVE @@ -1004,7 +1004,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { BundleSummary: "test_value", }) - // remove valaccount directly from pool + // remove pool account directly from pool s.App().StakersKeeper.RemovePoolAccountFromPool(s.Ctx(), i.STAKER_1, 0) // ACT @@ -1086,7 +1086,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Vote: bundletypes.VOTE_TYPE_VALID, }) - // remove valaccount directly from pool + // remove pool account directly from pool s.App().StakersKeeper.RemovePoolAccountFromPool(s.Ctx(), i.STAKER_1, 0) // ACT @@ -1174,7 +1174,7 @@ var _ = Describe("logic_end_block_handle_upload_timeout.go", Ordered, func() { Vote: bundletypes.VOTE_TYPE_INVALID, }) - // remove valaccount directly from pool + // remove pool account directly from pool s.App().StakersKeeper.RemovePoolAccountFromPool(s.Ctx(), i.STAKER_0, 0) // ACT diff --git a/x/bundles/keeper/msg_server_claim_uploader_role_test.go b/x/bundles/keeper/msg_server_claim_uploader_role_test.go index e1278684..9123e436 100644 --- a/x/bundles/keeper/msg_server_claim_uploader_role_test.go +++ b/x/bundles/keeper/msg_server_claim_uploader_role_test.go @@ -19,8 +19,8 @@ TEST CASES - msg_server_claim_uploader_role.go * Try to claim uploader role without pool being funded * Try to claim uploader role without being a staker * Try to claim uploader role if the next uploader is not set yet -* Try to claim uploader role with non-existing valaccount -* Try to claim uploader role with valaccount that belongs to another pool +* Try to claim uploader role with non-existing pool account +* Try to claim uploader role with pool account that belongs to another pool */ @@ -155,7 +155,7 @@ var _ = Describe("msg_server_claim_uploader_role.go", Ordered, func() { Expect(bundleProposal.VotersAbstain).To(BeEmpty()) }) - It("Try to claim uploader role with non existing valaccount", func() { + It("Try to claim uploader role with non existing pool account", func() { // ARRANGE s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ Creator: i.ALICE, @@ -176,7 +176,7 @@ var _ = Describe("msg_server_claim_uploader_role.go", Ordered, func() { Expect(found).To(BeFalse()) }) - It("Try to claim uploader role with valaccount that belongs to another pool", func() { + It("Try to claim uploader role with pool account that belongs to another pool", func() { // ARRANGE s.RunTxPoolSuccess(&funderstypes.MsgFundPool{ Creator: i.ALICE, diff --git a/x/bundles/keeper/msg_server_skip_uploader_role_test.go b/x/bundles/keeper/msg_server_skip_uploader_role_test.go index 28e10dff..6fbce8d6 100644 --- a/x/bundles/keeper/msg_server_skip_uploader_role_test.go +++ b/x/bundles/keeper/msg_server_skip_uploader_role_test.go @@ -176,9 +176,9 @@ var _ = Describe("msg_server_skip_uploader_role.go", Ordered, func() { Expect(found).To(BeFalse()) // check that no validator got a point for the second round - valaccounts := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) - for _, valaccount := range valaccounts { - Expect(valaccount.Points).To(BeZero()) + poolAccounts := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) + for _, poolAccount := range poolAccounts { + Expect(poolAccount.Points).To(BeZero()) } }) @@ -248,9 +248,9 @@ var _ = Describe("msg_server_skip_uploader_role.go", Ordered, func() { Expect(found).To(BeFalse()) // check that no validator got a point for the second round - valaccounts := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) - for _, valaccount := range valaccounts { - Expect(valaccount.Points).To(BeZero()) + poolAccounts := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) + for _, poolAccount := range poolAccounts { + Expect(poolAccount.Points).To(BeZero()) } }) @@ -297,13 +297,13 @@ var _ = Describe("msg_server_skip_uploader_role.go", Ordered, func() { Expect(found).To(BeFalse()) // check that no validator got a point for the second round - valaccounts := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) - for _, valaccount := range valaccounts { - if valaccount.Staker == i.STAKER_0 { - Expect(valaccount.Points).To(BeZero()) + poolAccounts := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) + for _, poolAccount := range poolAccounts { + if poolAccount.Staker == i.STAKER_0 { + Expect(poolAccount.Points).To(BeZero()) } else { // All others have one point because they did not vote at all - Expect(valaccount.Points).To(Equal(uint64(1))) + Expect(poolAccount.Points).To(Equal(uint64(1))) } } }) @@ -364,9 +364,9 @@ var _ = Describe("msg_server_skip_uploader_role.go", Ordered, func() { Expect(finalizedBundle.Uploader).To(Equal(i.STAKER_0)) // check if no validator got a point for the second round - valaccounts := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) - for _, valaccount := range valaccounts { - Expect(valaccount.Points).To(BeZero()) + poolAccounts := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) + for _, poolAccount := range poolAccounts { + Expect(poolAccount.Points).To(BeZero()) } }) @@ -423,9 +423,9 @@ var _ = Describe("msg_server_skip_uploader_role.go", Ordered, func() { Expect(found).To(BeFalse()) // check that no validator got a point - valaccounts := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) - for _, valaccount := range valaccounts { - Expect(valaccount.Points).To(BeZero()) + poolAccounts := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) + for _, poolAccount := range poolAccounts { + Expect(poolAccount.Points).To(BeZero()) } }) }) diff --git a/x/bundles/types/expected_keepers.go b/x/bundles/types/expected_keepers.go index 17b2e95d..44341f38 100644 --- a/x/bundles/types/expected_keepers.go +++ b/x/bundles/types/expected_keepers.go @@ -31,7 +31,7 @@ type StakerKeeper interface { GetAllStakerAddressesOfPool(ctx sdk.Context, poolId uint64) (stakers []string) AssertPoolAccountAuthorized(ctx sdk.Context, stakerAddress string, poolId uint64, poolAddress string) error - GetPoolAccount(ctx sdk.Context, stakerAddress string, poolId uint64) (valaccount stakersTypes.PoolAccount, active bool) + GetPoolAccount(ctx sdk.Context, stakerAddress string, poolId uint64) (poolAccount stakersTypes.PoolAccount, active bool) LeavePool(ctx sdk.Context, stakerAddress string, poolId uint64) diff --git a/x/query/keeper/grpc_query_can_propose_test.go b/x/query/keeper/grpc_query_can_propose_test.go index 0f2e44c3..3e065797 100644 --- a/x/query/keeper/grpc_query_can_propose_test.go +++ b/x/query/keeper/grpc_query_can_propose_test.go @@ -27,7 +27,7 @@ TEST CASES - grpc_query_can_propose.go * Call can propose if pool is disabled * Call can propose if pool is out of funds * Call can propose if pool has not reached the minimum stake -* Call can propose with a valaccount which does not exist +* Call can propose with a pool account which does not exist * Call can propose as a staker who is not the next uploader * Call can propose before the upload interval passed * Call can propose with an invalid from height @@ -280,7 +280,7 @@ var _ = Describe("grpc_query_can_propose.go", Ordered, func() { Expect(txErr.Error()).To(Equal(canPropose.Reason)) }) - It("Call can propose with a valaccount which does not exist", func() { + It("Call can propose with a pool account which does not exist", func() { // ACT canPropose, err := s.App().QueryKeeper.CanPropose(s.Ctx(), &querytypes.QueryCanProposeRequest{ PoolId: 0, diff --git a/x/query/keeper/grpc_query_can_validate.go b/x/query/keeper/grpc_query_can_validate.go index cb198289..b1ade1c8 100644 --- a/x/query/keeper/grpc_query_can_validate.go +++ b/x/query/keeper/grpc_query_can_validate.go @@ -25,7 +25,7 @@ func (k Keeper) CanValidate(c context.Context, req *types.QueryCanValidateReques var staker string - // Check if valaddress has a valaccount in pool + // Check if pool address has a pool account in pool for _, poolAccount := range k.stakerKeeper.GetAllPoolAccountsOfPool(ctx, req.PoolId) { if poolAccount.PoolAddress == req.PoolAddress { staker = poolAccount.Staker @@ -36,7 +36,7 @@ func (k Keeper) CanValidate(c context.Context, req *types.QueryCanValidateReques if staker == "" { return &types.QueryCanValidateResponse{ Possible: false, - Reason: "no valaccount found", + Reason: "no pool account found", }, nil } diff --git a/x/query/keeper/grpc_query_can_validate_test.go b/x/query/keeper/grpc_query_can_validate_test.go index c957a794..a179c60f 100644 --- a/x/query/keeper/grpc_query_can_validate_test.go +++ b/x/query/keeper/grpc_query_can_validate_test.go @@ -17,9 +17,9 @@ import ( TEST CASES - grpc_query_can_validate.go * Call can validate if pool does not exist -* Call can validate if valaddress does not exist -* Call can validate with a valaddress which belongs to another pool -* Call can validate with a valid valaddress +* Call can validate if pool address does not exist +* Call can validate with a pool address which belongs to another pool +* Call can validate with a valid pool address */ @@ -83,7 +83,7 @@ var _ = Describe("grpc_query_can_validate.go", Ordered, func() { Expect(canValidate.Reason).To(Equal(errors.Wrapf(errorsTypes.ErrNotFound, pooltypes.ErrPoolNotFound.Error(), 2).Error())) }) - It("Call can validate if valaddress does not exist", func() { + It("Call can validate if pool address does not exist", func() { // ACT canValidate, err := s.App().QueryKeeper.CanValidate(s.Ctx(), &querytypes.QueryCanValidateRequest{ PoolId: 0, @@ -94,10 +94,10 @@ var _ = Describe("grpc_query_can_validate.go", Ordered, func() { Expect(err).To(BeNil()) Expect(canValidate.Possible).To(BeFalse()) - Expect(canValidate.Reason).To(Equal("no valaccount found")) + Expect(canValidate.Reason).To(Equal("no pool account found")) }) - It("Call can validate with a valaddress which belongs to another pool", func() { + It("Call can validate with a pool address which belongs to another pool", func() { // ACT canValidate, err := s.App().QueryKeeper.CanValidate(s.Ctx(), &querytypes.QueryCanValidateRequest{ PoolId: 0, @@ -108,10 +108,10 @@ var _ = Describe("grpc_query_can_validate.go", Ordered, func() { Expect(err).To(BeNil()) Expect(canValidate.Possible).To(BeFalse()) - Expect(canValidate.Reason).To(Equal("no valaccount found")) + Expect(canValidate.Reason).To(Equal("no pool account found")) }) - It("Call can validate with a valid valaddress", func() { + It("Call can validate with a valid pool address", func() { // ACT canValidate, err := s.App().QueryKeeper.CanValidate(s.Ctx(), &querytypes.QueryCanValidateRequest{ PoolId: 0, diff --git a/x/query/keeper/grpc_query_can_vote_test.go b/x/query/keeper/grpc_query_can_vote_test.go index 38b47805..dc8dd2ab 100644 --- a/x/query/keeper/grpc_query_can_vote_test.go +++ b/x/query/keeper/grpc_query_can_vote_test.go @@ -26,7 +26,7 @@ TEST CASES - grpc_query_can_vote.go * Call can vote if pool is currently upgrading * Call can vote if pool is disabled * Call can vote if pool has not reached the minimum stake -* Call can vote with a valaccount which does not exist +* Call can vote with a pool account which does not exist * Call can vote if current bundle was dropped * Call can vote with a different storage id than the current one * Call can vote if voter has already voted valid @@ -246,7 +246,7 @@ var _ = Describe("grpc_query_can_vote.go", Ordered, func() { Expect(txErr.Error()).To(Equal(canVote.Reason)) }) - It("Call can vote with a valaccount which does not exist", func() { + It("Call can vote with a pool account which does not exist", func() { // ACT canVote, err := s.App().QueryKeeper.CanVote(s.Ctx(), &querytypes.QueryCanVoteRequest{ PoolId: 0, diff --git a/x/query/types/query.pb.go b/x/query/types/query.pb.go index ade83b9b..cbc2597a 100644 --- a/x/query/types/query.pb.go +++ b/x/query/types/query.pb.go @@ -341,7 +341,7 @@ type PoolMembership struct { // the staker can just change the pool address . PoolAddress string `protobuf:"bytes,4,opt,name=pool_address,json=poolAddress,proto3" json:"pool_address,omitempty"` // balance is the pool address account balance and indicates - // whether or not the valaccount needs additional funds to + // whether or not the pool account needs additional funds to // pay for gas fees Balance uint64 `protobuf:"varint,5,opt,name=balance,proto3" json:"balance,omitempty"` // commission is the commission the validator has chosen for diff --git a/x/stakers/keeper/msg_server_join_pool_test.go b/x/stakers/keeper/msg_server_join_pool_test.go index 7fa063c1..d7273a27 100644 --- a/x/stakers/keeper/msg_server_join_pool_test.go +++ b/x/stakers/keeper/msg_server_join_pool_test.go @@ -26,25 +26,25 @@ TEST CASES - msg_server_join_pool.go * Join disabled pool * Join a pool where other stakers have already joined * Self-Delegate more KYVE after joining a pool -* Join a pool with the same valaddress as the staker address -* Try to join the same pool with the same valaddress again -* Try to join the same pool with a different valaddress -* Try to join another pool with the same valaddress again -* Try to join another pool with a valaddress that is already used by another staker -* Try to join another pool with a different valaddress -* Try to join pool with empty valaddress +* Join a pool with the same pool address as the staker address +* Try to join the same pool with the same pool address again +* Try to join the same pool with a different pool address +* Try to join another pool with the same pool address again +* Try to join another pool with a pool address that is already used by another staker +* Try to join another pool with a different pool address +* Try to join pool with empty pool address * Try to join pool with empty commission * Try to join pool with empty stake fraction -* Join a pool with a valaddress which does not exist on chain yet -* Join a pool with a valaddress which does not exist on chain yet and send 0 funds -* Join a pool with an invalid valaddress -* Join a pool and fund the valaddress with more KYVE than available in balance +* Join a pool with a pool address which does not exist on chain yet +* Join a pool with a pool address which does not exist on chain yet and send 0 funds +* Join a pool with an invalid pool address +* Join a pool and fund the pool address with more KYVE than available in balance * Kick out lowest staker by joining a full pool * Fail to kick out lowest staker because not enough stake * Kick out lowest staker with respect to stake + delegation * Fail to kick out lowest staker because not enough stake + delegation -* Join pool again with same valaddress after staker has left pool -* Join pool again with different valaddress after staker has left pool +* Join pool again with same pool address after staker has left pool +* Join pool again with different pool address after staker has left pool */ @@ -112,15 +112,15 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) - valaccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + poolAccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) Expect(active).To(BeTrue()) - Expect(valaccount.Staker).To(Equal(i.STAKER_0)) - Expect(valaccount.PoolId).To(BeZero()) - Expect(valaccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) - Expect(valaccount.Points).To(BeZero()) - Expect(valaccount.IsLeaving).To(BeFalse()) + Expect(poolAccount.Staker).To(Equal(i.STAKER_0)) + Expect(poolAccount.PoolId).To(BeZero()) + Expect(poolAccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) + Expect(poolAccount.Points).To(BeZero()) + Expect(poolAccount.IsLeaving).To(BeFalse()) valaccountsOfPool := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) @@ -222,15 +222,15 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) - valaccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + poolAccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) Expect(active).To(BeTrue()) - Expect(valaccount.Staker).To(Equal(i.STAKER_0)) - Expect(valaccount.PoolId).To(BeZero()) - Expect(valaccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) - Expect(valaccount.Points).To(BeZero()) - Expect(valaccount.IsLeaving).To(BeFalse()) + Expect(poolAccount.Staker).To(Equal(i.STAKER_0)) + Expect(poolAccount.PoolId).To(BeZero()) + Expect(poolAccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) + Expect(poolAccount.Points).To(BeZero()) + Expect(poolAccount.IsLeaving).To(BeFalse()) valaccountsOfPool := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) @@ -269,15 +269,15 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) - valaccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + poolAccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) Expect(active).To(BeTrue()) - Expect(valaccount.Staker).To(Equal(i.STAKER_0)) - Expect(valaccount.PoolId).To(BeZero()) - Expect(valaccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) - Expect(valaccount.Points).To(BeZero()) - Expect(valaccount.IsLeaving).To(BeFalse()) + Expect(poolAccount.Staker).To(Equal(i.STAKER_0)) + Expect(poolAccount.PoolId).To(BeZero()) + Expect(poolAccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) + Expect(poolAccount.Points).To(BeZero()) + Expect(poolAccount.IsLeaving).To(BeFalse()) valaccountsOfPool := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) @@ -291,7 +291,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(totalStakeOfPool)) }) - It("Try to join the same pool with the same valaddress again", func() { + It("Try to join the same pool with the same pool address again", func() { // ARRANGE s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -318,7 +318,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) }) - It("join a pool with the same valaddress as the staker address", func() { + It("join a pool with the same pool address as the staker address", func() { // ACT s.RunTxStakersError(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -335,7 +335,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(BeEmpty()) }) - It("Try to join the same pool with a different valaddress", func() { + It("Try to join the same pool with a different pool address", func() { // ARRANGE s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -362,7 +362,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) }) - It("Try to join another pool with the same valaddress again", func() { + It("Try to join another pool with the same pool address again", func() { // ARRANGE s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -397,7 +397,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) }) - It("Try to join pool with a valaddress that is already used by another staker", func() { + It("Try to join pool with a pool address that is already used by another staker", func() { // ARRANGE msg := &pooltypes.MsgCreatePool{ Authority: gov, @@ -434,7 +434,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) }) - It("Try to join pool with a valaddress that is already used by another staker", func() { + It("Try to join pool with a pool address that is already used by another staker", func() { // ARRANGE s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -462,7 +462,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(BeEmpty()) }) - It("Try to join another pool with a different valaddress", func() { + It("Try to join another pool with a different pool address", func() { // ARRANGE s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -496,7 +496,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(2)) }) - It("Try to join pool with empty valaddress", func() { + It("Try to join pool with empty pool address", func() { // ACT s.RunTxStakersError(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -542,7 +542,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(BeEmpty()) }) - It("Join a pool with a valaddress which does not exist on chain yet", func() { + It("Join a pool with a pool address which does not exist on chain yet", func() { // ACT s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -564,15 +564,15 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) - valaccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + poolAccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) Expect(active).To(BeTrue()) - Expect(valaccount.Staker).To(Equal(i.STAKER_0)) - Expect(valaccount.PoolId).To(BeZero()) - Expect(valaccount.PoolAddress).To(Equal("kyve1dx0nvx7y9d44jvr2dr6r2p636jea3f9827rn0x")) - Expect(valaccount.Points).To(BeZero()) - Expect(valaccount.IsLeaving).To(BeFalse()) + Expect(poolAccount.Staker).To(Equal(i.STAKER_0)) + Expect(poolAccount.PoolId).To(BeZero()) + Expect(poolAccount.PoolAddress).To(Equal("kyve1dx0nvx7y9d44jvr2dr6r2p636jea3f9827rn0x")) + Expect(poolAccount.Points).To(BeZero()) + Expect(poolAccount.IsLeaving).To(BeFalse()) valaccountsOfPool := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) @@ -585,7 +585,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(totalStakeOfPool)) }) - It("Join a pool with a valaddress which does not exist on chain yet and send 0 funds", func() { + It("Join a pool with a pool address which does not exist on chain yet and send 0 funds", func() { // ACT s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -607,15 +607,15 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) - valaccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + poolAccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) Expect(active).To(BeTrue()) - Expect(valaccount.Staker).To(Equal(i.STAKER_0)) - Expect(valaccount.PoolId).To(BeZero()) - Expect(valaccount.PoolAddress).To(Equal("kyve1dx0nvx7y9d44jvr2dr6r2p636jea3f9827rn0x")) - Expect(valaccount.Points).To(BeZero()) - Expect(valaccount.IsLeaving).To(BeFalse()) + Expect(poolAccount.Staker).To(Equal(i.STAKER_0)) + Expect(poolAccount.PoolId).To(BeZero()) + Expect(poolAccount.PoolAddress).To(Equal("kyve1dx0nvx7y9d44jvr2dr6r2p636jea3f9827rn0x")) + Expect(poolAccount.Points).To(BeZero()) + Expect(poolAccount.IsLeaving).To(BeFalse()) valaccountsOfPool := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) @@ -628,7 +628,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(totalStakeOfPool)) }) - It("Join a pool with an invalid valaddress", func() { + It("Join a pool with an invalid pool address", func() { // ACT s.RunTxStakersError(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -645,7 +645,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(BeEmpty()) }) - It("Join a pool and fund the valaddress with more KYVE than available in balance", func() { + It("Join a pool and fund the pool address with more KYVE than available in balance", func() { // ACT s.RunTxStakersError(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -903,7 +903,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(s.App().StakersKeeper.GetAllStakerAddressesOfPool(s.Ctx(), 0)).NotTo(ContainElement(i.STAKER_1)) }) - It("Join pool again with same valaddress after staker has left pool", func() { + It("Join pool again with same pool address after staker has left pool", func() { // ARRANGE s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -947,17 +947,17 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) - valaccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + poolAccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) Expect(active).To(BeTrue()) - Expect(valaccount.Staker).To(Equal(i.STAKER_0)) - Expect(valaccount.PoolId).To(BeZero()) - Expect(valaccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) - Expect(valaccount.Points).To(BeZero()) - Expect(valaccount.IsLeaving).To(BeFalse()) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.2"))) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) + Expect(poolAccount.Staker).To(Equal(i.STAKER_0)) + Expect(poolAccount.PoolId).To(BeZero()) + Expect(poolAccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) + Expect(poolAccount.Points).To(BeZero()) + Expect(poolAccount.IsLeaving).To(BeFalse()) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.2"))) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) valaccountsOfPool := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) @@ -971,7 +971,7 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(s.App().StakersKeeper.GetDelegationAmountOfDelegator(s.Ctx(), i.STAKER_0, i.STAKER_0)).To(Equal(totalStakeOfPool)) }) - It("Join pool again with different valaddress after staker has left pool", func() { + It("Join pool again with different pool address after staker has left pool", func() { // ARRANGE s.RunTxStakersSuccess(&stakerstypes.MsgJoinPool{ Creator: i.STAKER_0, @@ -1017,17 +1017,17 @@ var _ = Describe("msg_server_join_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) - valaccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + poolAccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) Expect(active).To(BeTrue()) - Expect(valaccount.Staker).To(Equal(i.STAKER_0)) - Expect(valaccount.PoolId).To(BeZero()) - Expect(valaccount.PoolAddress).To(Equal(i.VALADDRESS_0_B)) - Expect(valaccount.Points).To(BeZero()) - Expect(valaccount.IsLeaving).To(BeFalse()) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.2"))) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) + Expect(poolAccount.Staker).To(Equal(i.STAKER_0)) + Expect(poolAccount.PoolId).To(BeZero()) + Expect(poolAccount.PoolAddress).To(Equal(i.VALADDRESS_0_B)) + Expect(poolAccount.Points).To(BeZero()) + Expect(poolAccount.IsLeaving).To(BeFalse()) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.2"))) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) valaccountsOfPool := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) diff --git a/x/stakers/keeper/msg_server_leave_pool_test.go b/x/stakers/keeper/msg_server_leave_pool_test.go index b18ec6fb..266d4305 100644 --- a/x/stakers/keeper/msg_server_leave_pool_test.go +++ b/x/stakers/keeper/msg_server_leave_pool_test.go @@ -72,17 +72,17 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) - valaccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + poolAccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) Expect(active).To(BeTrue()) - Expect(valaccount.Staker).To(Equal(i.STAKER_0)) - Expect(valaccount.PoolId).To(BeZero()) - Expect(valaccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) - Expect(valaccount.Points).To(BeZero()) - Expect(valaccount.IsLeaving).To(BeTrue()) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) + Expect(poolAccount.Staker).To(Equal(i.STAKER_0)) + Expect(poolAccount.PoolId).To(BeZero()) + Expect(poolAccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) + Expect(poolAccount.Points).To(BeZero()) + Expect(poolAccount.IsLeaving).To(BeTrue()) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) valaccountsOfPool := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) @@ -104,7 +104,7 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(BeEmpty()) - valaccount, active = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + poolAccount, active = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) Expect(active).To(BeFalse()) @@ -116,8 +116,8 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { Expect(totalStakeOfPool).To(BeZero()) // check if commission and stake fraction is still available - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) }) It("Leave a pool multiple other stakers have joined previously", func() { @@ -145,17 +145,17 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) - valaccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + poolAccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) Expect(active).To(BeTrue()) - Expect(valaccount.Staker).To(Equal(i.STAKER_0)) - Expect(valaccount.PoolId).To(BeZero()) - Expect(valaccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) - Expect(valaccount.Points).To(BeZero()) - Expect(valaccount.IsLeaving).To(BeTrue()) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) + Expect(poolAccount.Staker).To(Equal(i.STAKER_0)) + Expect(poolAccount.PoolId).To(BeZero()) + Expect(poolAccount.PoolAddress).To(Equal(i.VALADDRESS_0_A)) + Expect(poolAccount.Points).To(BeZero()) + Expect(poolAccount.IsLeaving).To(BeTrue()) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) valaccountsOfPool := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 0) @@ -177,7 +177,7 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(BeEmpty()) - valaccount, active = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + poolAccount, active = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) Expect(active).To(BeFalse()) @@ -189,8 +189,8 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { Expect(totalStakeOfPool).To(Equal(100 * i.KYVE)) // check if commission and stake fraction is still available - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) }) It("Try to leave a pool again", func() { @@ -250,17 +250,17 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(2)) - valaccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 1) + poolAccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 1) Expect(active).To(BeTrue()) - Expect(valaccount.Staker).To(Equal(i.STAKER_0)) - Expect(valaccount.PoolId).To(Equal(uint64(1))) - Expect(valaccount.PoolAddress).To(Equal(i.VALADDRESS_1_A)) - Expect(valaccount.Points).To(BeZero()) - Expect(valaccount.IsLeaving).To(BeTrue()) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) + Expect(poolAccount.Staker).To(Equal(i.STAKER_0)) + Expect(poolAccount.PoolId).To(Equal(uint64(1))) + Expect(poolAccount.PoolAddress).To(Equal(i.VALADDRESS_1_A)) + Expect(poolAccount.Points).To(BeZero()) + Expect(poolAccount.IsLeaving).To(BeTrue()) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) valaccountsOfPool := s.App().StakersKeeper.GetAllPoolAccountsOfPool(s.Ctx(), 1) @@ -280,7 +280,7 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { Expect(valaccountsOfStaker).To(HaveLen(1)) - valaccount, active = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 1) + poolAccount, active = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 1) Expect(active).To(BeFalse()) @@ -292,8 +292,8 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { Expect(totalStakeOfPool).To(BeZero()) // check if commission and stake fraction is still available - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) }) It("Leave a pool a staker has never joined", func() { @@ -317,12 +317,12 @@ var _ = Describe("msg_server_leave_pool.go", Ordered, func() { valaccountsOfStaker = s.App().StakersKeeper.GetPoolAccountsFromStaker(s.Ctx(), i.STAKER_1) Expect(valaccountsOfStaker).To(BeEmpty()) - valaccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 1) + poolAccount, active := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 1) Expect(active).To(BeFalse()) // check if commission and stake fraction is still available - Expect(valaccount.Commission).To(Equal(math.LegacyZeroDec())) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyZeroDec())) + Expect(poolAccount.Commission).To(Equal(math.LegacyZeroDec())) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyZeroDec())) }) }) diff --git a/x/stakers/keeper/msg_server_update_commission_test.go b/x/stakers/keeper/msg_server_update_commission_test.go index 9eb9af4a..1a5dc66f 100644 --- a/x/stakers/keeper/msg_server_update_commission_test.go +++ b/x/stakers/keeper/msg_server_update_commission_test.go @@ -63,8 +63,8 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { It("Get the default commission from a newly joined pool", func() { // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) }) It("Update commission to 50% from previous commission", func() { @@ -77,15 +77,15 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) // wait for update s.CommitAfterSeconds(s.App().StakersKeeper.GetCommissionChangeTime(s.Ctx())) s.CommitAfterSeconds(1) - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.5"))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.5"))) }) It("Update commission to 0% from previous commission", func() { @@ -98,15 +98,15 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) // wait for update s.CommitAfterSeconds(s.App().StakersKeeper.GetCommissionChangeTime(s.Ctx())) s.CommitAfterSeconds(1) - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyZeroDec())) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyZeroDec())) }) It("Update commission to 100% from previous commission", func() { @@ -119,15 +119,15 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) // wait for update s.CommitAfterSeconds(s.App().StakersKeeper.GetCommissionChangeTime(s.Ctx())) s.CommitAfterSeconds(1) - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyOneDec())) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyOneDec())) }) It("Update commission with a negative number from previous commission", func() { @@ -140,8 +140,8 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) }) It("Update commission with a too high number from previous commission", func() { @@ -154,8 +154,8 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) }) It("Update commission multiple times during the commission change time", func() { @@ -182,15 +182,15 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) // wait for update s.CommitAfterSeconds(s.App().StakersKeeper.GetCommissionChangeTime(s.Ctx())) s.CommitAfterSeconds(1) - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.3"))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.3"))) }) It("Update commission multiple times during the commission change time with the same value", func() { @@ -215,15 +215,15 @@ var _ = Describe("msg_server_update_commission.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) // wait for update s.CommitAfterSeconds(s.App().StakersKeeper.GetCommissionChangeTime(s.Ctx())) s.CommitAfterSeconds(1) - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.Commission).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) }) It("Update commission with multiple pools", func() { diff --git a/x/stakers/keeper/msg_server_update_stake_fraction_test.go b/x/stakers/keeper/msg_server_update_stake_fraction_test.go index c4327ba4..a27ba4bd 100644 --- a/x/stakers/keeper/msg_server_update_stake_fraction_test.go +++ b/x/stakers/keeper/msg_server_update_stake_fraction_test.go @@ -70,8 +70,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { It("Get the default stake fraction from a newly joined pool", func() { // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(10 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(10 * i.KYVE)) }) @@ -86,8 +86,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.5"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.5"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(50 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(50 * i.KYVE)) }) @@ -102,16 +102,16 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(10 * i.KYVE)) // wait for update s.CommitAfterSeconds(s.App().StakersKeeper.GetStakeFractionChangeTime(s.Ctx())) s.CommitAfterSeconds(1) - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0"))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(BeZero()) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(BeZero()) }) @@ -126,8 +126,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(10 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(10 * i.KYVE)) @@ -135,8 +135,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.CommitAfterSeconds(s.App().StakersKeeper.GetStakeFractionChangeTime(s.Ctx())) s.CommitAfterSeconds(1) - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.01"))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.01"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(1 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(1 * i.KYVE)) }) @@ -151,8 +151,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(100 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(100 * i.KYVE)) }) @@ -167,8 +167,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(10 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(10 * i.KYVE)) }) @@ -183,8 +183,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(10 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(10 * i.KYVE)) }) @@ -199,8 +199,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(10 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(10 * i.KYVE)) }) @@ -222,8 +222,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.2"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.2"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(20 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(20 * i.KYVE)) @@ -231,8 +231,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.CommitAfterSeconds(s.App().StakersKeeper.GetCommissionChangeTime(s.Ctx())) s.CommitAfterSeconds(1) - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.2"))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.2"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(20 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(20 * i.KYVE)) }) @@ -254,8 +254,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.PerformValidityChecks() // ASSERT - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(10 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(10 * i.KYVE)) @@ -263,8 +263,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.CommitAfterSeconds(s.App().StakersKeeper.GetCommissionChangeTime(s.Ctx())) s.CommitAfterSeconds(1) - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.01"))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.01"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(1 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(1 * i.KYVE)) }) @@ -277,8 +277,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { StakeFraction: math.LegacyMustNewDecFromStr("0.5"), }) - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.5"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.5"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(50 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(50 * i.KYVE)) @@ -292,8 +292,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { }) // ASSERT - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.5"))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.5"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(50 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(50 * i.KYVE)) @@ -301,8 +301,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.CommitAfterSeconds(s.App().StakersKeeper.GetCommissionChangeTime(s.Ctx())) s.CommitAfterSeconds(1) - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.02"))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.02"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(2 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(2 * i.KYVE)) }) @@ -370,8 +370,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { It("Validator stake increases while stake fraction stays the same", func() { // ARRANGE - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(10 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(10 * i.KYVE)) @@ -379,16 +379,16 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.SelfDelegateValidator(i.STAKER_0, 50*i.KYVE) // ASSERT - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(15 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(15 * i.KYVE)) }) It("Validator stake decreases while stake fraction stays the same", func() { // ARRANGE - valaccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ := s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(10 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(10 * i.KYVE)) @@ -401,8 +401,8 @@ var _ = Describe("msg_server_update_stake_fraction.go", Ordered, func() { s.CommitAfterSeconds(1) // ASSERT - valaccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) - Expect(valaccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) + poolAccount, _ = s.App().StakersKeeper.GetPoolAccount(s.Ctx(), i.STAKER_0, 0) + Expect(poolAccount.StakeFraction).To(Equal(math.LegacyMustNewDecFromStr("0.1"))) Expect(s.App().StakersKeeper.GetValidatorPoolStake(s.Ctx(), i.STAKER_0, 0)).To(Equal(5 * i.KYVE)) Expect(s.App().StakersKeeper.GetTotalStakeOfPool(s.Ctx(), 0)).To(Equal(5 * i.KYVE)) }) diff --git a/x/stakers/spec/01_concepts.md b/x/stakers/spec/01_concepts.md index b163b81d..0ca366df 100644 --- a/x/stakers/spec/01_concepts.md +++ b/x/stakers/spec/01_concepts.md @@ -27,15 +27,15 @@ Additionally, a staker can specify a commission. However, this takes `CommissionChangeTime` seconds of time before the change is applied. ## Valaccounts -To join a pool the user creates a valaccount for this pool. -The existence of a valaccount (for a pool) means that the staker +To join a pool the user creates a pool account for this pool. +The existence of a pool account (for a pool) means that the staker is a member of the given pool and needs to comply with the protocol in order to not get slashed. -A valaccount consists of the poolId a valaddress and a points counter. -The valaddress is the address of the protocol node which is allowed +A pool account consists of the poolId a pool account and a points counter. +The pool address is the address of the protocol node which is allowed to vote in favor of the staker. For certain types of misbehavior (e.g. being offline) a staker collects points. These are also -stored in the valaccount. +stored in the poolAccount. If a staker wants to leave a pool, a queue entry must be created. After `LeavePoolTime` seconds of time the actual leaving is performed and the diff --git a/x/stakers/spec/02_state.md b/x/stakers/spec/02_state.md index 493bb8fd..9058e448 100644 --- a/x/stakers/spec/02_state.md +++ b/x/stakers/spec/02_state.md @@ -24,30 +24,30 @@ type Staker struct { } ``` -## Valaccount -The Valaccount represents the membership of the staker in a given pool. +## PoolAccount +The PoolAccount represents the membership of the staker in a given pool. It contains the address of the protocol node which is allowed to vote in favor of the staker and stores the poolId as well as a counter for penalty-points. -- Valaccount: `0x02 | 0x00 | PoolId | StakerAddr -> ProtocolBuffer(valaccount)` +- PoolAccount: `0x02 | 0x00 | PoolId | StakerAddr -> ProtocolBuffer(poolAccount)` One additional index is maintained to query for all valaccounts of a staker. For this index only the key is used as StakerAddr and PoolId contain all -information to fetch the valaccount using the main key. +information to fetch the pool account using the main key. - ValaccountIndex2: `0x02 | 0x01 | StakerAddr | PoolId -> (empty)` ```go -type Valaccount struct { +type PoolAccount struct { // PoolId defines the pool in which the address // is allowed to vote in. PoolId uint64 - // Staker is the address the valaccount is voting for. + // Staker is the address the pool account is voting for. Staker string - // valaddress is the account stored on the protocol + // pool address is the account stored on the protocol // node which votes for the staker in the given pool - Valaddress string + PoolAccount string // When a node is inactive (does not vote at all) // a point is added. After a certain amount of points // is reached, the node gets kicked out. diff --git a/x/stakers/spec/03_messages.md b/x/stakers/spec/03_messages.md index f9aac8df..660751cb 100644 --- a/x/stakers/spec/03_messages.md +++ b/x/stakers/spec/03_messages.md @@ -37,7 +37,7 @@ This message allows a staker to join a pool. For joining a pool, the staker must provide the poolId and an address which is operated by the protocol node. This address is allowed to vote in favor of the staker. If this address misbehaves, the staker will get slashed. The message also takes an amount as an argument -which is transferred to the valaddress. The valaddress needs a small balance to +which is transferred to the pool address. The pool address needs a small balance to pay for fees. ## `MsgLeavePoolResponse` @@ -47,5 +47,5 @@ pool queue. Nothing else happens after that. The upcoming pool leave is shown in the staker query. So that delegators can see that the given staker is about to leave the given pool. -After the `LeavePoolTime` has passed the valaccount is deleted and the staker +After the `LeavePoolTime` has passed the pool account is deleted and the staker can shut down the protocol node. \ No newline at end of file diff --git a/x/stakers/spec/05_events.md b/x/stakers/spec/05_events.md index eae7d6bf..e841c1e3 100644 --- a/x/stakers/spec/05_events.md +++ b/x/stakers/spec/05_events.md @@ -117,10 +117,10 @@ message EventJoinPool { uint64 pool_id = 1; // staker is the address of the staker string staker = 2; - // valaddress is the address of the protocol node which + // pool address is the address of the protocol node which // votes in favor of the staker - string valaddress = 3; - // amount is the amount of funds transferred to the valaddress + string pool address = 3; + // amount is the amount of funds transferred to the pool address uint64 amount = 4; } ``` diff --git a/x/stakers/spec/07_exported.md b/x/stakers/spec/07_exported.md index 89edc1b2..17172101 100644 --- a/x/stakers/spec/07_exported.md +++ b/x/stakers/spec/07_exported.md @@ -16,18 +16,18 @@ type StakersKeeper interface { LeavePool(ctx sdk.Context, staker string, poolId uint64) // GetAllStakerAddressesOfPool returns a list of all stakers - // which have currently a valaccount registered for the given pool + // which have currently a pool account registered for the given pool // and are therefore allowed to participate in that pool. GetAllStakerAddressesOfPool(ctx sdk.Context, poolId uint64) (stakers []string) // GetCommission returns the commission of a staker as a parsed sdk.Dec GetCommission(ctx sdk.Context, stakerAddress string) sdk.Dec - // AssertValaccountAuthorized checks if the given `valaddress` is allowed to vote in pool + // AssertValaccountAuthorized checks if the given `pool address` is allowed to vote in pool // with id `poolId` to vote in favor of `stakerAddress`. - // If the valaddress is not authorized the appropriate error is returned. + // If the pool address is not authorized the appropriate error is returned. // Otherwise, it returns `nil` - AssertValaccountAuthorized(ctx sdk.Context, poolId uint64, stakerAddress string, valaddress string) error + AssertValaccountAuthorized(ctx sdk.Context, poolId uint64, stakerAddress string, pool address string) error // GetActiveStakers returns all staker-addresses that are // currently participating in at least one pool. diff --git a/x/stakers/types/errors.go b/x/stakers/types/errors.go index 39fa0813..ee8493d6 100644 --- a/x/stakers/types/errors.go +++ b/x/stakers/types/errors.go @@ -11,16 +11,16 @@ var ( ErrNoStaker = errors.Register(ModuleName, 1105, "sender is no staker") ErrAlreadyJoinedPool = errors.Register(ModuleName, 1106, "already joined pool") ErrAlreadyLeftPool = errors.Register(ModuleName, 1107, "already left pool") - PoolAddressAlreadyUsed = errors.Register(ModuleName, 1108, "valaddress already used") + PoolAddressAlreadyUsed = errors.Register(ModuleName, 1108, "pool address already used") ErrStringMaxLengthExceeded = errors.Register(ModuleName, 1109, "String length exceeded: %d vs %d") ErrStakerAlreadyCreated = errors.Register(ModuleName, 1110, "Staker already created") - ErrPoolAddressSameAsStaker = errors.Register(ModuleName, 1111, "Valaddress has same address as Valaddress") + ErrPoolAddressSameAsStaker = errors.Register(ModuleName, 1111, "Pool address has same address as validator") ErrCanNotJoinDisabledPool = errors.Register(ModuleName, 1112, "can not join disabled pool") ErrInvalidIdentityString = errors.Register(ModuleName, 1113, "invalid identity: %s") ErrNotEnoughRewards = errors.Register(ModuleName, 1114, "claim amount is larger than current rewards") ErrPoolLeaveAlreadyInProgress = errors.Register(ModuleName, 1117, "Pool leave is already in progress") - ErrPoolAccountUnauthorized = errors.Register(ModuleName, 1118, "valaccount unauthorized") + ErrPoolAccountUnauthorized = errors.Register(ModuleName, 1118, "pool account unauthorized") ErrValidatorJailed = errors.Register(ModuleName, 1119, "validator jailed") - ErrNoPoolAccount = errors.Register(ModuleName, 1120, "sender has no valaccount") + ErrNoPoolAccount = errors.Register(ModuleName, 1120, "sender has no pool account") ) diff --git a/x/stakers/types/genesis.go b/x/stakers/types/genesis.go index d10dd005..5b3fd1ce 100644 --- a/x/stakers/types/genesis.go +++ b/x/stakers/types/genesis.go @@ -21,7 +21,7 @@ func (gs GenesisState) Validate() error { for _, elem := range gs.PoolAccountList { index := string(PoolAccountKey(elem.PoolId, elem.Staker)) if _, ok := valaccountMap[index]; ok { - return fmt.Errorf("duplicated index for valaccount %v", elem) + return fmt.Errorf("duplicated index for pool account %v", elem) } valaccountMap[index] = struct{}{} stakerLeaving[index] = elem.IsLeaving diff --git a/x/stakers/types/keys.go b/x/stakers/types/keys.go index 0213d9d0..aee4c020 100644 --- a/x/stakers/types/keys.go +++ b/x/stakers/types/keys.go @@ -28,7 +28,7 @@ var ( // key -> StakerKeyPrefix | StakerKeyPrefix = []byte{1} - // PoolAccountPrefix stores valaccount for each staker and pool + // PoolAccountPrefix stores pool account for each staker and pool // PoolAccountPrefix | | PoolAccountPrefix = []byte{2, 0} // PoolAccountPrefixIndex2 | |