Skip to content

Commit

Permalink
Fix some baseapp tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Dec 1, 2021
1 parent 51cbf76 commit c63122e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/snapshots"
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
"github.com/cosmos/cosmos-sdk/store/rootmulti"
Expand All @@ -41,6 +42,7 @@ var (
capKey2 = sdk.NewKVStoreKey("key2")

interfaceRegistry = testdata.NewTestInterfaceRegistry()
encCfg = simapp.MakeTestEncodingConfig()
)

type paramStore struct {
Expand Down Expand Up @@ -163,6 +165,7 @@ func setupBaseAppWithSnapshots(t *testing.T, blocks uint, blockTxs int, options
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
TxDecoder: encCfg.TxConfig.TxDecoder(),
},
func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { return ctx, nil },
)
Expand Down Expand Up @@ -958,6 +961,7 @@ func TestCheckTx(t *testing.T) {
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
TxDecoder: encCfg.TxConfig.TxDecoder(),
},
customHandlerTxTest(t, capKey1, counterKey),
)
Expand Down Expand Up @@ -1018,6 +1022,7 @@ func TestDeliverTx(t *testing.T) {
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
TxDecoder: encCfg.TxConfig.TxDecoder(),
},
customHandlerTxTest(t, capKey1, anteKey),
)
Expand Down Expand Up @@ -1080,6 +1085,7 @@ func TestMultiMsgDeliverTx(t *testing.T) {
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
TxDecoder: encCfg.TxConfig.TxDecoder(),
},
customHandlerTxTest(t, capKey1, anteKey),
)
Expand Down Expand Up @@ -1168,6 +1174,7 @@ func TestSimulateTx(t *testing.T) {
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
TxDecoder: encCfg.TxConfig.TxDecoder(),
},
func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { return ctx, nil },
)
Expand Down Expand Up @@ -1243,6 +1250,7 @@ func TestRunInvalidTransaction(t *testing.T) {
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
TxDecoder: encCfg.TxConfig.TxDecoder(),
},
func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
return
Expand Down Expand Up @@ -1367,6 +1375,7 @@ func TestTxGasLimits(t *testing.T) {
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
TxDecoder: encCfg.TxConfig.TxDecoder(),
},
ante,
)
Expand Down Expand Up @@ -1454,6 +1463,7 @@ func TestMaxBlockGasLimits(t *testing.T) {
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
TxDecoder: encCfg.TxConfig.TxDecoder(),
},
ante,
)
Expand Down Expand Up @@ -1540,6 +1550,7 @@ func TestBaseAppMiddleware(t *testing.T) {
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
TxDecoder: encCfg.TxConfig.TxDecoder(),
},
customHandlerTxTest(t, capKey1, anteKey),
)
Expand Down Expand Up @@ -1634,6 +1645,7 @@ func TestGasConsumptionBadTx(t *testing.T) {
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
TxDecoder: encCfg.TxConfig.TxDecoder(),
},
ante,
)
Expand Down Expand Up @@ -1695,6 +1707,7 @@ func TestQuery(t *testing.T) {
middleware.TxHandlerOptions{
LegacyRouter: legacyRouter,
MsgServiceRouter: middleware.NewMsgServiceRouter(interfaceRegistry),
TxDecoder: encCfg.TxConfig.TxDecoder(),
},
func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
store := ctx.KVStore(capKey1)
Expand Down Expand Up @@ -2014,7 +2027,10 @@ func TestWithRouter(t *testing.T) {
customRouter := &testCustomRouter{routes: sync.Map{}}
r := sdk.NewRoute(routeMsgCounter, handlerMsgCounter(t, capKey1, deliverKey))
customRouter.AddRoute(r)
txHandler := middleware.NewRunMsgsTxHandler(middleware.NewMsgServiceRouter(interfaceRegistry), customRouter)
txHandler := middleware.ComposeMiddlewares(
middleware.NewRunMsgsTxHandler(middleware.NewMsgServiceRouter(interfaceRegistry), customRouter),
middleware.NewTxDecoderMiddleware(encCfg.TxConfig.TxDecoder()),
)
bapp.SetTxHandler(txHandler)
}
app := setupBaseApp(t, txHandlerOpt)
Expand Down

0 comments on commit c63122e

Please sign in to comment.