refactor(bank, feegrant, authz): avoid creating baseaccount (#19188)
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
co-authored by
Aleksandr Bezobchuk
parent
26d30f2111
commit
869c96c403
@@ -136,8 +136,6 @@ func TestBaseApp_BlockGas(t *testing.T) {
|
||||
err = bankKeeper.SendCoinsFromModuleToAccount(ctx, testutil.MintModuleName, addr1, feeAmount)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, feeCoin.Amount, bankKeeper.GetBalance(ctx, addr1, feeCoin.Denom).Amount)
|
||||
seq := accountKeeper.GetAccount(ctx, addr1).GetSequence()
|
||||
require.Equal(t, uint64(0), seq)
|
||||
|
||||
// msg and signatures
|
||||
msg := &baseapptestutil.MsgKeyValue{
|
||||
@@ -152,8 +150,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
|
||||
txBuilder.SetFeeAmount(feeAmount)
|
||||
txBuilder.SetGasLimit(uint64(simtestutil.DefaultConsensusParams.Block.MaxGas))
|
||||
|
||||
senderAccountNumber := accountKeeper.GetAccount(ctx, addr1).GetAccountNumber()
|
||||
privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{senderAccountNumber}, []uint64{0}
|
||||
privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0}
|
||||
_, txBytes, err := createTestTx(txConfig, txBuilder, privs, accNums, accSeqs, ctx.ChainID())
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -176,7 +173,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
|
||||
require.Equal(t, []byte("ok"), okValue)
|
||||
}
|
||||
// check block gas is always consumed
|
||||
baseGas := uint64(38798) // baseGas is the gas consumed before tx msg
|
||||
baseGas := uint64(38012) // baseGas is the gas consumed before tx msg
|
||||
expGasConsumed := addUint64Saturating(tc.gasToConsume, baseGas)
|
||||
if expGasConsumed > uint64(simtestutil.DefaultConsensusParams.Block.MaxGas) {
|
||||
// capped by gasLimit
|
||||
@@ -186,7 +183,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
|
||||
// tx fee is always deducted
|
||||
require.Equal(t, int64(0), bankKeeper.GetBalance(ctx, addr1, feeCoin.Denom).Amount.Int64())
|
||||
// sender's sequence is always increased
|
||||
seq = accountKeeper.GetAccount(ctx, addr1).GetSequence()
|
||||
seq := accountKeeper.GetAccount(ctx, addr1).GetSequence()
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, uint64(1), seq)
|
||||
})
|
||||
|
||||
@@ -224,7 +224,7 @@ func TestGRPCQuerySpendableBalances(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
|
||||
req := banktypes.NewQuerySpendableBalancesRequest(addr1, nil)
|
||||
testdata.DeterministicIterations(t, f.ctx, req, f.queryClient.SpendableBalances, 2032, false)
|
||||
testdata.DeterministicIterations(t, f.ctx, req, f.queryClient.SpendableBalances, 1777, false)
|
||||
}
|
||||
|
||||
func TestGRPCQueryTotalSupply(t *testing.T) {
|
||||
|
||||
@@ -95,7 +95,7 @@ func TestGRPCValidatorOutstandingRewards(t *testing.T) {
|
||||
// send funds to val addr
|
||||
funds := f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, int64(1000))
|
||||
assert.NilError(t, f.bankKeeper.SendCoinsFromModuleToAccount(f.sdkCtx, types.ModuleName, sdk.AccAddress(f.valAddr), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, funds))))
|
||||
|
||||
f.accountKeeper.SetAccount(f.sdkCtx, f.accountKeeper.NewAccountWithAddress(f.sdkCtx, sdk.AccAddress(f.valAddr)))
|
||||
initialStake := int64(10)
|
||||
tstaking := stakingtestutil.NewHelper(t, f.sdkCtx, f.stakingKeeper)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
@@ -167,7 +167,7 @@ func TestGRPCValidatorCommission(t *testing.T) {
|
||||
// send funds to val addr
|
||||
funds := f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, int64(1000))
|
||||
assert.NilError(t, f.bankKeeper.SendCoinsFromModuleToAccount(f.sdkCtx, types.ModuleName, sdk.AccAddress(f.valAddr), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, funds))))
|
||||
|
||||
f.accountKeeper.SetAccount(f.sdkCtx, f.accountKeeper.NewAccountWithAddress(f.sdkCtx, sdk.AccAddress(f.valAddr)))
|
||||
initialStake := int64(10)
|
||||
tstaking := stakingtestutil.NewHelper(t, f.sdkCtx, f.stakingKeeper)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
@@ -498,7 +498,7 @@ func TestGRPCDelegationRewards(t *testing.T) {
|
||||
// send funds to val addr
|
||||
funds := f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, int64(1000))
|
||||
assert.NilError(t, f.bankKeeper.SendCoinsFromModuleToAccount(f.sdkCtx, types.ModuleName, sdk.AccAddress(f.valAddr), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, funds))))
|
||||
|
||||
f.accountKeeper.SetAccount(f.sdkCtx, f.accountKeeper.NewAccountWithAddress(f.sdkCtx, sdk.AccAddress(f.valAddr)))
|
||||
initialStake := int64(10)
|
||||
tstaking := stakingtestutil.NewHelper(t, f.sdkCtx, f.stakingKeeper)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
|
||||
@@ -910,6 +910,7 @@ func TestMsgDepositValidatorRewardsPool(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
// send funds from module to addr to perform DepositValidatorRewardsPool
|
||||
err = f.bankKeeper.SendCoinsFromModuleToAccount(f.sdkCtx, distrtypes.ModuleName, addr, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, tokens)))
|
||||
f.accountKeeper.SetAccount(f.sdkCtx, f.accountKeeper.NewAccountWithAddress(f.sdkCtx, sdk.AccAddress(valAddr1)))
|
||||
require.NoError(t, err)
|
||||
tstaking := stakingtestutil.NewHelper(t, f.sdkCtx, f.stakingKeeper)
|
||||
tstaking.Commission = stakingtypes.NewCommissionRates(math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDec(0))
|
||||
|
||||
@@ -75,6 +75,7 @@ type fixture struct {
|
||||
sdkCtx sdk.Context
|
||||
cdc codec.Codec
|
||||
|
||||
accountKeeper authkeeper.AccountKeeper
|
||||
bankKeeper bankkeeper.Keeper
|
||||
evidenceKeeper *keeper.Keeper
|
||||
slashingKeeper slashingkeeper.Keeper
|
||||
@@ -164,6 +165,7 @@ func initFixture(tb testing.TB) *fixture {
|
||||
app: integrationApp,
|
||||
sdkCtx: sdkCtx,
|
||||
cdc: cdc,
|
||||
accountKeeper: accountKeeper,
|
||||
bankKeeper: bankKeeper,
|
||||
evidenceKeeper: evidenceKeeper,
|
||||
slashingKeeper: slashingKeeper,
|
||||
@@ -183,7 +185,7 @@ func TestHandleDoubleSign(t *testing.T) {
|
||||
assert.NilError(t, err)
|
||||
operatorAddr, valpubkey := valAddresses[0], pubkeys[0]
|
||||
tstaking := stakingtestutil.NewHelper(t, ctx, f.stakingKeeper)
|
||||
|
||||
f.accountKeeper.SetAccount(f.sdkCtx, f.accountKeeper.NewAccountWithAddress(f.sdkCtx, sdk.AccAddress(operatorAddr)))
|
||||
selfDelegation := tstaking.CreateValidatorWithValPower(operatorAddr, valpubkey, power, true)
|
||||
|
||||
// execute end-blocker and verify validator attributes
|
||||
@@ -278,7 +280,7 @@ func TestHandleDoubleSign_TooOld(t *testing.T) {
|
||||
operatorAddr, valpubkey := valAddresses[0], pubkeys[0]
|
||||
|
||||
tstaking := stakingtestutil.NewHelper(t, ctx, f.stakingKeeper)
|
||||
|
||||
f.accountKeeper.SetAccount(f.sdkCtx, f.accountKeeper.NewAccountWithAddress(f.sdkCtx, sdk.AccAddress(operatorAddr)))
|
||||
amt := tstaking.CreateValidatorWithValPower(operatorAddr, valpubkey, power, true)
|
||||
|
||||
// execute end-blocker and verify validator attributes
|
||||
@@ -328,7 +330,7 @@ func TestHandleDoubleSignAfterRotation(t *testing.T) {
|
||||
|
||||
operatorAddr, valpubkey := valAddresses[0], pubkeys[0]
|
||||
tstaking := stakingtestutil.NewHelper(t, ctx, f.stakingKeeper)
|
||||
|
||||
f.accountKeeper.SetAccount(f.sdkCtx, f.accountKeeper.NewAccountWithAddress(f.sdkCtx, sdk.AccAddress(operatorAddr)))
|
||||
selfDelegation := tstaking.CreateValidatorWithValPower(operatorAddr, valpubkey, power, true)
|
||||
|
||||
// execute end-blocker and verify validator attributes
|
||||
|
||||
@@ -360,6 +360,8 @@ func TestProposalPassedEndblocker(t *testing.T) {
|
||||
stakingMsgSvr := stakingkeeper.NewMsgServerImpl(suite.StakingKeeper)
|
||||
valAddr := sdk.ValAddress(addrs[0])
|
||||
proposer := addrs[0]
|
||||
acc := suite.AccountKeeper.NewAccountWithAddress(ctx, addrs[0])
|
||||
suite.AccountKeeper.SetAccount(ctx, acc)
|
||||
|
||||
createValidators(t, stakingMsgSvr, ctx, []sdk.ValAddress{valAddr}, []int64{10})
|
||||
_, err := suite.StakingKeeper.EndBlocker(ctx)
|
||||
@@ -421,6 +423,9 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) {
|
||||
toAddrStr, err := ac.BytesToString(addrs[0])
|
||||
require.NoError(t, err)
|
||||
|
||||
acc := suite.AccountKeeper.NewAccountWithAddress(ctx, addrs[0])
|
||||
suite.AccountKeeper.SetAccount(ctx, acc)
|
||||
|
||||
createValidators(t, stakingMsgSvr, ctx, []sdk.ValAddress{valAddr}, []int64{10})
|
||||
_, err = suite.StakingKeeper.EndBlocker(ctx)
|
||||
require.NoError(t, err)
|
||||
@@ -499,6 +504,8 @@ func TestExpeditedProposal_PassAndConversionToRegular(t *testing.T) {
|
||||
valAddr := sdk.ValAddress(addrs[0])
|
||||
proposer := addrs[0]
|
||||
|
||||
acc := suite.AccountKeeper.NewAccountWithAddress(ctx, addrs[0])
|
||||
suite.AccountKeeper.SetAccount(ctx, acc)
|
||||
// Create a validator so that able to vote on proposal.
|
||||
createValidators(t, stakingMsgSvr, ctx, []sdk.ValAddress{valAddr}, []int64{10})
|
||||
_, err = suite.StakingKeeper.EndBlocker(ctx)
|
||||
|
||||
@@ -58,6 +58,10 @@ func createValidators(t *testing.T, f *fixture, powers []int64) ([]sdk.AccAddres
|
||||
assert.NilError(t, f.stakingKeeper.SetNewValidatorByPowerIndex(f.ctx, val2))
|
||||
assert.NilError(t, f.stakingKeeper.SetNewValidatorByPowerIndex(f.ctx, val3))
|
||||
|
||||
for _, addr := range addrs {
|
||||
f.accountKeeper.SetAccount(f.ctx, f.accountKeeper.NewAccountWithAddress(f.ctx, addr))
|
||||
}
|
||||
|
||||
_, _ = f.stakingKeeper.Delegate(f.ctx, addrs[0], f.stakingKeeper.TokensFromConsensusPower(f.ctx, powers[0]), stakingtypes.Unbonded, val1, true)
|
||||
_, _ = f.stakingKeeper.Delegate(f.ctx, addrs[1], f.stakingKeeper.TokensFromConsensusPower(f.ctx, powers[1]), stakingtypes.Unbonded, val2, true)
|
||||
_, _ = f.stakingKeeper.Delegate(f.ctx, addrs[2], f.stakingKeeper.TokensFromConsensusPower(f.ctx, powers[2]), stakingtypes.Unbonded, val3, true)
|
||||
|
||||
@@ -41,6 +41,7 @@ type fixture struct {
|
||||
queryClient v1.QueryClient
|
||||
legacyQueryClient v1beta1.QueryClient
|
||||
|
||||
accountKeeper authkeeper.AccountKeeper
|
||||
bankKeeper bankkeeper.Keeper
|
||||
stakingKeeper *stakingkeeper.Keeper
|
||||
govKeeper *keeper.Keeper
|
||||
@@ -153,6 +154,7 @@ func initFixture(tb testing.TB) *fixture {
|
||||
ctx: sdkCtx,
|
||||
queryClient: queryClient,
|
||||
legacyQueryClient: legacyQueryClient,
|
||||
accountKeeper: accountKeeper,
|
||||
bankKeeper: bankKeeper,
|
||||
stakingKeeper: stakingKeeper,
|
||||
govKeeper: govKeeper,
|
||||
|
||||
@@ -356,7 +356,6 @@ func TestTallyDelgatorMultipleOverride(t *testing.T) {
|
||||
assert.Assert(t, found)
|
||||
val2, found := f.stakingKeeper.GetValidator(ctx, vals[1])
|
||||
assert.Assert(t, found)
|
||||
|
||||
_, err := f.stakingKeeper.Delegate(ctx, addrs[3], delTokens, stakingtypes.Unbonded, val1, true)
|
||||
assert.NilError(t, err)
|
||||
_, err = f.stakingKeeper.Delegate(ctx, addrs[3], delTokens, stakingtypes.Unbonded, val2, true)
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"cosmossdk.io/core/comet"
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/log"
|
||||
authkeeper "cosmossdk.io/x/auth/keeper"
|
||||
bankkeeper "cosmossdk.io/x/bank/keeper"
|
||||
"cosmossdk.io/x/slashing"
|
||||
slashingkeeper "cosmossdk.io/x/slashing/keeper"
|
||||
@@ -24,6 +25,7 @@ import (
|
||||
func TestBeginBlocker(t *testing.T) {
|
||||
var (
|
||||
interfaceRegistry codectypes.InterfaceRegistry
|
||||
accountKeeper authkeeper.AccountKeeper
|
||||
bankKeeper bankkeeper.Keeper
|
||||
stakingKeeper *stakingkeeper.Keeper
|
||||
slashingKeeper slashingkeeper.Keeper
|
||||
@@ -35,6 +37,7 @@ func TestBeginBlocker(t *testing.T) {
|
||||
depinject.Supply(log.NewNopLogger()),
|
||||
),
|
||||
&interfaceRegistry,
|
||||
&accountKeeper,
|
||||
&bankKeeper,
|
||||
&stakingKeeper,
|
||||
&slashingKeeper,
|
||||
@@ -50,6 +53,8 @@ func TestBeginBlocker(t *testing.T) {
|
||||
|
||||
// bond the validator
|
||||
power := int64(100)
|
||||
acc := accountKeeper.NewAccountWithAddress(ctx, sdk.AccAddress(addr))
|
||||
accountKeeper.SetAccount(ctx, acc)
|
||||
amt := tstaking.CreateValidatorWithValPower(addr, pk, power, true)
|
||||
_, err = stakingKeeper.EndBlocker(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -41,6 +41,7 @@ type fixture struct {
|
||||
|
||||
ctx sdk.Context
|
||||
|
||||
accountKeeper authkeeper.AccountKeeper
|
||||
bankKeeper bankkeeper.Keeper
|
||||
slashingKeeper slashingkeeper.Keeper
|
||||
stakingKeeper *stakingkeeper.Keeper
|
||||
@@ -135,6 +136,7 @@ func initFixture(tb testing.TB) *fixture {
|
||||
return &fixture{
|
||||
app: integrationApp,
|
||||
ctx: sdkCtx,
|
||||
accountKeeper: accountKeeper,
|
||||
bankKeeper: bankKeeper,
|
||||
slashingKeeper: slashingKeeper,
|
||||
stakingKeeper: stakingKeeper,
|
||||
@@ -157,6 +159,8 @@ func TestUnJailNotBonded(t *testing.T) {
|
||||
// create max (5) validators all with the same power
|
||||
for i := uint32(0); i < p.MaxValidators; i++ {
|
||||
addr, val := f.valAddrs[i], pks[i]
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, sdk.AccAddress(addr))
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
tstaking.CreateValidatorWithValPower(addr, val, 100, true)
|
||||
}
|
||||
|
||||
@@ -166,6 +170,8 @@ func TestUnJailNotBonded(t *testing.T) {
|
||||
|
||||
// create a 6th validator with less power than the cliff validator (won't be bonded)
|
||||
addr, val := f.valAddrs[5], pks[5]
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, sdk.AccAddress(addr))
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
amt := f.stakingKeeper.TokensFromConsensusPower(f.ctx, 50)
|
||||
msg := tstaking.CreateValidatorMsg(addr, val, amt)
|
||||
msg.MinSelfDelegation = amt
|
||||
@@ -246,6 +252,8 @@ func TestHandleNewValidator(t *testing.T) {
|
||||
assert.NilError(t, f.slashingKeeper.ValidatorSigningInfo.Set(f.ctx, sdk.ConsAddress(valpubkey.Address()), info))
|
||||
|
||||
// Validator created
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, sdk.AccAddress(addr))
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
amt := tstaking.CreateValidatorWithValPower(addr, valpubkey, 100, true)
|
||||
|
||||
_, err = f.stakingKeeper.EndBlocker(f.ctx)
|
||||
@@ -303,6 +311,9 @@ func TestHandleAlreadyJailed(t *testing.T) {
|
||||
info := slashingtypes.NewValidatorSigningInfo(consaddr, f.ctx.BlockHeight(), int64(0), time.Unix(0, 0), false, int64(0))
|
||||
assert.NilError(t, f.slashingKeeper.ValidatorSigningInfo.Set(f.ctx, sdk.ConsAddress(val.Address()), info))
|
||||
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, sdk.AccAddress(addr))
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
|
||||
amt := tstaking.CreateValidatorWithValPower(addr, val, power, true)
|
||||
|
||||
_, err = f.stakingKeeper.EndBlocker(f.ctx)
|
||||
@@ -366,6 +377,10 @@ func TestValidatorDippingInAndOut(t *testing.T) {
|
||||
|
||||
pks := simtestutil.CreateTestPubKeys(3)
|
||||
simtestutil.AddTestAddrsFromPubKeys(f.bankKeeper, f.stakingKeeper, f.ctx, pks, f.stakingKeeper.TokensFromConsensusPower(f.ctx, 200))
|
||||
for _, pk := range pks {
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, sdk.AccAddress(pk.Address()))
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
}
|
||||
|
||||
addr, val := pks[0].Address(), pks[0]
|
||||
consAddr := sdk.ConsAddress(addr)
|
||||
|
||||
@@ -82,6 +82,11 @@ func createValidators(t *testing.T, f *fixture, powers []int64) ([]sdk.AccAddres
|
||||
assert.NilError(t, f.stakingKeeper.SetNewValidatorByPowerIndex(f.sdkCtx, val1))
|
||||
assert.NilError(t, f.stakingKeeper.SetNewValidatorByPowerIndex(f.sdkCtx, val2))
|
||||
|
||||
for _, addr := range addrs {
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.sdkCtx, addr)
|
||||
f.accountKeeper.SetAccount(f.sdkCtx, acc)
|
||||
}
|
||||
|
||||
_, err := f.stakingKeeper.Delegate(f.sdkCtx, addrs[0], f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, powers[0]), types.Unbonded, val1, true)
|
||||
assert.NilError(t, err)
|
||||
_, err = f.stakingKeeper.Delegate(f.sdkCtx, addrs[1], f.stakingKeeper.TokensFromConsensusPower(f.sdkCtx, powers[1]), types.Unbonded, val2, true)
|
||||
|
||||
@@ -95,6 +95,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) {
|
||||
|
||||
// mature unbonding delegations
|
||||
ctx = ctx.WithHeaderInfo(header.Info{Time: completionTime})
|
||||
acc := f.accountKeeper.NewAccountWithAddress(ctx, addrDel)
|
||||
f.accountKeeper.SetAccount(ctx, acc)
|
||||
_, err = f.stakingKeeper.CompleteUnbonding(ctx, addrDel, addrVal)
|
||||
assert.NilError(t, err)
|
||||
|
||||
|
||||
@@ -245,6 +245,9 @@ func setValidator(t *testing.T, f *deterministicFixture, validator stakingtypes.
|
||||
coins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, validator.BondedTokens()))
|
||||
assert.NilError(t, banktestutil.FundAccount(f.ctx, f.bankKeeper, delegatorAddress, coins))
|
||||
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddress)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
|
||||
_, err = f.stakingKeeper.Delegate(f.ctx, delegatorAddress, validator.BondedTokens(), stakingtypes.Unbonded, validator, true)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
@@ -396,6 +399,8 @@ func TestGRPCValidatorDelegations(t *testing.T) {
|
||||
|
||||
for i := 0; i < numDels; i++ {
|
||||
delegator := testdata.AddressGenerator(rt).Draw(rt, "delegator")
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegator)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
_, err := createDelegationAndDelegate(t, rt, f, delegator, validator)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
@@ -412,9 +417,13 @@ func TestGRPCValidatorDelegations(t *testing.T) {
|
||||
|
||||
validator := getStaticValidator(t, f)
|
||||
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddr1)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
_, err := fundAccountAndDelegate(t, f, delegatorAddr1, validator, f.amt1)
|
||||
assert.NilError(t, err)
|
||||
|
||||
acc = f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddr2)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
_, err = fundAccountAndDelegate(t, f, delegatorAddr2, validator, f.amt2)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -435,6 +444,8 @@ func TestGRPCValidatorUnbondingDelegations(t *testing.T) {
|
||||
|
||||
for i := 0; i < numDels; i++ {
|
||||
delegator := testdata.AddressGenerator(rt).Draw(rt, "delegator")
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegator)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
shares, err := createDelegationAndDelegate(t, rt, f, delegator, validator)
|
||||
assert.NilError(t, err)
|
||||
valbz, err := f.stakingKeeper.ValidatorAddressCodec().StringToBytes(validator.GetOperator())
|
||||
@@ -454,12 +465,16 @@ func TestGRPCValidatorUnbondingDelegations(t *testing.T) {
|
||||
f = initDeterministicFixture(t) // reset
|
||||
|
||||
validator := getStaticValidator(t, f)
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddr1)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
shares1, err := fundAccountAndDelegate(t, f, delegatorAddr1, validator, f.amt1)
|
||||
assert.NilError(t, err)
|
||||
|
||||
_, _, err = f.stakingKeeper.Undelegate(f.ctx, delegatorAddr1, validatorAddr1, shares1)
|
||||
assert.NilError(t, err)
|
||||
|
||||
acc = f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddr2)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
shares2, err := fundAccountAndDelegate(t, f, delegatorAddr2, validator, f.amt2)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -480,6 +495,8 @@ func TestGRPCDelegation(t *testing.T) {
|
||||
rapid.Check(t, func(rt *rapid.T) {
|
||||
validator := createAndSetValidatorWithStatus(t, rt, f, stakingtypes.Bonded)
|
||||
delegator := testdata.AddressGenerator(rt).Draw(rt, "delegator")
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegator)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
_, err := createDelegationAndDelegate(t, rt, f, delegator, validator)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -494,6 +511,8 @@ func TestGRPCDelegation(t *testing.T) {
|
||||
f = initDeterministicFixture(t) // reset
|
||||
|
||||
validator := getStaticValidator(t, f)
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddr1)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
_, err := fundAccountAndDelegate(t, f, delegatorAddr1, validator, f.amt1)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -512,6 +531,8 @@ func TestGRPCUnbondingDelegation(t *testing.T) {
|
||||
rapid.Check(t, func(rt *rapid.T) {
|
||||
validator := createAndSetValidatorWithStatus(t, rt, f, stakingtypes.Bonded)
|
||||
delegator := testdata.AddressGenerator(rt).Draw(rt, "delegator")
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegator)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
shares, err := createDelegationAndDelegate(t, rt, f, delegator, validator)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -531,6 +552,8 @@ func TestGRPCUnbondingDelegation(t *testing.T) {
|
||||
f = initDeterministicFixture(t) // reset
|
||||
validator := getStaticValidator(t, f)
|
||||
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddr1)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
shares1, err := fundAccountAndDelegate(t, f, delegatorAddr1, validator, f.amt1)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -555,6 +578,8 @@ func TestGRPCDelegatorDelegations(t *testing.T) {
|
||||
|
||||
for i := 0; i < numVals; i++ {
|
||||
validator := createAndSetValidatorWithStatus(t, rt, f, stakingtypes.Bonded)
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegator)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
_, err := createDelegationAndDelegate(t, rt, f, delegator, validator)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
@@ -570,6 +595,8 @@ func TestGRPCDelegatorDelegations(t *testing.T) {
|
||||
f = initDeterministicFixture(t) // reset
|
||||
|
||||
validator := getStaticValidator(t, f)
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddr1)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
_, err := fundAccountAndDelegate(t, f, delegatorAddr1, validator, f.amt1)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -588,6 +615,8 @@ func TestGRPCDelegatorValidator(t *testing.T) {
|
||||
validator := createAndSetValidatorWithStatus(t, rt, f, stakingtypes.Bonded)
|
||||
|
||||
delegator := testdata.AddressGenerator(rt).Draw(rt, "delegator")
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegator)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
_, err := createDelegationAndDelegate(t, rt, f, delegator, validator)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -602,6 +631,8 @@ func TestGRPCDelegatorValidator(t *testing.T) {
|
||||
f = initDeterministicFixture(t) // reset
|
||||
|
||||
validator := getStaticValidator(t, f)
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddr1)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
_, err := fundAccountAndDelegate(t, f, delegatorAddr1, validator, f.amt1)
|
||||
|
||||
assert.NilError(t, err)
|
||||
@@ -624,6 +655,8 @@ func TestGRPCDelegatorUnbondingDelegations(t *testing.T) {
|
||||
|
||||
for i := 0; i < numVals; i++ {
|
||||
validator := createAndSetValidatorWithStatus(t, rt, f, stakingtypes.Bonded)
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegator)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
shares, err := createDelegationAndDelegate(t, rt, f, delegator, validator)
|
||||
assert.NilError(t, err)
|
||||
valbz, err := f.stakingKeeper.ValidatorAddressCodec().StringToBytes(validator.GetOperator())
|
||||
@@ -643,6 +676,8 @@ func TestGRPCDelegatorUnbondingDelegations(t *testing.T) {
|
||||
f = initDeterministicFixture(t) // reset
|
||||
|
||||
validator := getStaticValidator(t, f)
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddr1)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
shares1, err := fundAccountAndDelegate(t, f, delegatorAddr1, validator, f.amt1)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -707,6 +742,8 @@ func TestGRPCDelegatorValidators(t *testing.T) {
|
||||
|
||||
for i := 0; i < numVals; i++ {
|
||||
validator := createAndSetValidatorWithStatus(t, rt, f, stakingtypes.Bonded)
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegator)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
_, err := createDelegationAndDelegate(t, rt, f, delegator, validator)
|
||||
assert.NilError(t, err)
|
||||
}
|
||||
@@ -722,7 +759,8 @@ func TestGRPCDelegatorValidators(t *testing.T) {
|
||||
f = initDeterministicFixture(t) // reset
|
||||
|
||||
validator := getStaticValidator(t, f)
|
||||
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddr1)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
_, err := fundAccountAndDelegate(t, f, delegatorAddr1, validator, f.amt1)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -761,6 +799,8 @@ func TestGRPCRedelegations(t *testing.T) {
|
||||
numDels := rapid.IntRange(1, 5).Draw(rt, "num-dels")
|
||||
|
||||
delegator := testdata.AddressGenerator(rt).Draw(rt, "delegator")
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegator)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
shares, err := createDelegationAndDelegate(t, rt, f, delegator, validator)
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -795,6 +835,8 @@ func TestGRPCRedelegations(t *testing.T) {
|
||||
validator := getStaticValidator(t, f)
|
||||
_ = getStaticValidator2(t, f)
|
||||
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, delegatorAddr1)
|
||||
f.accountKeeper.SetAccount(f.ctx, acc)
|
||||
shares, err := fundAccountAndDelegate(t, f, delegatorAddr1, validator, f.amt1)
|
||||
assert.NilError(t, err)
|
||||
|
||||
|
||||
@@ -205,7 +205,8 @@ func TestRotateConsPubKey(t *testing.T) {
|
||||
// create 5 validators
|
||||
for i := 0; i < 5; i++ {
|
||||
comm := types.NewCommissionRates(math.LegacyNewDec(0), math.LegacyNewDec(0), math.LegacyNewDec(0))
|
||||
|
||||
acc := f.accountKeeper.NewAccountWithAddress(ctx, sdk.AccAddress(valAddrs[i]))
|
||||
f.accountKeeper.SetAccount(ctx, acc)
|
||||
msg, err := types.NewMsgCreateValidator(valAddrs[i].String(), PKs[i], sdk.NewCoin(sdk.DefaultBondDenom, stakingKeeper.TokensFromConsensusPower(ctx, 30)),
|
||||
types.Description{Moniker: "NewVal"}, comm, math.OneInt())
|
||||
assert.NilError(t, err)
|
||||
|
||||
@@ -384,6 +384,10 @@ func TestUnbondingDelegationOnHold1(t *testing.T) {
|
||||
|
||||
// _, app, ctx := createTestInput(t)
|
||||
bondDenom, addrDels, addrVals := SetupUnbondingTests(t, f, &hookCalled, &ubdeID)
|
||||
for _, addr := range addrDels {
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.sdkCtx, addr)
|
||||
f.accountKeeper.SetAccount(f.sdkCtx, acc)
|
||||
}
|
||||
completionTime, bondedAmt1, notBondedAmt1 := doUnbondingDelegation(t, f.stakingKeeper, f.bankKeeper, f.sdkCtx, bondDenom, addrDels, addrVals, &hookCalled)
|
||||
|
||||
// CONSUMER CHAIN'S UNBONDING PERIOD ENDS - BUT UNBONDING CANNOT COMPLETE
|
||||
@@ -423,6 +427,10 @@ func TestUnbondingDelegationOnHold2(t *testing.T) {
|
||||
|
||||
// _, app, ctx := createTestInput(t)
|
||||
bondDenom, addrDels, addrVals := SetupUnbondingTests(t, f, &hookCalled, &ubdeID)
|
||||
for _, addr := range addrDels {
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.sdkCtx, addr)
|
||||
f.accountKeeper.SetAccount(f.sdkCtx, acc)
|
||||
}
|
||||
completionTime, bondedAmt1, notBondedAmt1 := doUnbondingDelegation(t, f.stakingKeeper, f.bankKeeper, f.sdkCtx, bondDenom, addrDels, addrVals, &hookCalled)
|
||||
|
||||
// PROVIDER CHAIN'S UNBONDING PERIOD ENDS - BUT UNBONDING CANNOT COMPLETE
|
||||
|
||||
@@ -40,6 +40,8 @@ func TestValidateVoteExtensions(t *testing.T) {
|
||||
vals := []stakingtypes.Validator{}
|
||||
for _, v := range privKeys {
|
||||
valAddr := sdk.ValAddress(v.PubKey().Address())
|
||||
acc := f.accountKeeper.NewAccountWithAddress(f.sdkCtx, sdk.AccAddress(v.PubKey().Address()))
|
||||
f.accountKeeper.SetAccount(f.sdkCtx, acc)
|
||||
simtestutil.AddTestAddrsFromPubKeys(f.bankKeeper, f.stakingKeeper, f.sdkCtx, []cryptotypes.PubKey{v.PubKey()}, math.NewInt(100000000000))
|
||||
vals = append(vals, testutil.NewValidator(t, valAddr, v.PubKey()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user