diff --git a/app.go b/app.go index c074f8ccce0..e3a589adb87 100644 --- a/app.go +++ b/app.go @@ -142,7 +142,7 @@ func NewSimApp( bApp.SetAppVersion(version.Version) keys := sdk.NewKVStoreKeys( - bam.MainStoreKey, auth.StoreKey, staking.StoreKey, + bam.MainStoreKey, auth.StoreKey, bank.StoreKey, staking.StoreKey, supply.StoreKey, mint.StoreKey, distr.StoreKey, slashing.StoreKey, gov.StoreKey, params.StoreKey, upgrade.StoreKey, evidence.StoreKey, ) @@ -174,20 +174,20 @@ func NewSimApp( app.cdc, keys[auth.StoreKey], app.subspaces[auth.ModuleName], auth.ProtoBaseAccount, ) app.BankKeeper = bank.NewBaseKeeper( - app.AccountKeeper, app.subspaces[bank.ModuleName], app.BlacklistedAccAddrs(), + app.cdc, keys[bank.StoreKey], app.AccountKeeper, app.subspaces[bank.ModuleName], app.BlacklistedAccAddrs(), ) app.SupplyKeeper = supply.NewKeeper( app.cdc, keys[supply.StoreKey], app.AccountKeeper, app.BankKeeper, maccPerms, ) stakingKeeper := staking.NewKeeper( - app.cdc, keys[staking.StoreKey], app.SupplyKeeper, app.subspaces[staking.ModuleName], + app.cdc, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName], ) app.MintKeeper = mint.NewKeeper( app.cdc, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper, app.SupplyKeeper, auth.FeeCollectorName, ) app.DistrKeeper = distr.NewKeeper( - app.cdc, keys[distr.StoreKey], app.subspaces[distr.ModuleName], &stakingKeeper, + app.cdc, keys[distr.StoreKey], app.subspaces[distr.ModuleName], app.BankKeeper, &stakingKeeper, app.SupplyKeeper, auth.FeeCollectorName, app.ModuleAccountAddrs(), ) app.SlashingKeeper = slashing.NewKeeper( @@ -231,12 +231,12 @@ func NewSimApp( auth.NewAppModule(app.AccountKeeper), bank.NewAppModule(app.BankKeeper, app.AccountKeeper), crisis.NewAppModule(&app.CrisisKeeper), - supply.NewAppModule(app.SupplyKeeper, app.AccountKeeper), - gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.SupplyKeeper), + supply.NewAppModule(app.SupplyKeeper, app.BankKeeper, app.AccountKeeper), + gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper), mint.NewAppModule(app.MintKeeper), - slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.StakingKeeper), - distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.SupplyKeeper, app.StakingKeeper), - staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper), + slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), + distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper, app.StakingKeeper), + staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper), upgrade.NewAppModule(app.UpgradeKeeper), evidence.NewAppModule(app.EvidenceKeeper), ) @@ -265,12 +265,12 @@ func NewSimApp( app.sm = module.NewSimulationManager( auth.NewAppModule(app.AccountKeeper), bank.NewAppModule(app.BankKeeper, app.AccountKeeper), - supply.NewAppModule(app.SupplyKeeper, app.AccountKeeper), - gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.SupplyKeeper), + supply.NewAppModule(app.SupplyKeeper, app.BankKeeper, app.AccountKeeper), + gov.NewAppModule(app.GovKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper), mint.NewAppModule(app.MintKeeper), - staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.SupplyKeeper), - distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.SupplyKeeper, app.StakingKeeper), - slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.StakingKeeper), + staking.NewAppModule(app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper), + distr.NewAppModule(app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.SupplyKeeper, app.StakingKeeper), + slashing.NewAppModule(app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), params.NewAppModule(), // NOTE: only used for simulation to generate randomized param change proposals ) diff --git a/genesis_account.go b/genesis_account.go index e6bc7f97c04..d995f7023e1 100644 --- a/genesis_account.go +++ b/genesis_account.go @@ -31,9 +31,6 @@ type SimGenesisAccount struct { // Validate checks for errors on the vesting and module account parameters func (sga SimGenesisAccount) Validate() error { if !sga.OriginalVesting.IsZero() { - if sga.OriginalVesting.IsAnyGT(sga.Coins) { - return errors.New("vesting amount cannot be greater than total amount") - } if sga.StartTime >= sga.EndTime { return errors.New("vesting start-time cannot be before end-time") } diff --git a/genesis_account_test.go b/genesis_account_test.go index 6c0c6d6775c..385bb7b217b 100644 --- a/genesis_account_test.go +++ b/genesis_account_test.go @@ -20,8 +20,7 @@ func TestSimGenesisAccountValidate(t *testing.T) { vestingStart := time.Now().UTC() coins := sdk.NewCoins(sdk.NewInt64Coin("test", 1000)) - baseAcc := authtypes.NewBaseAccount(addr, nil, pubkey, 0, 0) - require.NoError(t, baseAcc.SetCoins(coins)) + baseAcc := authtypes.NewBaseAccount(addr, pubkey, 0, 0) testCases := []struct { name string @@ -38,14 +37,14 @@ func TestSimGenesisAccountValidate(t *testing.T) { { "invalid basic account with mismatching address/pubkey", simapp.SimGenesisAccount{ - BaseAccount: authtypes.NewBaseAccount(addr, nil, secp256k1.GenPrivKey().PubKey(), 0, 0), + BaseAccount: authtypes.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0), }, true, }, { "valid basic account with module name", simapp.SimGenesisAccount{ - BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(crypto.AddressHash([]byte("testmod"))), nil, nil, 0, 0), + BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(crypto.AddressHash([]byte("testmod"))), nil, 0, 0), ModuleName: "testmod", }, false, @@ -78,16 +77,6 @@ func TestSimGenesisAccountValidate(t *testing.T) { }, true, }, - { - "valid basic account with invalid original vesting coins", - simapp.SimGenesisAccount{ - BaseAccount: baseAcc, - OriginalVesting: coins.Add(coins...), - StartTime: vestingStart.Unix(), - EndTime: vestingStart.Add(1 * time.Hour).Unix(), - }, - true, - }, } for _, tc := range testCases { diff --git a/test_helpers.go b/test_helpers.go index 5192e59feab..3f2967e58f1 100644 --- a/test_helpers.go +++ b/test_helpers.go @@ -1,7 +1,6 @@ package simapp import ( - "os" "testing" "github.com/stretchr/testify/require" @@ -48,7 +47,7 @@ func Setup(isCheckTx bool) *SimApp { // genesis accounts. func SetupWithGenesisAccounts(genAccs []authexported.GenesisAccount) *SimApp { db := dbm.NewMemDB() - app := NewSimApp(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil, true, map[int64]bool{}, 0) + app := NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, 0) // initialize the chain with the passed in genesis accounts genesisState := NewDefaultGenesisState() @@ -101,11 +100,9 @@ func AddTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sd } // CheckBalance checks the balance of an account. -func CheckBalance(t *testing.T, app *SimApp, addr sdk.AccAddress, exp sdk.Coins) { +func CheckBalance(t *testing.T, app *SimApp, addr sdk.AccAddress, balances sdk.Coins) { ctxCheck := app.BaseApp.NewContext(true, abci.Header{}) - res := app.AccountKeeper.GetAccount(ctxCheck, addr) - - require.True(t, exp.IsEqual(res.GetCoins())) + require.True(t, balances.IsEqual(app.BankKeeper.GetAllBalances(ctxCheck, addr))) } // SignCheckDeliver checks a generated signed transaction and simulates a