refactor: Move simapp FundAccount and FundModuleAccount to testutil (#9427)
ref: #9346
This commit is contained in:
parent
f65b6c9363
commit
7a8b273d93
@ -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.
|
||||
|
||||
|
||||
@ -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"
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -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{}
|
||||
@ -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}
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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"
|
||||
@ -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
|
||||
@ -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,
|
||||
@ -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,
|
||||
|
||||
@ -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() {
|
||||
@ -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)
|
||||
@ -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)
|
||||
|
||||
@ -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"
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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) {
|
||||
@ -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)})
|
||||
|
||||
@ -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 {
|
||||
@ -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
|
||||
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
@ -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"
|
||||
)
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
@ -4,11 +4,11 @@ import (
|
||||
gocontext "context"
|
||||
"fmt"
|
||||
|
||||
"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/types/query"
|
||||
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"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
@ -33,7 +33,7 @@ func (suite *IntegrationTestSuite) TestQueryBalance() {
|
||||
acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr)
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins))
|
||||
|
||||
res, err = queryClient.Balance(gocontext.Background(), req)
|
||||
suite.Require().NoError(err)
|
||||
@ -65,7 +65,7 @@ func (suite *IntegrationTestSuite) TestQueryAllBalances() {
|
||||
acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr)
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins))
|
||||
|
||||
res, err = queryClient.AllBalances(gocontext.Background(), req)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
@ -4,11 +4,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
@ -17,11 +12,15 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
|
||||
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -310,7 +309,7 @@ func (suite *IntegrationTestSuite) TestSendCoinsNewAccount() {
|
||||
addr1 := sdk.AccAddress([]byte("addr1_______________"))
|
||||
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
|
||||
app.AccountKeeper.SetAccount(ctx, acc1)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances))
|
||||
|
||||
acc1Balances := app.BankKeeper.GetAllBalances(ctx, addr1)
|
||||
suite.Require().Equal(balances, acc1Balances)
|
||||
@ -340,7 +339,7 @@ func (suite *IntegrationTestSuite) TestInputOutputNewAccount() {
|
||||
addr1 := sdk.AccAddress([]byte("addr1_______________"))
|
||||
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
|
||||
app.AccountKeeper.SetAccount(ctx, acc1)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances))
|
||||
|
||||
acc1Balances := app.BankKeeper.GetAllBalances(ctx, addr1)
|
||||
suite.Require().Equal(balances, acc1Balances)
|
||||
@ -393,7 +392,7 @@ func (suite *IntegrationTestSuite) TestInputOutputCoins() {
|
||||
suite.Require().Error(app.BankKeeper.InputOutputCoins(ctx, inputs, []types.Output{}))
|
||||
suite.Require().Error(app.BankKeeper.InputOutputCoins(ctx, inputs, outputs))
|
||||
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances))
|
||||
|
||||
insufficientInputs := []types.Input{
|
||||
{Address: addr1.String(), Coins: sdk.NewCoins(newFooCoin(300), newBarCoin(100))},
|
||||
@ -428,12 +427,12 @@ func (suite *IntegrationTestSuite) TestSendCoins() {
|
||||
addr2 := sdk.AccAddress("addr2_______________")
|
||||
acc2 := app.AccountKeeper.NewAccountWithAddress(ctx, addr2)
|
||||
app.AccountKeeper.SetAccount(ctx, acc2)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, balances))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, balances))
|
||||
|
||||
sendAmt := sdk.NewCoins(newFooCoin(50), newBarCoin(25))
|
||||
suite.Require().Error(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendAmt))
|
||||
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances))
|
||||
suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendAmt))
|
||||
|
||||
acc1Balances := app.BankKeeper.GetAllBalances(ctx, addr1)
|
||||
@ -469,14 +468,14 @@ func (suite *IntegrationTestSuite) TestValidateBalance() {
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
|
||||
balances := sdk.NewCoins(newFooCoin(100))
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, balances))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances))
|
||||
suite.Require().NoError(app.BankKeeper.ValidateBalance(ctx, addr1))
|
||||
|
||||
bacc := authtypes.NewBaseAccountWithAddress(addr2)
|
||||
vacc := vesting.NewContinuousVestingAccount(bacc, balances.Add(balances...), now.Unix(), endTime.Unix())
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, vacc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, balances))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, balances))
|
||||
suite.Require().Error(app.BankKeeper.ValidateBalance(ctx, addr2))
|
||||
}
|
||||
|
||||
@ -533,7 +532,7 @@ func (suite *IntegrationTestSuite) TestHasBalance() {
|
||||
balances := sdk.NewCoins(newFooCoin(100))
|
||||
suite.Require().False(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(99)))
|
||||
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr, balances))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, balances))
|
||||
suite.Require().False(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(101)))
|
||||
suite.Require().True(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(100)))
|
||||
suite.Require().True(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(1)))
|
||||
@ -547,7 +546,7 @@ func (suite *IntegrationTestSuite) TestMsgSendEvents() {
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
newCoins := sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr, newCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, newCoins))
|
||||
|
||||
suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr, addr2, newCoins))
|
||||
event1 := sdk.Event{
|
||||
@ -615,7 +614,7 @@ func (suite *IntegrationTestSuite) TestMsgMultiSendEvents() {
|
||||
suite.Require().Equal(0, len(events))
|
||||
|
||||
// Set addr's coins but not addr2's coins
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))))
|
||||
suite.Require().Error(app.BankKeeper.InputOutputCoins(ctx, inputs, outputs))
|
||||
|
||||
events = ctx.EventManager().ABCIEvents()
|
||||
@ -632,10 +631,10 @@ func (suite *IntegrationTestSuite) TestMsgMultiSendEvents() {
|
||||
suite.Require().Equal(abci.Event(event1), events[7])
|
||||
|
||||
// Set addr's coins and addr2's coins
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))))
|
||||
newCoins = sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))
|
||||
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100))))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100))))
|
||||
newCoins2 = sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100))
|
||||
|
||||
suite.Require().NoError(app.BankKeeper.InputOutputCoins(ctx, inputs, outputs))
|
||||
@ -702,8 +701,8 @@ func (suite *IntegrationTestSuite) TestSpendableCoins() {
|
||||
app.AccountKeeper.SetAccount(ctx, macc)
|
||||
app.AccountKeeper.SetAccount(ctx, vacc)
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins))
|
||||
|
||||
suite.Require().Equal(origCoins, app.BankKeeper.SpendableCoins(ctx, addr2))
|
||||
|
||||
@ -728,13 +727,13 @@ func (suite *IntegrationTestSuite) TestVestingAccountSend() {
|
||||
vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix())
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, vacc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
|
||||
// require that no coins be sendable at the beginning of the vesting schedule
|
||||
suite.Require().Error(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendCoins))
|
||||
|
||||
// receive some coins
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, sendCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, sendCoins))
|
||||
// require that all vested coins are spendable plus any received
|
||||
ctx = ctx.WithBlockTime(now.Add(12 * time.Hour))
|
||||
suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendCoins))
|
||||
@ -760,13 +759,13 @@ func (suite *IntegrationTestSuite) TestPeriodicVestingAccountSend() {
|
||||
vacc := vesting.NewPeriodicVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), periods)
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, vacc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
|
||||
// require that no coins be sendable at the beginning of the vesting schedule
|
||||
suite.Require().Error(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendCoins))
|
||||
|
||||
// receive some coins
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, sendCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, sendCoins))
|
||||
|
||||
// require that all vested coins are spendable plus any received
|
||||
ctx = ctx.WithBlockTime(now.Add(12 * time.Hour))
|
||||
@ -792,8 +791,8 @@ func (suite *IntegrationTestSuite) TestVestingAccountReceive() {
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, vacc)
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins))
|
||||
|
||||
// send some coins to the vesting account
|
||||
suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr2, addr1, sendCoins))
|
||||
@ -831,8 +830,8 @@ func (suite *IntegrationTestSuite) TestPeriodicVestingAccountReceive() {
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, vacc)
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins))
|
||||
|
||||
// send some coins to the vesting account
|
||||
suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr2, addr1, sendCoins))
|
||||
@ -868,8 +867,8 @@ func (suite *IntegrationTestSuite) TestDelegateCoins() {
|
||||
app.AccountKeeper.SetAccount(ctx, vacc)
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
app.AccountKeeper.SetAccount(ctx, macc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins))
|
||||
|
||||
ctx = ctx.WithBlockTime(now.Add(12 * time.Hour))
|
||||
|
||||
@ -932,8 +931,8 @@ func (suite *IntegrationTestSuite) TestUndelegateCoins() {
|
||||
app.AccountKeeper.SetAccount(ctx, vacc)
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
app.AccountKeeper.SetAccount(ctx, macc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr2, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins))
|
||||
|
||||
ctx = ctx.WithBlockTime(now.Add(12 * time.Hour))
|
||||
|
||||
@ -983,7 +982,7 @@ func (suite *IntegrationTestSuite) TestUndelegateCoins_Invalid() {
|
||||
suite.Require().Error(app.BankKeeper.UndelegateCoins(ctx, addrModule, addr1, delCoins))
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, macc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins))
|
||||
|
||||
suite.Require().Error(app.BankKeeper.UndelegateCoins(ctx, addrModule, addr1, delCoins))
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
|
||||
@ -5,11 +5,11 @@ import (
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/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/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
@ -42,7 +42,7 @@ func (suite *IntegrationTestSuite) TestQuerier_QueryBalance() {
|
||||
acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr)
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins))
|
||||
|
||||
res, err = querier(ctx, []string{types.QueryBalance}, req)
|
||||
suite.Require().NoError(err)
|
||||
@ -79,7 +79,7 @@ func (suite *IntegrationTestSuite) TestQuerier_QueryAllBalances() {
|
||||
acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr)
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins))
|
||||
res, err = querier(ctx, []string{types.QueryAllBalances}, req)
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
@ -193,7 +194,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
|
||||
|
||||
35
x/bank/testutil/test_helpers.go
Normal file
35
x/bank/testutil/test_helpers.go
Normal file
@ -0,0 +1,35 @@
|
||||
package testutil
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
// 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)
|
||||
}
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
@ -83,7 +84,7 @@ func TestAllocateTokensToManyValidators(t *testing.T) {
|
||||
require.NotNil(t, feeCollector)
|
||||
|
||||
// fund fee collector
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, feeCollector.GetName(), fees))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, feeCollector.GetName(), fees))
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, feeCollector)
|
||||
|
||||
@ -163,7 +164,7 @@ func TestAllocateTokensTruncation(t *testing.T) {
|
||||
feeCollector := app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName)
|
||||
require.NotNil(t, feeCollector)
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, feeCollector.GetName(), fees))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, feeCollector.GetName(), fees))
|
||||
|
||||
app.AccountKeeper.SetAccount(ctx, feeCollector)
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
@ -280,7 +281,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
|
||||
|
||||
// set module account coins
|
||||
distrAcc := app.DistrKeeper.GetDistributionAccount(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, balanceTokens))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, balanceTokens))))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, distrAcc)
|
||||
|
||||
// create validator with 50% commission
|
||||
@ -492,7 +493,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
|
||||
|
||||
// set module account coins
|
||||
distrAcc := app.DistrKeeper.GetDistributionAccount(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)))))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, distrAcc)
|
||||
|
||||
tokens := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDec(initial))}
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
|
||||
@ -623,7 +624,7 @@ func (suite *KeeperTestSuite) TestGRPCCommunityPool() {
|
||||
"valid request",
|
||||
func() {
|
||||
amount := sdk.NewCoins(sdk.NewInt64Coin("stake", 100))
|
||||
suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, addrs[0], amount))
|
||||
suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addrs[0], amount))
|
||||
|
||||
err := app.DistrKeeper.FundCommunityPool(ctx, amount, addrs[0])
|
||||
suite.Require().Nil(err)
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
)
|
||||
|
||||
@ -49,7 +50,7 @@ func TestWithdrawValidatorCommission(t *testing.T) {
|
||||
// set module account coins
|
||||
distrAcc := app.DistrKeeper.GetDistributionAccount(ctx)
|
||||
coins := sdk.NewCoins(sdk.NewCoin("mytoken", sdk.NewInt(2)), sdk.NewCoin("stake", sdk.NewInt(2)))
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), coins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, distrAcc.GetName(), coins))
|
||||
|
||||
app.AccountKeeper.SetModuleAccount(ctx, distrAcc)
|
||||
|
||||
@ -114,7 +115,7 @@ func TestFundCommunityPool(t *testing.T) {
|
||||
addr := simapp.AddTestAddrs(app, ctx, 2, sdk.ZeroInt())
|
||||
|
||||
amount := sdk.NewCoins(sdk.NewInt64Coin("stake", 100))
|
||||
require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, addr[0], amount))
|
||||
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr[0], amount))
|
||||
|
||||
initPool := app.DistrKeeper.GetFeePool(ctx)
|
||||
assert.Empty(t, initPool.CommunityPool)
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
)
|
||||
@ -33,7 +34,7 @@ func TestProposalHandlerPassed(t *testing.T) {
|
||||
// add coins to the module account
|
||||
macc := app.DistrKeeper.GetDistributionAccount(ctx)
|
||||
balances := app.BankKeeper.GetAllBalances(ctx, macc.GetAddress())
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, macc.GetName(), amount))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, macc.GetName(), amount))
|
||||
|
||||
app.AccountKeeper.SetModuleAccount(ctx, macc)
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
@ -143,7 +144,7 @@ func (suite *SimTestSuite) testSimulateMsgWithdrawValidatorCommission(tokenName
|
||||
|
||||
// set module account coins
|
||||
distrAcc := suite.app.DistrKeeper.GetDistributionAccount(suite.ctx)
|
||||
suite.Require().NoError(simapp.FundModuleAccount(suite.app.BankKeeper, suite.ctx, distrAcc.GetName(), sdk.NewCoins(
|
||||
suite.Require().NoError(testutil.FundModuleAccount(suite.app.BankKeeper, suite.ctx, distrAcc.GetName(), sdk.NewCoins(
|
||||
sdk.NewCoin(tokenName, sdk.NewInt(10)),
|
||||
sdk.NewCoin("stake", sdk.NewInt(5)),
|
||||
)))
|
||||
@ -229,7 +230,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
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -14,6 +13,7 @@ import (
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/feegrant"
|
||||
"github.com/cosmos/cosmos-sdk/x/feegrant/simulation"
|
||||
)
|
||||
@ -43,7 +43,7 @@ func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Ac
|
||||
|
||||
// add coins to the accounts
|
||||
for _, account := range accounts {
|
||||
err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, account.Address, initCoins)
|
||||
err := testutil.FundAccount(suite.app.BankKeeper, suite.ctx, account.Address, initCoins)
|
||||
suite.Require().NoError(err)
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/simapp/helpers"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/genutil/types"
|
||||
@ -64,7 +65,7 @@ func (suite *GenTxTestSuite) setAccountBalance(addr sdk.AccAddress, amount int64
|
||||
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr)
|
||||
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
|
||||
|
||||
err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 25)})
|
||||
err := testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 25)})
|
||||
suite.Require().NoError(err)
|
||||
|
||||
bankGenesisState := suite.app.BankKeeper.ExportGenesis(suite.ctx)
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
@ -271,7 +272,7 @@ func getTestingAccounts(t *testing.T, r *rand.Rand, app *simapp.SimApp, ctx sdk.
|
||||
for _, account := range accounts {
|
||||
acc := app.AccountKeeper.NewAccountWithAddress(ctx, account.Address)
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, account.Address, initCoins))
|
||||
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, account.Address, initCoins))
|
||||
}
|
||||
|
||||
return accounts
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/slashing/simulation"
|
||||
@ -123,7 +124,7 @@ func getTestingAccounts(t *testing.T, r *rand.Rand, app *simapp.SimApp, ctx sdk.
|
||||
for _, account := range accounts {
|
||||
acc := app.AccountKeeper.NewAccountWithAddress(ctx, account.Address)
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, account.Address, initCoins))
|
||||
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, account.Address, initCoins))
|
||||
}
|
||||
|
||||
return accounts
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
@ -64,7 +65,7 @@ func TestInitGenesis(t *testing.T) {
|
||||
log.Printf("%#v", len(validators))
|
||||
// mint coins in the bonded pool representing the validators coins
|
||||
require.NoError(t,
|
||||
simapp.FundModuleAccount(
|
||||
testutil.FundModuleAccount(
|
||||
app.BankKeeper,
|
||||
ctx,
|
||||
types.BondedPoolName,
|
||||
@ -182,7 +183,7 @@ func TestInitGenesisLargeValidatorSet(t *testing.T) {
|
||||
|
||||
// mint coins in the bonded pool representing the validators coins
|
||||
require.NoError(t,
|
||||
simapp.FundModuleAccount(
|
||||
testutil.FundModuleAccount(
|
||||
app.BankKeeper,
|
||||
ctx,
|
||||
types.BondedPoolName,
|
||||
|
||||
@ -5,14 +5,13 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
@ -20,6 +19,7 @@ import (
|
||||
"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/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
|
||||
@ -38,7 +38,7 @@ func bootstrapHandlerGenesisTest(t *testing.T, power int64, numAddrs int, accAmo
|
||||
|
||||
// set non bonded pool balance
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), totalSupply))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), totalSupply))
|
||||
return app, ctx, addrDels, addrVals
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
@ -186,7 +187,7 @@ func TestUnbondDelegation(t *testing.T) {
|
||||
startTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10)
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), startTokens))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), startTokens))))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
// create a validator and a delegator to that validator
|
||||
@ -227,7 +228,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) {
|
||||
bondDenom := app.StakingKeeper.BondDenom(ctx)
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(bondDenom, startTokens))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(bondDenom, startTokens))))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
// create a validator and a delegator to that validator
|
||||
@ -315,7 +316,7 @@ func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), delCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), delCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true)
|
||||
@ -327,7 +328,7 @@ func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
|
||||
// create a second delegation to this validator
|
||||
@ -337,7 +338,7 @@ func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) {
|
||||
require.Equal(t, delTokens, issuedShares.RoundInt())
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
|
||||
validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true)
|
||||
@ -375,7 +376,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), delCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), delCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true)
|
||||
@ -386,7 +387,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
|
||||
// create a second delegation to this validator
|
||||
@ -395,14 +396,14 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) {
|
||||
validator, issuedShares = validator.AddTokensFromDel(delTokens)
|
||||
require.Equal(t, delTokens, issuedShares.RoundInt())
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
|
||||
validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true)
|
||||
delegation := types.NewDelegation(addrDels[1], addrVals[0], issuedShares)
|
||||
app.StakingKeeper.SetDelegation(ctx, delegation)
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
|
||||
header := ctx.BlockHeader()
|
||||
@ -454,7 +455,7 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), delCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), delCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
// create a validator with a self-delegation
|
||||
@ -473,7 +474,7 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
|
||||
// create a second delegation to this validator
|
||||
@ -535,7 +536,7 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), delCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), delCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
//create a validator with a self-delegation
|
||||
@ -560,7 +561,7 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), delCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
|
||||
validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true)
|
||||
@ -699,7 +700,7 @@ func TestRedelegateToSameValidator(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
// create a validator with a self-delegation
|
||||
@ -728,7 +729,7 @@ func TestRedelegationMaxEntries(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
// create a validator with a self-delegation
|
||||
@ -784,7 +785,7 @@ func TestRedelegateSelfDelegation(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
//create a validator with a self-delegation
|
||||
@ -840,7 +841,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
//create a validator with a self-delegation
|
||||
@ -922,7 +923,7 @@ func TestRedelegateFromUnbondedValidator(t *testing.T) {
|
||||
|
||||
// add bonded tokens to pool for delegations
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
//create a validator with a self-delegation
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
@ -25,7 +26,7 @@ func bootstrapSlashTest(t *testing.T, power int64) (*simapp.SimApp, sdk.Context,
|
||||
totalSupply := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), amt.MulRaw(int64(len(addrDels)))))
|
||||
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), totalSupply))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), totalSupply))
|
||||
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
@ -35,7 +36,7 @@ func bootstrapSlashTest(t *testing.T, power int64) (*simapp.SimApp, sdk.Context,
|
||||
|
||||
// set bonded pool balance
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), bondedCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), bondedCoins))
|
||||
|
||||
for i := int64(0); i < numVals; i++ {
|
||||
validator := teststaking.NewValidator(t, addrVals[i], PKs[i])
|
||||
@ -125,7 +126,7 @@ func TestSlashRedelegation(t *testing.T) {
|
||||
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
|
||||
balances := app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress())
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), startCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), startCoins))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
|
||||
// set a redelegation with an expiration timestamp beyond which the
|
||||
@ -402,7 +403,7 @@ func TestSlashWithRedelegation(t *testing.T) {
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
rdCoins := sdk.NewCoins(sdk.NewCoin(bondDenom, rdTokens.MulRaw(2)))
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), rdCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), rdCoins))
|
||||
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
|
||||
@ -565,8 +566,8 @@ func TestSlashBoth(t *testing.T) {
|
||||
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), bondedCoins))
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), notBondedCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), bondedCoins))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), notBondedCoins))
|
||||
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
@ -36,7 +37,7 @@ func bootstrapValidatorTest(t testing.TB, power int64, numAddrs int) (*simapp.Si
|
||||
// set bonded pool supply
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), totalSupply))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), totalSupply))
|
||||
|
||||
return app, ctx, addrDels, addrVals
|
||||
}
|
||||
@ -113,8 +114,8 @@ func TestUpdateValidatorByPowerIndex(t *testing.T) {
|
||||
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 1234)))))
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 1234)))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)))))
|
||||
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
@ -162,8 +163,8 @@ func TestUpdateBondedValidatorsDecreaseCliff(t *testing.T) {
|
||||
app.StakingKeeper.SetParams(ctx, params)
|
||||
|
||||
// create a random pool
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 1234)))))
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 1234)))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)))))
|
||||
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
@ -217,7 +218,7 @@ func TestSlashToZeroPowerRemoved(t *testing.T) {
|
||||
|
||||
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), valTokens))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), valTokens))))
|
||||
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
|
||||
@ -422,8 +423,8 @@ func TestGetValidatorSortingMixed(t *testing.T) {
|
||||
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 501)))))
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 0)))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 501)))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), app.StakingKeeper.TokensFromConsensusPower(ctx, 0)))))
|
||||
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
@ -497,7 +498,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
|
||||
validators[i], _ = validators[i].AddTokensFromDel(tokens)
|
||||
|
||||
notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, tokens))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, tokens))))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
validators[i] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[i], true)
|
||||
}
|
||||
@ -516,7 +517,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
|
||||
|
||||
newTokens := sdk.NewCoins()
|
||||
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), newTokens))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), newTokens))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
// test that the two largest validators are
|
||||
@ -548,7 +549,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
|
||||
|
||||
notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
newTokens = sdk.NewCoins(sdk.NewCoin(params.BondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 1)))
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), newTokens))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), newTokens))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
validators[3] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true)
|
||||
@ -563,7 +564,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
|
||||
validators[3], _ = validators[3].RemoveDelShares(sdk.NewDec(201))
|
||||
|
||||
bondedPool := app.StakingKeeper.GetBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, rmTokens))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, bondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, rmTokens))))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, bondedPool)
|
||||
|
||||
validators[3] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true)
|
||||
@ -577,7 +578,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) {
|
||||
validators[3], _ = validators[3].AddTokensFromDel(sdk.NewInt(200))
|
||||
|
||||
notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx)
|
||||
require.NoError(t, simapp.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, sdk.NewInt(200)))))
|
||||
require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), sdk.NewCoins(sdk.NewCoin(params.BondDenom, sdk.NewInt(200)))))
|
||||
app.AccountKeeper.SetModuleAccount(ctx, notBondedPool)
|
||||
|
||||
validators[3] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[3], true)
|
||||
|
||||
@ -13,6 +13,7 @@ import (
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
|
||||
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/simulation"
|
||||
@ -283,7 +284,7 @@ func getTestingAccounts(t *testing.T, r *rand.Rand, app *simapp.SimApp, ctx sdk.
|
||||
for _, account := range accounts {
|
||||
acc := app.AccountKeeper.NewAccountWithAddress(ctx, account.Address)
|
||||
app.AccountKeeper.SetAccount(ctx, acc)
|
||||
require.NoError(t, simapp.FundAccount(app.BankKeeper, ctx, account.Address, initCoins))
|
||||
require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, account.Address, initCoins))
|
||||
}
|
||||
|
||||
return accounts
|
||||
|
||||
Loading…
Reference in New Issue
Block a user