diff --git a/.github/mergify.yml b/.github/mergify.yml index 55f367b0b62..5255132e514 100644 --- a/.github/mergify.yml +++ b/.github/mergify.yml @@ -46,6 +46,14 @@ pull_request_rules: backport: branches: - 08-wasm/release/v0.3.x+ibc-go-v7.4.x-wasmvm-v1.5.x + - name: backport patches to v0.4.x wasm ibc-go v7.4.x & wasmvm 1.5.x branch + conditions: + - base=main + - label=backport-wasm-v0.4.x+ibc-go-v7.4.x-wasmvm-v1.5.x + actions: + backport: + branches: + - 08-wasm/release/v0.4.x+ibc-go-v7.4.x-wasmvm-v1.5.x - name: backport patches to v0.4.x wasm ibc-go v8.4.x & wasmvm 2.0.x branch conditions: - base=main @@ -54,6 +62,14 @@ pull_request_rules: backport: branches: - 08-wasm/release/v0.4.x+ibc-go-v8.4.x-wasmvm-v2.0.x + - name: backport patches to v0.5.x wasm ibc-go v8.4.x & wasmvm 2.1.x branch + conditions: + - base=main + - label=backport-wasm-v0.5.x+ibc-go-v8.4.x-wasmvm-v2.1.x + actions: + backport: + branches: + - 08-wasm/release/v0.5.x+ibc-go-v8.4.x-wasmvm-v2.0.x - name: backport patches to v0.5.x wasm ibc-go v9.0.x & wasmvm 2.1.x branch conditions: - base=main diff --git a/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go index da06cd44b12..6fddd5c8a1b 100644 --- a/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go +++ b/modules/apps/27-interchain-accounts/genesis/types/genesis_test.go @@ -91,12 +91,12 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { testCases := []struct { name string malleate func() - expPass bool + expErr error }{ { "success", func() {}, - true, + nil, }, { "failed to validate active channel - invalid port identifier", @@ -110,7 +110,7 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { genesisState = genesistypes.NewControllerGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, []string{}, controllertypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, { "failed to validate active channel - invalid channel identifier", @@ -124,7 +124,7 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { genesisState = genesistypes.NewControllerGenesisState(activeChannels, []genesistypes.RegisteredInterchainAccount{}, []string{}, controllertypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, { "failed to validate registered account - invalid port identifier", @@ -145,7 +145,7 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { genesisState = genesistypes.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}, controllertypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, { "failed to validate registered account - invalid owner address", @@ -166,7 +166,7 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { genesisState = genesistypes.NewControllerGenesisState(activeChannels, registeredAccounts, []string{}, controllertypes.DefaultParams()) }, - false, + icatypes.ErrInvalidAccountAddress, }, { "failed to validate controller ports - invalid port identifier", @@ -187,7 +187,7 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { genesisState = genesistypes.NewControllerGenesisState(activeChannels, registeredAccounts, []string{"invalid|port"}, controllertypes.DefaultParams()) }, - false, + host.ErrInvalidID, }, } @@ -201,10 +201,11 @@ func (suite *GenesisTypesTestSuite) TestValidateControllerGenesisState() { err := genesisState.Validate() - if tc.expPass { + if tc.expErr == nil { suite.Require().NoError(err, tc.name) } else { suite.Require().Error(err, tc.name) + suite.Require().ErrorIs(err, tc.expErr) } }) } diff --git a/modules/core/02-client/types/client_test.go b/modules/core/02-client/types/client_test.go index 43b5b1c7f58..6655c04c6e3 100644 --- a/modules/core/02-client/types/client_test.go +++ b/modules/core/02-client/types/client_test.go @@ -1,6 +1,7 @@ package types_test import ( + "errors" "testing" "github.com/stretchr/testify/require" @@ -63,15 +64,15 @@ func TestValidateClientType(t *testing.T) { testCases := []struct { name string clientType string - expPass bool + expError error }{ - {"valid", "tendermint", true}, - {"valid solomachine", "solomachine-v1", true}, - {"too large", "tenderminttenderminttenderminttenderminttendermintt", false}, - {"too short", "t", false}, - {"blank id", " ", false}, - {"empty id", "", false}, - {"ends with dash", "tendermint-", false}, + {"valid", "tendermint", nil}, + {"valid solomachine", "solomachine-v1", nil}, + {"too large", "tenderminttenderminttenderminttenderminttendermintt", errors.New("client type results in largest client identifier being invalid")}, + {"too short", "t", errors.New("client type results in smallest client identifier being invalid")}, + {"blank id", " ", errors.New("client type cannot be blank")}, + {"empty id", "", errors.New("client type cannot be blank")}, + {"ends with dash", "tendermint-", errors.New("invalid client type")}, } for _, tc := range testCases { @@ -79,10 +80,10 @@ func TestValidateClientType(t *testing.T) { err := types.ValidateClientType(tc.clientType) - if tc.expPass { + if tc.expError == nil { require.NoError(t, err, tc.name) } else { - require.Error(t, err, tc.name) + require.ErrorContains(t, err, tc.expError.Error()) } } } diff --git a/modules/core/04-channel/types/packet_test.go b/modules/core/04-channel/types/packet_test.go index fca1d9a357d..599bd623a51 100644 --- a/modules/core/04-channel/types/packet_test.go +++ b/modules/core/04-channel/types/packet_test.go @@ -1,6 +1,7 @@ package types_test import ( + "errors" "testing" "github.com/stretchr/testify/require" @@ -55,28 +56,27 @@ func TestCommitPacket(t *testing.T) { func TestPacketValidateBasic(t *testing.T) { testCases := []struct { - packet types.Packet - expPass bool - errMsg string + packet types.Packet + expError error }{ - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""}, - {types.NewPacket(validPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid sequence"}, - {types.NewPacket(validPacketData, 1, invalidPort, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source port"}, - {types.NewPacket(validPacketData, 1, portid, invalidChannel, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid source channel"}, - {types.NewPacket(validPacketData, 1, portid, chanid, invalidPort, cpchanid, timeoutHeight, timeoutTimestamp), false, "invalid destination port"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, invalidChannel, timeoutHeight, timeoutTimestamp), false, "invalid destination channel"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, 0), false, "disabled both timeout height and timestamp"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, timeoutTimestamp), true, "disabled timeout height, valid timeout timestamp"}, - {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, 0), true, "disabled timeout timestamp, valid timeout height"}, - {types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), true, ""}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), nil}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, timeoutTimestamp), nil}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, 0), nil}, + {types.NewPacket(unknownPacketData, 1, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), nil}, + {types.NewPacket(validPacketData, 0, portid, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), errors.New("packet sequence cannot be 0: invalid packet")}, + {types.NewPacket(validPacketData, 1, invalidPort, chanid, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), errors.New("invalid source port")}, + {types.NewPacket(validPacketData, 1, portid, invalidChannel, cpportid, cpchanid, timeoutHeight, timeoutTimestamp), errors.New("invalid source channel")}, + {types.NewPacket(validPacketData, 1, portid, chanid, invalidPort, cpchanid, timeoutHeight, timeoutTimestamp), errors.New("invalid destination port")}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, invalidChannel, timeoutHeight, timeoutTimestamp), errors.New("invalid destination channel")}, + {types.NewPacket(validPacketData, 1, portid, chanid, cpportid, cpchanid, disabledTimeout, 0), errors.New("packet timeout height and packet timeout timestamp cannot both be 0: invalid packet")}, } - for i, tc := range testCases { + for _, tc := range testCases { err := tc.packet.ValidateBasic() - if tc.expPass { - require.NoError(t, err, "Msg %d failed: %s", i, tc.errMsg) + if tc.expError == nil { + require.NoError(t, err) } else { - require.Error(t, err, "Invalid Msg %d passed: %s", i, tc.errMsg) + require.ErrorContains(t, err, tc.expError.Error()) } } }