refactor(distribution)!: use collections for DelegatorStartingInfo state (#16483)

Co-authored-by: unknown unknown <unknown@unknown>
This commit is contained in:
testinginprod
2023-06-14 10:39:11 +00:00
committed by GitHub
co-authored by unknown unknown
parent bbb452f609
commit b3da8bb4e8
13 changed files with 51 additions and 132 deletions
@@ -6,6 +6,7 @@ import (
"testing"
"time"
"cosmossdk.io/collections"
"cosmossdk.io/depinject"
sdklog "cosmossdk.io/log"
"cosmossdk.io/math"
@@ -201,7 +202,7 @@ func (s *SimTestSuite) TestSimulateMsgCancelUnbondingDelegation() {
delegator := s.accounts[2]
delegation := types.NewDelegation(delegator.Address, validator0.GetOperator(), issuedShares)
s.stakingKeeper.SetDelegation(ctx, delegation)
s.distrKeeper.SetDelegatorStartingInfo(ctx, validator0.GetOperator(), delegator.Address, distrtypes.NewDelegatorStartingInfo(2, math.LegacyOneDec(), 200))
s.Require().NoError(s.distrKeeper.DelegatorStartingInfo.Set(ctx, collections.Join(validator0.GetOperator(), delegator.Address), distrtypes.NewDelegatorStartingInfo(2, math.LegacyOneDec(), 200)))
s.setupValidatorRewards(ctx, validator0.GetOperator())
@@ -293,7 +294,7 @@ func (s *SimTestSuite) TestSimulateMsgUndelegate() {
delegator := s.accounts[2]
delegation := types.NewDelegation(delegator.Address, validator0.GetOperator(), issuedShares)
s.stakingKeeper.SetDelegation(ctx, delegation)
s.distrKeeper.SetDelegatorStartingInfo(ctx, validator0.GetOperator(), delegator.Address, distrtypes.NewDelegatorStartingInfo(2, math.LegacyOneDec(), 200))
s.Require().NoError(s.distrKeeper.DelegatorStartingInfo.Set(ctx, collections.Join(validator0.GetOperator(), delegator.Address), distrtypes.NewDelegatorStartingInfo(2, math.LegacyOneDec(), 200)))
s.setupValidatorRewards(ctx, validator0.GetOperator())
@@ -334,12 +335,13 @@ func (s *SimTestSuite) TestSimulateMsgBeginRedelegate() {
delegator := s.accounts[3]
delegation := types.NewDelegation(delegator.Address, validator0.GetOperator(), issuedShares)
s.stakingKeeper.SetDelegation(ctx, delegation)
s.distrKeeper.SetDelegatorStartingInfo(ctx, validator0.GetOperator(), delegator.Address, distrtypes.NewDelegatorStartingInfo(2, math.LegacyOneDec(), 200))
s.Require().NoError(s.distrKeeper.DelegatorStartingInfo.Set(ctx, collections.Join(validator0.GetOperator(), delegator.Address), distrtypes.NewDelegatorStartingInfo(2, math.LegacyOneDec(), 200)))
s.setupValidatorRewards(ctx, validator0.GetOperator())
s.setupValidatorRewards(ctx, validator1.GetOperator())
s.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash, Time: blockTime})
_, err := s.app.FinalizeBlock(&abci.RequestFinalizeBlock{Height: s.app.LastBlockHeight() + 1, Hash: s.app.LastCommitID().Hash, Time: blockTime})
s.Require().NoError(err)
// execute operation
op := simulation.SimulateMsgBeginRedelegate(s.txConfig, s.accountKeeper, s.bankKeeper, s.stakingKeeper)