Skip to content

Commit

Permalink
refactor: Move simapp FundAccount and FundModuleAccount to testutil (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
likhita-809 authored Jun 29, 2021
1 parent f65b6c9 commit 7a8b273
Show file tree
Hide file tree
Showing 34 changed files with 187 additions and 163 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking Changes

* [\#9427](https://github.com/cosmos/cosmos-sdk/pull/9427) Move simapp `FundAccount` and `FundModuleAccount` to `x/bank/testutil`
* (client/tx) [\#9421](https://github.com/cosmos/cosmos-sdk/pull/9421/) `BuildUnsignedTx`, `BuildSimTx`, `PrintUnsignedStdTx` functions are moved to
the Tx Factory as methods.

Expand Down
29 changes: 0 additions & 29 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand Down Expand Up @@ -437,31 +436,3 @@ type EmptyAppOptions struct{}
func (ao EmptyAppOptions) Get(o string) interface{} {
return nil
}

// FundAccount is a utility function that funds an account by minting and
// sending the coins to the address. This should be used for testing purposes
// only!
//
// TODO: Instead of using the mint module account, which has the
// permission of minting, create a "faucet" account. (@fdymylja)
func FundAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins) error {
if err := bankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts); err != nil {
return err
}

return bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, amounts)
}

// FundModuleAccount is a utility function that funds a module account by
// minting and sending the coins to the address. This should be used for testing
// purposes only!
//
// TODO: Instead of using the mint module account, which has the
// permission of minting, create a "faucet" account. (@fdymylja)
func FundModuleAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, recipientMod string, amounts sdk.Coins) error {
if err := bankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts); err != nil {
return err
}

return bankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, recipientMod, amounts)
}
8 changes: 4 additions & 4 deletions types/query/filtered_pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)

Expand All @@ -32,7 +32,7 @@ func (s *paginationTestSuite) TestFilteredPaginations() {
addr1 := sdk.AccAddress([]byte("addr1"))
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
app.AccountKeeper.SetAccount(ctx, acc1)
s.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances))
s.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances))
store := ctx.KVStore(app.GetKey(types.StoreKey))

// verify pagination with limit > total values
Expand Down Expand Up @@ -107,7 +107,7 @@ func (s *paginationTestSuite) TestReverseFilteredPaginations() {
addr1 := sdk.AccAddress([]byte("addr1"))
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
app.AccountKeeper.SetAccount(ctx, acc1)
s.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances))
s.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances))
store := ctx.KVStore(app.GetKey(types.StoreKey))

// verify pagination with limit > total values
Expand Down Expand Up @@ -188,7 +188,7 @@ func ExampleFilteredPaginate() {
addr1 := sdk.AccAddress([]byte("addr1"))
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
app.AccountKeeper.SetAccount(ctx, acc1)
err := simapp.FundAccount(app.BankKeeper, ctx, addr1, balances)
err := testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)
if err != nil { // should return no error
fmt.Println(err)
}
Expand Down
7 changes: 4 additions & 3 deletions types/query/pagination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)

Expand Down Expand Up @@ -76,7 +77,7 @@ func (s *paginationTestSuite) TestPagination() {
addr1 := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
app.AccountKeeper.SetAccount(ctx, acc1)
s.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances))
s.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances))

s.T().Log("verify empty page request results a max of defaultLimit records and counts total records")
pageReq := &query.PageRequest{}
Expand Down Expand Up @@ -185,7 +186,7 @@ func (s *paginationTestSuite) TestReversePagination() {
addr1 := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
app.AccountKeeper.SetAccount(ctx, acc1)
s.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances))
s.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances))

s.T().Log("verify paginate with custom limit and countTotal, Reverse false")
pageReq := &query.PageRequest{Limit: 2, CountTotal: true, Reverse: true, Key: nil}
Expand Down Expand Up @@ -306,7 +307,7 @@ func ExamplePaginate() {
addr1 := sdk.AccAddress([]byte("addr1"))
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
app.AccountKeeper.SetAccount(ctx, acc1)
err := simapp.FundAccount(app.BankKeeper, ctx, addr1, balances)
err := testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)
if err != nil { // should return no error
fmt.Println(err)
}
Expand Down
10 changes: 4 additions & 6 deletions x/auth/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import (
"strings"
"testing"

"github.com/cosmos/cosmos-sdk/simapp"

minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
Expand All @@ -23,6 +19,8 @@ import (
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)

// Test that simulate transaction accurately estimates gas cost
Expand Down Expand Up @@ -472,7 +470,7 @@ func (suite *AnteTestSuite) TestAnteHandlerFees() {
{
"signer does not have enough funds to pay the fee",
func() {
err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 149)))
err := testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 149)))
suite.Require().NoError(err)
},
false,
Expand All @@ -489,7 +487,7 @@ func (suite *AnteTestSuite) TestAnteHandlerFees() {
suite.Require().True(suite.app.BankKeeper.GetAllBalances(suite.ctx, modAcc.GetAddress()).Empty())
require.True(sdk.IntEq(suite.T(), suite.app.BankKeeper.GetAllBalances(suite.ctx, addr0).AmountOf("atom"), sdk.NewInt(149)))

err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 1)))
err := testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 1)))
suite.Require().NoError(err)
},
false,
Expand Down
6 changes: 3 additions & 3 deletions x/auth/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package ante_test

import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
)

func (suite *AnteTestSuite) TestEnsureMempoolFees() {
Expand Down Expand Up @@ -83,7 +83,7 @@ func (suite *AnteTestSuite) TestDeductFees() {
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
coins := sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(10)))
err = simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, coins)
err = testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, coins)
suite.Require().NoError(err)

dfd := ante.NewDeductFeeDecorator(suite.app.AccountKeeper, suite.app.BankKeeper, nil)
Expand All @@ -95,7 +95,7 @@ func (suite *AnteTestSuite) TestDeductFees() {

// Set account with sufficient funds
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
err = simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(200))))
err = testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(200))))
suite.Require().NoError(err)

_, err = antehandler(suite.ctx, tx, false)
Expand Down
7 changes: 3 additions & 4 deletions x/auth/ante/feegrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"

"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/simapp/helpers"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -21,6 +19,7 @@ import (
authsign "github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/feegrant"
)

Expand All @@ -46,11 +45,11 @@ func (suite *AnteTestSuite) TestDeductFeesNoDelegation() {
priv5, _, addr5 := testdata.KeyTestPubAddr()

// Set addr1 with insufficient funds
err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(10))})
err := testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(10))})
suite.Require().NoError(err)

// Set addr2 with more funds
err = simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))})
err = testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))})
suite.Require().NoError(err)

// grant fee allowance from `addr2` to `addr3` (plenty to pay)
Expand Down
5 changes: 3 additions & 2 deletions x/auth/signing/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
"github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
)

func TestVerifySignature(t *testing.T) {
Expand All @@ -40,9 +41,9 @@ func TestVerifySignature(t *testing.T) {
_ = app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
app.AccountKeeper.SetAccount(ctx, acc1)
balances := sdk.NewCoins(sdk.NewInt64Coin("atom", 200))
require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr, balances))
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr, balances))
acc, err := ante.GetSignerAcc(ctx, app.AccountKeeper, addr)
require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr, balances))
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr, balances))

msgs := []sdk.Msg{testdata.NewTestMsg(addr)}
fee := legacytx.NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)})
Expand Down
3 changes: 2 additions & 1 deletion x/auth/vesting/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
)

type HandlerTestSuite struct {
Expand Down Expand Up @@ -37,7 +38,7 @@ func (suite *HandlerTestSuite) TestMsgCreateVestingAccount() {

acc1 := suite.app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
suite.app.AccountKeeper.SetAccount(ctx, acc1)
suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, ctx, addr1, balances))
suite.Require().NoError(testutil.FundAccount(suite.app.BankKeeper, ctx, addr1, balances))

testCases := []struct {
name string
Expand Down
5 changes: 3 additions & 2 deletions x/authz/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/authz"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

Expand Down Expand Up @@ -129,7 +130,7 @@ func (s *TestSuite) TestKeeperFees() {
granterAddr := addrs[0]
granteeAddr := addrs[1]
recipientAddr := addrs[2]
s.Require().NoError(simapp.FundAccount(app.BankKeeper, s.ctx, granterAddr, sdk.NewCoins(sdk.NewInt64Coin("steak", 10000))))
s.Require().NoError(testutil.FundAccount(app.BankKeeper, s.ctx, granterAddr, sdk.NewCoins(sdk.NewInt64Coin("steak", 10000))))
now := s.ctx.BlockHeader().Time
s.Require().NotNil(now)

Expand Down Expand Up @@ -204,7 +205,7 @@ func (s *TestSuite) TestDispatchedEvents() {
granterAddr := addrs[0]
granteeAddr := addrs[1]
recipientAddr := addrs[2]
require.NoError(simapp.FundAccount(app.BankKeeper, s.ctx, granterAddr, sdk.NewCoins(sdk.NewInt64Coin("steak", 10000))))
require.NoError(testutil.FundAccount(app.BankKeeper, s.ctx, granterAddr, sdk.NewCoins(sdk.NewInt64Coin("steak", 10000))))
now := s.ctx.BlockHeader().Time
require.NotNil(now)

Expand Down
4 changes: 2 additions & 2 deletions x/authz/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/stretchr/testify/suite"

abci "github.com/tendermint/tendermint/abci/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

Expand All @@ -15,6 +14,7 @@ import (
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/authz"
"github.com/cosmos/cosmos-sdk/x/authz/simulation"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)

Expand Down Expand Up @@ -76,7 +76,7 @@ func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Ac
for _, account := range accounts {
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, account.Address)
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, suite.ctx, account.Address, initCoins))
suite.Require().NoError(testutil.FundAccount(suite.app.BankKeeper, suite.ctx, account.Address, initCoins))
}

return accounts
Expand Down
17 changes: 9 additions & 8 deletions x/bank/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)

Expand Down Expand Up @@ -94,7 +95,7 @@ func TestSendNotEnoughBalance(t *testing.T) {
app := simapp.SetupWithGenesisAccounts(genAccs)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67))))
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67))))

app.Commit()

Expand Down Expand Up @@ -129,7 +130,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) {
app := simapp.SetupWithGenesisAccounts(genAccs)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67))))
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 67))))

app.Commit()

Expand Down Expand Up @@ -199,9 +200,9 @@ func TestMsgMultiSendMultipleOut(t *testing.T) {
app := simapp.SetupWithGenesisAccounts(genAccs)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))

require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))

app.Commit()

Expand Down Expand Up @@ -248,11 +249,11 @@ func TestMsgMultiSendMultipleInOut(t *testing.T) {
app := simapp.SetupWithGenesisAccounts(genAccs)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))

require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))

require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr4, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr4, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))

app.Commit()

Expand Down Expand Up @@ -295,7 +296,7 @@ func TestMsgMultiSendDependent(t *testing.T) {
app := simapp.SetupWithGenesisAccounts(genAccs)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))))

app.Commit()

Expand Down
5 changes: 3 additions & 2 deletions x/bank/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand All @@ -30,7 +31,7 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) {
ctx := benchmarkApp.BaseApp.NewContext(false, tmproto.Header{})

// some value conceivably higher than the benchmarks would ever go
require.NoError(b, simapp.FundAccount(benchmarkApp.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000))))
require.NoError(b, testutil.FundAccount(benchmarkApp.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000))))

benchmarkApp.Commit()
txGen := simappparams.MakeTestEncodingConfig().TxConfig
Expand Down Expand Up @@ -72,7 +73,7 @@ func BenchmarkOneBankMultiSendTxPerBlock(b *testing.B) {
ctx := benchmarkApp.BaseApp.NewContext(false, tmproto.Header{})

// some value conceivably higher than the benchmarks would ever go
require.NoError(b, simapp.FundAccount(benchmarkApp.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000))))
require.NoError(b, testutil.FundAccount(benchmarkApp.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 100000000000))))

benchmarkApp.Commit()
txGen := simappparams.MakeTestEncodingConfig().TxConfig
Expand Down
Loading

0 comments on commit 7a8b273

Please sign in to comment.