Skip to content

Commit

Permalink
Merge Pr cosmos#5642: Remove x/mock
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored Feb 14, 2020
1 parent 60fdb0a commit 5726684
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/supply"
)

Expand Down Expand Up @@ -43,25 +44,26 @@ func Setup(isCheckTx bool) *SimApp {
return app
}

// SetupWithGenesisAccounts initializes a new SimApp with the passed in
// genesis accounts.
func SetupWithGenesisAccounts(genAccs []authexported.GenesisAccount) *SimApp {
// SetupWithGenesisAccounts initializes a new SimApp with the provided genesis
// accounts and possible balances.
func SetupWithGenesisAccounts(genAccs []authexported.GenesisAccount, balances ...bank.Balance) *SimApp {
db := dbm.NewMemDB()
app := NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, 0)

// initialize the chain with the passed in genesis accounts
genesisState := NewDefaultGenesisState()

authGenesis := auth.NewGenesisState(auth.DefaultParams(), genAccs)
genesisStateBz := app.Codec().MustMarshalJSON(authGenesis)
genesisState[auth.ModuleName] = genesisStateBz
genesisState[auth.ModuleName] = app.Codec().MustMarshalJSON(authGenesis)

bankGenesis := bank.NewGenesisState(bank.DefaultGenesisState().SendEnabled, balances)
genesisState[bank.ModuleName] = app.Codec().MustMarshalJSON(bankGenesis)

stateBytes, err := codec.MarshalJSONIndent(app.Codec(), genesisState)
if err != nil {
panic(err)
}

// Initialize the chain
app.InitChain(
abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
Expand Down Expand Up @@ -91,6 +93,9 @@ func AddTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sd

// fill all the addresses with some coins, set the loose pool tokens simultaneously
for _, addr := range testAddrs {
acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr)
app.AccountKeeper.SetAccount(ctx, acc)

_, err := app.BankKeeper.AddCoins(ctx, addr, initCoins)
if err != nil {
panic(err)
Expand Down

0 comments on commit 5726684

Please sign in to comment.