27 lines
817 B
Go
27 lines
817 B
Go
package testutil
|
|
|
|
import (
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
|
dbm "github.com/tendermint/tm-db"
|
|
|
|
"github.com/cosmos/cosmos-sdk/store"
|
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
// DefaultContext creates a sdk.Context with a fresh MemDB that can be used in tests.
|
|
func DefaultContext(key storetypes.StoreKey, tkey storetypes.StoreKey) sdk.Context {
|
|
db := dbm.NewMemDB()
|
|
cms := store.NewCommitMultiStore(db)
|
|
cms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
|
|
cms.MountStoreWithDB(tkey, storetypes.StoreTypeTransient, db)
|
|
err := cms.LoadLatestVersion()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
ctx := sdk.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger())
|
|
|
|
return ctx
|
|
}
|