Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: change non nil relayer check to non empty #1774

Merged
merged 7 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (apps/29-fee) [\#1774](https://github.com/cosmos/ibc-go/pull/1774) Change non nil relayer assertion to non empty to avoid import/export issues for genesis upgrades.
* (makefile) [\#1785](https://github.com/cosmos/ibc-go/pull/1785) Fetch the correct versions of protocol buffers dependencies from tendermint, cosmos-sdk, and ics23.
* (apps/29-fee) [\#1278](https://github.com/cosmos/ibc-go/pull/1278) The URI path for the query to get all incentivized packets for a specific channel did not follow the same format as the rest of queries.

Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var (
ErrRefundAccNotFound = sdkerrors.Register(ModuleName, 3, "no account found for given refund address")
ErrBalanceNotFound = sdkerrors.Register(ModuleName, 4, "balance not found for given account address")
ErrFeeNotFound = sdkerrors.Register(ModuleName, 5, "there is no fee escrowed for the given packetID")
ErrRelayersNotNil = sdkerrors.Register(ModuleName, 6, "relayers must be nil. This feature is not supported")
ErrRelayersNotEmpty = sdkerrors.Register(ModuleName, 6, "relayers must not be set. This feature is not supported")
ErrCounterpartyPayeeEmpty = sdkerrors.Register(ModuleName, 7, "counterparty payee must not be empty")
ErrForwardRelayerAddressNotFound = sdkerrors.Register(ModuleName, 8, "forward relayer address not found")
ErrFeeNotEnabled = sdkerrors.Register(ModuleName, 9, "fee module is not enabled for this channel. If this error occurs after channel setup, fee module may not be enabled")
Expand Down
6 changes: 3 additions & 3 deletions modules/apps/29-fee/types/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func (p PacketFee) Validate() error {
return sdkerrors.Wrap(err, "failed to convert RefundAddress into sdk.AccAddress")
}

// enforce relayer is nil
if p.Relayers != nil {
return ErrRelayersNotNil
// enforce relayers are not set
if len(p.Relayers) != 0 {
return ErrRelayersNotEmpty
}

if err := p.Fee.Validate(); err != nil {
Expand Down
18 changes: 16 additions & 2 deletions modules/apps/29-fee/types/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ func TestPacketFeeValidation(t *testing.T) {
func() {},
true,
},
{
"success with empty slice for Relayers",
func() {
packetFee.Relayers = []string{}
},
true,
},
{
"should fail when refund address is invalid",
func() {
Expand Down Expand Up @@ -102,6 +109,13 @@ func TestPacketFeeValidation(t *testing.T) {
},
false,
},
{
"should fail with non empty Relayers",
func() {
packetFee.Relayers = []string{"relayer"}
},
false,
},
}

for _, tc := range testCases {
Expand All @@ -113,9 +127,9 @@ func TestPacketFeeValidation(t *testing.T) {
err := packetFee.Validate()

if tc.expPass {
require.NoError(t, err)
require.NoError(t, err, tc.name)
} else {
require.Error(t, err)
require.Error(t, err, tc.name)
}
}
}
6 changes: 3 additions & 3 deletions modules/apps/29-fee/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ func (msg MsgPayPacketFee) ValidateBasic() error {
return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress")
}

// enforce relayer is nil
if msg.Relayers != nil {
return ErrRelayersNotNil
// enforce relayer is not set
if len(msg.Relayers) != 0 {
return ErrRelayersNotEmpty
}

if err := msg.Fee.Validate(); err != nil {
Expand Down
22 changes: 18 additions & 4 deletions modules/apps/29-fee/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ func TestMsgPayPacketFeeValidation(t *testing.T) {
func() {},
true,
},
{
"success with empty relayers",
func() {
msg.Relayers = []string{}
},
true,
},
{
"invalid channelID",
func() {
Expand Down Expand Up @@ -211,9 +218,9 @@ func TestMsgPayPacketFeeValidation(t *testing.T) {
err := msg.ValidateBasic()

if tc.expPass {
require.NoError(t, err)
require.NoError(t, err, tc.name)
} else {
require.Error(t, err)
require.Error(t, err, tc.name)
}
}
}
Expand Down Expand Up @@ -258,6 +265,13 @@ func TestMsgPayPacketFeeAsyncValidation(t *testing.T) {
func() {},
true,
},
{
"success with empty relayers",
func() {
msg.PacketFee.Relayers = []string{}
},
true,
},
{
"invalid channelID",
func() {
Expand Down Expand Up @@ -355,9 +369,9 @@ func TestMsgPayPacketFeeAsyncValidation(t *testing.T) {
err := msg.ValidateBasic()

if tc.expPass {
require.NoError(t, err)
require.NoError(t, err, tc.name)
} else {
require.Error(t, err)
require.Error(t, err, tc.name)
}
}
}
Expand Down