Skip to content

Commit

Permalink
refactor!: use KVStoreService and context.Context in x/bank (#15891)
Browse files Browse the repository at this point in the history
  • Loading branch information
facundomedica committed Apr 26, 2023
1 parent e59c4a8 commit 6dfe735
Show file tree
Hide file tree
Showing 78 changed files with 605 additions and 523 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking Changes

* (x/bank) [#15891](https://github.com/cosmos/cosmos-sdk/issues/15891) `NewKeeper` now takes a `KVStoreService` instead of a `StoreKey` and methods in the `Keeper` now take a `context.Context` instead of a `sdk.Context`. Also `FundAccount` and `FundModuleAccount` from the `testutil` package accept a `context.Context` instead of a `sdk.Context`, and it's position was moved to the first place.
* (x/bank) [#15818](https://github.com/cosmos/cosmos-sdk/issues/15818) `BaseViewKeeper`'s `Logger` method now doesn't require a context. `NewBaseKeeper`, `NewBaseSendKeeper` and `NewBaseViewKeeper` now also require a `log.Logger` to be passed in.
* (client) [#15597](https://github.com/cosmos/cosmos-sdk/pull/15597) `RegisterNodeService` now requires a config parameter.
* (x/*all*) [#15648](https://github.com/cosmos/cosmos-sdk/issues/15648) Make `SetParams` consistent across all modules and validate the params at the message handling instead of `SetParams` method.
Expand Down
1 change: 1 addition & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ This is no longer the case, the assertion has been loosened to only require modu
The following modules `NewKeeper` function now take a `KVStoreService` instead of a `StoreKey`:

* `x/auth`
* `x/bank`
* `x/consensus`
* `x/feegrant`
* `x/nft`
Expand Down
2 changes: 1 addition & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func NewSimApp(

app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
keys[banktypes.StoreKey],
runtime.NewKVStoreService(keys[banktypes.StoreKey]),
app.AccountKeeper,
BlockedAddresses(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/bank/keeper/deterministic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func initDeterministicFixture(t *testing.T) *deterministicFixture {
}

func fundAccount(f *deterministicFixture, addr sdk.AccAddress, coin ...sdk.Coin) {
err := banktestutil.FundAccount(f.bankKeeper, f.ctx, addr, sdk.NewCoins(coin...))
err := banktestutil.FundAccount(f.ctx, f.bankKeeper, addr, sdk.NewCoins(coin...))
assert.NilError(&testing.T{}, err)
}

Expand Down Expand Up @@ -174,7 +174,7 @@ func TestGRPCQuerySpendableBalances(t *testing.T) {
coins = sdk.NewCoins(append(coins, coin)...)
}

err := banktestutil.FundAccount(f.bankKeeper, f.ctx, addr, coins)
err := banktestutil.FundAccount(f.ctx, f.bankKeeper, addr, coins)
assert.NilError(t, err)

req := banktypes.NewQuerySpendableBalancesRequest(addr, testdata.PaginationGenerator(rt, uint64(len(denoms))).Draw(rt, "pagination"))
Expand All @@ -186,7 +186,7 @@ func TestGRPCQuerySpendableBalances(t *testing.T) {
sdk.NewCoin("denom", sdk.NewInt(100)),
)

err := banktestutil.FundAccount(f.bankKeeper, f.ctx, addr1, coins)
err := banktestutil.FundAccount(f.ctx, f.bankKeeper, addr1, coins)
assert.NilError(t, err)

req := banktypes.NewQuerySpendableBalancesRequest(addr1, nil)
Expand Down Expand Up @@ -450,7 +450,7 @@ func TestGRPCDenomOwners(t *testing.T) {
sdk.NewInt(rapid.Int64Min(1).Draw(rt, "amount")),
)

err := banktestutil.FundAccount(f.bankKeeper, f.ctx, addr, sdk.NewCoins(coin))
err := banktestutil.FundAccount(f.ctx, f.bankKeeper, addr, sdk.NewCoins(coin))
assert.NilError(t, err)
}

Expand All @@ -476,7 +476,7 @@ func TestGRPCDenomOwners(t *testing.T) {
addr, err := sdk.AccAddressFromBech32(denomOwners[i].Address)
assert.NilError(t, err)

err = banktestutil.FundAccount(f.bankKeeper, f.ctx, addr, sdk.NewCoins(coin1))
err = banktestutil.FundAccount(f.ctx, f.bankKeeper, addr, sdk.NewCoins(coin1))
assert.NilError(t, err)
}

Expand Down
71 changes: 38 additions & 33 deletions tests/integration/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper_test

import (
"context"
"fmt"
"reflect"
"strings"
Expand Down Expand Up @@ -169,8 +170,10 @@ func initKeepersWithmAccPerms(f *fixture, blockedAddrs map[string]bool) (authkee
appCodec, storeService, authtypes.ProtoBaseAccount,
maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

bankStoreService := runtime.NewKVStoreService(f.fetchStoreKey(types.StoreKey).(*storetypes.KVStoreKey))
bankKeeper := keeper.NewBaseKeeper(
appCodec, f.fetchStoreKey(types.StoreKey), authKeeper, blockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String(), log.NewNopLogger(),
appCodec, bankStoreService, authKeeper, blockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String(), log.NewNopLogger(),
)

return authKeeper, bankKeeper
Expand Down Expand Up @@ -390,7 +393,7 @@ func TestSendCoinsNewAccount(t *testing.T) {
addr1 := sdk.AccAddress([]byte("addr1_______________"))
acc1 := f.accountKeeper.NewAccountWithAddress(ctx, addr1)
f.accountKeeper.SetAccount(ctx, acc1)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, balances))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, balances))

acc1Balances := f.bankKeeper.GetAllBalances(ctx, addr1)
assert.DeepEqual(t, balances, acc1Balances)
Expand Down Expand Up @@ -423,7 +426,7 @@ func TestInputOutputNewAccount(t *testing.T) {
addr1 := sdk.AccAddress([]byte("addr1_______________"))
acc1 := f.accountKeeper.NewAccountWithAddress(ctx, addr1)
f.accountKeeper.SetAccount(ctx, acc1)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, balances))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, balances))

acc1Balances := f.bankKeeper.GetAllBalances(ctx, addr1)
assert.DeepEqual(t, balances, acc1Balances)
Expand Down Expand Up @@ -478,7 +481,7 @@ func TestInputOutputCoins(t *testing.T) {
assert.Error(t, f.bankKeeper.InputOutputCoins(ctx, input, []types.Output{}), "sum inputs != sum outputs")
assert.Error(t, f.bankKeeper.InputOutputCoins(ctx, input, outputs), "spendable balance is smaller than 20bar: insufficient funds")

assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, balances))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, balances))

insufficientInput := types.Input{
Address: addr1.String(),
Expand Down Expand Up @@ -516,12 +519,12 @@ func TestSendCoins(t *testing.T) {
addr2 := sdk.AccAddress("addr2_______________")
acc2 := f.accountKeeper.NewAccountWithAddress(ctx, addr2)
f.accountKeeper.SetAccount(ctx, acc2)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr2, balances))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr2, balances))

sendAmt := sdk.NewCoins(newFooCoin(50), newBarCoin(25))
assert.Error(t, f.bankKeeper.SendCoins(ctx, addr1, addr2, sendAmt), "spendable balance is smaller than 25bar: insufficient funds")

assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, balances))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, balances))
assert.NilError(t, f.bankKeeper.SendCoins(ctx, addr1, addr2, sendAmt))

acc1Balances := f.bankKeeper.GetAllBalances(ctx, addr1)
Expand Down Expand Up @@ -560,14 +563,14 @@ func TestValidateBalance(t *testing.T) {
f.accountKeeper.SetAccount(ctx, acc)

balances := sdk.NewCoins(newFooCoin(100))
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, balances))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, balances))
assert.NilError(t, f.bankKeeper.ValidateBalance(ctx, addr1))

bacc := authtypes.NewBaseAccountWithAddress(addr2)
vacc := vesting.NewContinuousVestingAccount(bacc, balances.Add(balances...), now.Unix(), endTime.Unix())

f.accountKeeper.SetAccount(ctx, vacc)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr2, balances))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr2, balances))
assert.Error(t, f.bankKeeper.ValidateBalance(ctx, addr2), "vesting amount 200foo cannot be greater than total amount 100foo")
}

Expand All @@ -590,7 +593,7 @@ func TestSendCoins_Invalid_SendLockedCoins(t *testing.T) {
vacc := vesting.NewContinuousVestingAccount(acc0, origCoins, now.Unix(), endTime.Unix())
f.accountKeeper.SetAccount(ctx, vacc)

assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, f.ctx, addr2, balances))
assert.NilError(t, banktestutil.FundAccount(f.ctx, f.bankKeeper, addr2, balances))
assert.Error(t, f.bankKeeper.SendCoins(ctx, addr, addr2, sendCoins), fmt.Sprintf("locked amount exceeds account balance funds: %s > 0stake: insufficient funds", origCoins))
}

Expand Down Expand Up @@ -653,7 +656,7 @@ func TestHasBalance(t *testing.T) {
balances := sdk.NewCoins(newFooCoin(100))
assert.Assert(t, f.bankKeeper.HasBalance(ctx, addr, newFooCoin(99)) == false)

assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr, balances))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr, balances))
assert.Assert(t, f.bankKeeper.HasBalance(ctx, addr, newFooCoin(101)) == false)
assert.Assert(t, f.bankKeeper.HasBalance(ctx, addr, newFooCoin(100)))
assert.Assert(t, f.bankKeeper.HasBalance(ctx, addr, newFooCoin(1)))
Expand All @@ -670,7 +673,7 @@ func TestMsgSendEvents(t *testing.T) {

f.accountKeeper.SetAccount(ctx, acc)
newCoins := sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr, newCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr, newCoins))

assert.NilError(t, f.bankKeeper.SendCoins(ctx, addr, addr2, newCoins))
event1 := sdk.Event{
Expand Down Expand Up @@ -742,7 +745,7 @@ func TestMsgMultiSendEvents(t *testing.T) {
assert.Equal(t, 0, len(events))

// Set addr's coins but not addr2's coins
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50), sdk.NewInt64Coin(barDenom, 100))))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50), sdk.NewInt64Coin(barDenom, 100))))
assert.NilError(t, f.bankKeeper.InputOutputCoins(ctx, input, outputs))

events = ctx.EventManager().ABCIEvents()
Expand All @@ -759,10 +762,10 @@ func TestMsgMultiSendEvents(t *testing.T) {
assert.DeepEqual(t, abci.Event(event1), events[7])

// Set addr's coins and addr2's coins
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))))
newCoins = sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))

assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100))))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr, sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100))))
newCoins2 = sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100))

assert.NilError(t, f.bankKeeper.InputOutputCoins(ctx, input, outputs))
Expand Down Expand Up @@ -823,8 +826,8 @@ func TestSpendableCoins(t *testing.T) {
f.accountKeeper.SetAccount(ctx, macc)
f.accountKeeper.SetAccount(ctx, vacc)
f.accountKeeper.SetAccount(ctx, acc)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr2, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr2, origCoins))

assert.DeepEqual(t, origCoins, f.bankKeeper.SpendableCoins(ctx, addr2))
assert.DeepEqual(t, origCoins[0], f.bankKeeper.SpendableCoin(ctx, addr2, "stake"))
Expand Down Expand Up @@ -854,13 +857,13 @@ func TestVestingAccountSend(t *testing.T) {
vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix())

f.accountKeeper.SetAccount(ctx, vacc)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, origCoins))

// require that no coins be sendable at the beginning of the vesting schedule
assert.Error(t, f.bankKeeper.SendCoins(ctx, addr1, addr2, sendCoins), fmt.Sprintf("spendable balance is smaller than %s: insufficient funds", sendCoins))

// receive some coins
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, sendCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, sendCoins))
// require that all vested coins are spendable plus any received
ctx = ctx.WithBlockTime(now.Add(12 * time.Hour))
assert.NilError(t, f.bankKeeper.SendCoins(ctx, addr1, addr2, sendCoins))
Expand Down Expand Up @@ -889,13 +892,13 @@ func TestPeriodicVestingAccountSend(t *testing.T) {
vacc := vesting.NewPeriodicVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), periods)

f.accountKeeper.SetAccount(ctx, vacc)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, origCoins))

// require that no coins be sendable at the beginning of the vesting schedule
assert.Error(t, f.bankKeeper.SendCoins(ctx, addr1, addr2, sendCoins), fmt.Sprintf("spendable balance is smaller than %s: insufficient funds", sendCoins))

// receive some coins
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, sendCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, sendCoins))

// require that all vested coins are spendable plus any received
ctx = ctx.WithBlockTime(now.Add(12 * time.Hour))
Expand Down Expand Up @@ -924,8 +927,8 @@ func TestVestingAccountReceive(t *testing.T) {

f.accountKeeper.SetAccount(ctx, vacc)
f.accountKeeper.SetAccount(ctx, acc)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr2, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr2, origCoins))

// send some coins to the vesting account
assert.NilError(t, f.bankKeeper.SendCoins(ctx, addr2, addr1, sendCoins))
Expand Down Expand Up @@ -966,8 +969,8 @@ func TestPeriodicVestingAccountReceive(t *testing.T) {

f.accountKeeper.SetAccount(ctx, vacc)
f.accountKeeper.SetAccount(ctx, acc)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr2, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr2, origCoins))

// send some coins to the vesting account
assert.NilError(t, f.bankKeeper.SendCoins(ctx, addr2, addr1, sendCoins))
Expand Down Expand Up @@ -1006,8 +1009,8 @@ func TestDelegateCoins(t *testing.T) {
f.accountKeeper.SetAccount(ctx, vacc)
f.accountKeeper.SetAccount(ctx, acc)
f.accountKeeper.SetAccount(ctx, macc)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr2, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr2, origCoins))

ctx = ctx.WithBlockTime(now.Add(12 * time.Hour))

Expand Down Expand Up @@ -1076,8 +1079,8 @@ func TestUndelegateCoins(t *testing.T) {
f.accountKeeper.SetAccount(ctx, vacc)
f.accountKeeper.SetAccount(ctx, acc)
f.accountKeeper.SetAccount(ctx, macc)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr2, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr2, origCoins))

ctx = ctx.WithBlockTime(now.Add(12 * time.Hour))

Expand Down Expand Up @@ -1130,7 +1133,7 @@ func TestUndelegateCoins_Invalid(t *testing.T) {
assert.Error(t, f.bankKeeper.UndelegateCoins(ctx, addrModule, addr1, delCoins), fmt.Sprintf("module account %s does not exist: unknown address", addrModule.String()))

f.accountKeeper.SetAccount(ctx, macc)
assert.NilError(t, banktestutil.FundAccount(f.bankKeeper, ctx, addr1, origCoins))
assert.NilError(t, banktestutil.FundAccount(ctx, f.bankKeeper, addr1, origCoins))

assert.Error(t, f.bankKeeper.UndelegateCoins(ctx, addrModule, addr1, delCoins), fmt.Sprintf("spendable balance is smaller than %s: insufficient funds", delCoins))
f.accountKeeper.SetAccount(ctx, acc)
Expand Down Expand Up @@ -1208,7 +1211,8 @@ func TestBalanceTrackingEvents(t *testing.T) {
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

f.bankKeeper = keeper.NewBaseKeeper(f.appCodec, f.fetchStoreKey(types.StoreKey),
bankStoreService := runtime.NewKVStoreService(f.fetchStoreKey(types.StoreKey).(*storetypes.KVStoreKey))
f.bankKeeper = keeper.NewBaseKeeper(f.appCodec, bankStoreService,
f.accountKeeper, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
log.NewNopLogger(),
)
Expand Down Expand Up @@ -1329,7 +1333,7 @@ func TestMintCoinRestrictions(t *testing.T) {
f := initFixture(t)
t.Parallel()

type BankMintingRestrictionFn func(ctx sdk.Context, coins sdk.Coins) error
type BankMintingRestrictionFn func(ctx context.Context, coins sdk.Coins) error

maccPerms := make(map[string][]string)
maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking}
Expand All @@ -1354,7 +1358,7 @@ func TestMintCoinRestrictions(t *testing.T) {
}{
{
"restriction",
func(_ sdk.Context, coins sdk.Coins) error {
func(_ context.Context, coins sdk.Coins) error {
for _, coin := range coins {
if coin.Denom != fooDenom {
return fmt.Errorf("Module %s only has perms for minting %s coins, tried minting %s coins", types.ModuleName, fooDenom, coin.Denom)
Expand All @@ -1376,7 +1380,8 @@ func TestMintCoinRestrictions(t *testing.T) {
}

for _, test := range tests {
f.bankKeeper = keeper.NewBaseKeeper(f.appCodec, f.fetchStoreKey(types.StoreKey),
bankStoreService := runtime.NewKVStoreService(f.fetchStoreKey(types.StoreKey).(*storetypes.KVStoreKey))
f.bankKeeper = keeper.NewBaseKeeper(f.appCodec, bankStoreService,
f.accountKeeper, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
log.NewNopLogger(),
).WithMintCoinsRestriction(keeper.MintingRestrictionFn(test.restrictionFn))
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/distribution/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func initFixture(t testing.TB) *fixture {
}
bankKeeper := bankkeeper.NewBaseKeeper(
cdc,
keys[banktypes.StoreKey],
runtime.NewKVStoreService(keys[banktypes.StoreKey]),
accountKeeper,
blockedAddresses,
authority.String(),
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/genutil/gentx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func setAccountBalance(t *testing.T, f *fixture, addr sdk.AccAddress, amount int
acc := f.accountKeeper.NewAccountWithAddress(f.ctx, addr)
f.accountKeeper.SetAccount(f.ctx, acc)

err := testutil.FundAccount(f.bankKeeper, f.ctx, addr, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, amount)})
err := testutil.FundAccount(f.ctx, f.bankKeeper, addr, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, amount)})
assert.NilError(t, err)

bankGenesisState := f.bankKeeper.ExportGenesis(f.ctx)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/staking/keeper/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) {
bondDenom := app.StakingKeeper.BondDenom(ctx)
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)

assert.NilError(t, banktestutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(bondDenom, startTokens))))
assert.NilError(t, banktestutil.FundModuleAccount(ctx, app.BankKeeper, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(bondDenom, startTokens))))
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)

// create a validator and a delegator to that validator
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/staking/keeper/determinstic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func setValidator(f *deterministicFixture, t *testing.T, validator stakingtypes.

delegatorAddress := sdk.AccAddress(validator.GetOperator())
coins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, validator.BondedTokens()))
banktestutil.FundAccount(f.bankKeeper, f.ctx, delegatorAddress, coins)
banktestutil.FundAccount(f.ctx, f.bankKeeper, delegatorAddress, coins)

_, err := f.stakingKeeper.Delegate(f.ctx, delegatorAddress, validator.BondedTokens(), stakingtypes.Unbonded, validator, true)
assert.NilError(t, err)
Expand Down Expand Up @@ -237,7 +237,7 @@ func fundAccountAndDelegate(f *deterministicFixture, t *testing.T, delegator sdk
coins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, amt))

assert.NilError(t, f.bankKeeper.MintCoins(f.ctx, minttypes.ModuleName, coins))
banktestutil.FundAccount(f.bankKeeper, f.ctx, delegator, coins)
banktestutil.FundAccount(f.ctx, f.bankKeeper, delegator, coins)

shares, err := f.stakingKeeper.Delegate(f.ctx, delegator, amt, stakingtypes.Unbonded, validator, true)
return shares, err
Expand Down
Loading

0 comments on commit 6dfe735

Please sign in to comment.