diff --git a/CHANGELOG.md b/CHANGELOG.md index 3519ce30d92..6aff1fcc83e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### State Machine Breaking +* (apps/27-interchain-accounts) [\#1882](https://github.com/cosmos/ibc-go/pull/1882) Explicitly check length of interchain account packet data in favour of nil check. + ### Improvements * (linting) [\#1418](https://github.com/cosmos/ibc-go/pull/1418) Fix linting errors, resulting compatiblity with go1.18 linting style, golangci-lint 1.46.2 and the revivie linter. This caused breaking changes in core/04-channel, core/ante, and the testing library. diff --git a/modules/apps/27-interchain-accounts/types/packet.go b/modules/apps/27-interchain-accounts/types/packet.go index e7669a77fc9..59419f8f302 100644 --- a/modules/apps/27-interchain-accounts/types/packet.go +++ b/modules/apps/27-interchain-accounts/types/packet.go @@ -16,7 +16,7 @@ func (iapd InterchainAccountPacketData) ValidateBasic() error { return sdkerrors.Wrap(ErrInvalidOutgoingData, "packet data type cannot be unspecified") } - if iapd.Data == nil { + if len(iapd.Data) == 0 { return sdkerrors.Wrap(ErrInvalidOutgoingData, "packet data cannot be empty") } diff --git a/modules/apps/27-interchain-accounts/types/packet_test.go b/modules/apps/27-interchain-accounts/types/packet_test.go index 3bf0d5bd572..462b347e809 100644 --- a/modules/apps/27-interchain-accounts/types/packet_test.go +++ b/modules/apps/27-interchain-accounts/types/packet_test.go @@ -40,6 +40,15 @@ func (suite *TypesTestSuite) TestValidateBasic() { }, { "empty data", + types.InterchainAccountPacketData{ + Type: types.EXECUTE_TX, + Data: []byte{}, + Memo: "memo", + }, + false, + }, + { + "nil data", types.InterchainAccountPacketData{ Type: types.EXECUTE_TX, Data: nil,