diff --git a/modules/core/ante/ante_test.go b/modules/core/ante/ante_test.go index 2033f1f4e18..68b75fab0a7 100644 --- a/modules/core/ante/ante_test.go +++ b/modules/core/ante/ante_test.go @@ -3,6 +3,7 @@ package ante_test import ( "testing" + "github.com/cosmos/btcutil/bech32" "github.com/stretchr/testify/require" testifysuite "github.com/stretchr/testify/suite" @@ -180,7 +181,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { testCases := []struct { name string malleate func(suite *AnteTestSuite) []sdk.Msg - expPass bool + expError error }{ { "success on one new RecvPacket message", @@ -188,7 +189,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { // the RecvPacket message has not been submitted to the chain yet, so it will succeed return []sdk.Msg{suite.createRecvPacketMessage(false)} }, - true, + nil, }, { "success on one new Acknowledgement message", @@ -196,7 +197,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { // the Acknowledgement message has not been submitted to the chain yet, so it will succeed return []sdk.Msg{suite.createAcknowledgementMessage(false)} }, - true, + nil, }, { "success on one new Timeout message", @@ -204,7 +205,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { // the Timeout message has not been submitted to the chain yet, so it will succeed return []sdk.Msg{suite.createTimeoutMessage(false)} }, - true, + nil, }, { "success on one new TimeoutOnClose message", @@ -212,7 +213,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { // the TimeoutOnClose message has not been submitted to the chain yet, so it will succeed return []sdk.Msg{suite.createTimeoutOnCloseMessage(false)} }, - true, + nil, }, { "success on three new messages of each type", @@ -241,7 +242,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { } return msgs }, - true, + nil, }, { "success on three redundant messages of RecvPacket, Acknowledgement and TimeoutOnClose, and one new Timeout message", @@ -271,7 +272,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { } return msgs }, - true, + nil, }, { "success on one new message and two redundant messages of each type", @@ -301,21 +302,21 @@ func (suite *AnteTestSuite) TestAnteDecorator() { } return msgs }, - true, + nil, }, { "success on one new UpdateClient message", func(suite *AnteTestSuite) []sdk.Msg { return []sdk.Msg{suite.createUpdateClientMessage()} }, - true, + nil, }, { "success on three new UpdateClient messages", func(suite *AnteTestSuite) []sdk.Msg { return []sdk.Msg{suite.createUpdateClientMessage(), suite.createUpdateClientMessage(), suite.createUpdateClientMessage()} }, - true, + nil, }, { "success on three new Updateclient messages and one new RecvPacket message", @@ -327,7 +328,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { suite.createRecvPacketMessage(false), } }, - true, + nil, }, { "success on three redundant RecvPacket messages and one SubmitMisbehaviour message", @@ -342,14 +343,14 @@ func (suite *AnteTestSuite) TestAnteDecorator() { msgs = append(msgs, &clienttypes.MsgSubmitMisbehaviour{}) //nolint:staticcheck // we're using the deprecated message for testing return msgs }, - true, + nil, }, { "no success on one redundant RecvPacket message", func(suite *AnteTestSuite) []sdk.Msg { return []sdk.Msg{suite.createRecvPacketMessage(true)} }, - false, + channeltypes.ErrRedundantTx, }, { "no success on three redundant messages of each type", @@ -374,12 +375,12 @@ func (suite *AnteTestSuite) TestAnteDecorator() { } return msgs }, - false, + channeltypes.ErrRedundantTx, }, { "no success on one new UpdateClient message and three redundant RecvPacket messages", func(suite *AnteTestSuite) []sdk.Msg { - msgs := []sdk.Msg{&clienttypes.MsgUpdateClient{}} + msgs := []sdk.Msg{suite.createUpdateClientMessage()} for i := 1; i <= 3; i++ { msgs = append(msgs, suite.createRecvPacketMessage(true)) @@ -387,7 +388,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { return msgs }, - false, + channeltypes.ErrRedundantTx, }, { "no success on one new UpdateClient message: invalid client identifier", @@ -398,7 +399,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { msgs := []sdk.Msg{&clienttypes.MsgUpdateClient{ClientId: ibctesting.InvalidID, ClientMessage: clientMsg}} return msgs }, - false, + clienttypes.ErrClientNotActive, }, { "no success on one new UpdateClient message: client module not found", @@ -409,7 +410,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { msgs := []sdk.Msg{&clienttypes.MsgUpdateClient{ClientId: clienttypes.FormatClientIdentifier("08-wasm", 1), ClientMessage: clientMsg}} return msgs }, - false, + clienttypes.ErrClientNotActive, }, { "no success on one new UpdateClient message: no consensus state for trusted height", @@ -420,7 +421,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { msgs := []sdk.Msg{&clienttypes.MsgUpdateClient{ClientId: suite.path.EndpointA.ClientID, ClientMessage: clientMsg}} return msgs }, - false, + clienttypes.ErrConsensusStateNotFound, }, { "no success on three new UpdateClient messages and three redundant messages of each type", @@ -445,7 +446,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { } return msgs }, - false, + channeltypes.ErrRedundantTx, }, { "no success on one new message and one invalid message", @@ -460,7 +461,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { channeltypes.NewMsgRecvPacket(packet, []byte("proof"), clienttypes.NewHeight(1, 1), "signer"), } }, - false, + bech32.ErrInvalidLength(6), }, { "no success on one new message and one redundant message in the same block", @@ -484,7 +485,7 @@ func (suite *AnteTestSuite) TestAnteDecorator() { return []sdk.Msg{msg} }, - false, + channeltypes.ErrRedundantTx, }, } @@ -515,10 +516,10 @@ func (suite *AnteTestSuite) TestAnteDecorator() { suite.Require().NoError(err, "antedecorator should not error on DeliverTx") _, err = decorator.AnteHandle(checkCtx, tx, false, next) - if tc.expPass { + if tc.expError == nil { suite.Require().NoError(err, "non-strict decorator did not pass as expected") } else { - suite.Require().Error(err, "non-strict antehandler did not return error as expected") + suite.Require().ErrorIs(err, tc.expError, "non-strict antehandler did not return error as expected") } }) }