47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package gov_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
dbm "github.com/cometbft/cometbft-db"
|
|
abcitypes "github.com/cometbft/cometbft/abci/types"
|
|
tmjson "github.com/cometbft/cometbft/libs/json"
|
|
"github.com/cometbft/cometbft/libs/log"
|
|
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"cosmossdk.io/simapp"
|
|
|
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/server"
|
|
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
"github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
)
|
|
|
|
func TestItCreatesModuleAccountOnInitBlock(t *testing.T) {
|
|
db := dbm.NewMemDB()
|
|
|
|
appOptions := make(simtestutil.AppOptionsMap, 0)
|
|
appOptions[flags.FlagHome] = simapp.DefaultNodeHome
|
|
appOptions[server.FlagInvCheckPeriod] = 5
|
|
|
|
app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, appOptions, baseapp.SetChainID("test-chain-id"))
|
|
|
|
genesisState := simapp.GenesisStateWithSingleValidator(t, app)
|
|
stateBytes, err := tmjson.Marshal(genesisState)
|
|
require.NoError(t, err)
|
|
|
|
app.InitChain(
|
|
abcitypes.RequestInitChain{
|
|
AppStateBytes: stateBytes,
|
|
ChainId: "test-chain-id",
|
|
},
|
|
)
|
|
|
|
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
|
|
acc := app.AccountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName))
|
|
require.NotNil(t, acc)
|
|
}
|