Skip to content

Commit

Permalink
some changes from review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
crodriguezvega committed Mar 31, 2022
1 parent 93ee2d7 commit 34f03df
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenTry() {

// use chainA (controller) for ChanOpenTry
msg := channeltypes.NewMsgChannelOpenTry(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, TestVersion, channeltypes.ORDERED, []string{path.EndpointA.ConnectionID}, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, TestVersion, proofInit, proofHeight, icatypes.ModuleName)
handler := suite.chainA.GetSimApp().MsgSvcRouter.Handler(msg)
handler := suite.chainA.GetSimApp().MsgServiceRouter.Handler(msg)
_, err = handler(suite.chainA.GetContext(), msg)

suite.Require().Error(err)
Expand Down Expand Up @@ -359,7 +359,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenConfirm() {

// use chainA (controller) for ChanOpenConfirm
msg := channeltypes.NewMsgChannelOpenConfirm(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, proofAck, proofHeight, icatypes.ModuleName)
handler := suite.chainA.GetSimApp().MsgSvcRouter.Handler(msg)
handler := suite.chainA.GetSimApp().MsgServiceRouter.Handler(msg)
_, err = handler(suite.chainA.GetContext(), msg)

suite.Require().Error(err)
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/27-interchain-accounts/host/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenInit() {

// use chainB (host) for ChanOpenInit
msg := channeltypes.NewMsgChannelOpenInit(path.EndpointB.ChannelConfig.PortID, icatypes.Version, channeltypes.ORDERED, []string{path.EndpointB.ConnectionID}, path.EndpointA.ChannelConfig.PortID, icatypes.ModuleName)
handler := suite.chainB.GetSimApp().MsgSvcRouter.Handler(msg)
handler := suite.chainB.GetSimApp().MsgServiceRouter.Handler(msg)
_, err := handler(suite.chainB.GetContext(), msg)

suite.Require().Error(err)
Expand Down Expand Up @@ -255,7 +255,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenAck() {

// use chainB (host) for ChanOpenAck
msg := channeltypes.NewMsgChannelOpenAck(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, path.EndpointA.ChannelID, TestVersion, proofTry, proofHeight, icatypes.ModuleName)
handler := suite.chainB.GetSimApp().MsgSvcRouter.Handler(msg)
handler := suite.chainB.GetSimApp().MsgServiceRouter.Handler(msg)
_, err = handler(suite.chainB.GetContext(), msg)

suite.Require().Error(err)
Expand Down
4 changes: 2 additions & 2 deletions modules/core/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ type ibcTxHandler struct {
next tx.Handler
}

// IbcTxMiddleware implements ibc tx handling middleware
func IbcTxMiddleware(IBCKeeper *keeper.Keeper) tx.Middleware {
// IBCTxMiddleware implements ibc tx handling middleware
func IBCTxMiddleware(IBCKeeper *keeper.Keeper) tx.Middleware {
return func(txh tx.Handler) tx.Handler {
return ibcTxHandler{
k: IBCKeeper,
Expand Down
4 changes: 2 additions & 2 deletions modules/core/middleware/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func (suite *MiddlewareTestSuite) TestMiddleware() {
// commiting it to a block, so that the when check tx runs with the redundant
// message they are both in the same block
k := suite.chainB.App.GetIBCKeeper()
mw := ibcmiddleware.IbcTxMiddleware(k)
mw := ibcmiddleware.IBCTxMiddleware(k)
checkCtx := suite.chainB.GetContext().WithIsCheckTx(true)
txHandler := middleware.ComposeMiddlewares(noopTxHandler, mw)

Expand All @@ -462,7 +462,7 @@ func (suite *MiddlewareTestSuite) TestMiddleware() {
suite.SetupTest()

k := suite.chainB.App.GetIBCKeeper()
mw := ibcmiddleware.IbcTxMiddleware(k)
mw := ibcmiddleware.IBCTxMiddleware(k)

msgs := tc.malleate(suite)

Expand Down
16 changes: 8 additions & 8 deletions testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ type SimApp struct {
legacyAmino *codec.LegacyAmino
appCodec codec.Codec
interfaceRegistry types.InterfaceRegistry
MsgSvcRouter *authmiddleware.MsgServiceRouter
MsgServiceRouter *authmiddleware.MsgServiceRouter
legacyRouter sdk.Router

invCheckPeriod uint
Expand Down Expand Up @@ -272,7 +272,7 @@ func NewSimApp(
appCodec: appCodec,
interfaceRegistry: interfaceRegistry,
legacyRouter: authmiddleware.NewLegacyRouter(),
MsgSvcRouter: authmiddleware.NewMsgServiceRouter(interfaceRegistry),
MsgServiceRouter: authmiddleware.NewMsgServiceRouter(interfaceRegistry),
invCheckPeriod: invCheckPeriod,
keys: keys,
tkeys: tkeys,
Expand Down Expand Up @@ -338,7 +338,7 @@ func NewSimApp(
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper,
)

app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgSvcRouter, app.AccountKeeper)
app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter, app.AccountKeeper)

// register the proposal types
govRouter := govv1beta1.NewRouter()
Expand All @@ -350,7 +350,7 @@ func NewSimApp(
govConfig := govtypes.DefaultConfig()
app.GovKeeper = govkeeper.NewKeeper(
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
&stakingKeeper, govRouter, app.MsgSvcRouter, govConfig,
&stakingKeeper, govRouter, app.MsgServiceRouter, govConfig,
)

// Create Transfer Keepers
Expand All @@ -371,13 +371,13 @@ func NewSimApp(
appCodec, keys[icacontrollertypes.StoreKey], app.GetSubspace(icacontrollertypes.SubModuleName),
app.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 fee
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
scopedICAControllerKeeper, app.MsgSvcRouter,
scopedICAControllerKeeper, app.MsgServiceRouter,
)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName),
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
app.AccountKeeper, scopedICAHostKeeper, app.MsgSvcRouter,
app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter,
)

icaModule := ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper)
Expand Down Expand Up @@ -471,7 +471,7 @@ func NewSimApp(

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.legacyRouter, app.QueryRouter(), encodingConfig.Amino)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgSvcRouter, app.GRPCQueryRouter())
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter, app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)

// add test gRPC service for testing gRPC queries in isolation
Expand Down Expand Up @@ -540,7 +540,7 @@ func (app *SimApp) setTxHandler(txConfig client.TxConfig, indexEventsStr []strin
Debug: app.Trace(),
IndexEvents: indexEvents,
LegacyRouter: app.legacyRouter,
MsgServiceRouter: app.MsgSvcRouter,
MsgServiceRouter: app.MsgServiceRouter,
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
Expand Down
6 changes: 5 additions & 1 deletion testing/simapp/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for middlewares")
}

if options.IBCKeeper == nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "IBC keeper is required for middlewares")
}

var sigGasConsumer = options.SigGasConsumer
if sigGasConsumer == nil {
sigGasConsumer = authmiddleware.DefaultSigVerificationGasConsumer
Expand Down Expand Up @@ -102,6 +106,6 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) {
// should be accounted for, should go below this authmiddleware.
authmiddleware.ConsumeBlockGasMiddleware,
authmiddleware.NewTipMiddleware(options.BankKeeper),
ibcmiddleware.IbcTxMiddleware(options.IBCKeeper),
ibcmiddleware.IBCTxMiddleware(options.IBCKeeper),
), nil
}
4 changes: 3 additions & 1 deletion testing/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ func ABCIResponsesResultsHash(ar *tmprotostate.ABCIResponses) []byte {
return tmtypes.NewResults(ar.DeliverTxs).Hash()
}

// MakeCommit commits a block
// MakeCommit iterates over the provided validator set, creating a Precommit vote for each
// participant at the provided height and round. Each vote is signed and added to the VoteSet.
// Finally, the VoteSet is committed finalizing the block.
func MakeCommit(ctx context.Context, blockID tmtypes.BlockID, height int64, round int32, voteSet *tmtypes.VoteSet, validators []tmtypes.PrivValidator, now time.Time) (*tmtypes.Commit, error) {
// all sign
for i := 0; i < len(validators); i++ {
Expand Down

0 comments on commit 34f03df

Please sign in to comment.