forked from cosmos/ibc-go
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent blocked addresses from sending ICS 20 transfers (cosmos#…
…1907) * fix bug, add test Ensures that a sender account isn't a blocked address Added test cases for MsgTransfer handling * update documentation * move blocked address check to SendTransfer * add changelog entry
- Loading branch information
1 parent
f0f7ce4
commit f891c29
Showing
6 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package keeper_test | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/ibc-go/v5/modules/apps/transfer/types" | ||
) | ||
|
||
func (suite *KeeperTestSuite) TestMsgTransfer() { | ||
var msg *types.MsgTransfer | ||
|
||
testCases := []struct { | ||
name string | ||
malleate func() | ||
expPass bool | ||
}{ | ||
{ | ||
"success", | ||
func() {}, | ||
true, | ||
}, | ||
{ | ||
"invalid sender", | ||
func() { | ||
msg.Sender = "address" | ||
}, | ||
false, | ||
}, | ||
{ | ||
"sender is a blocked address", | ||
func() { | ||
msg.Sender = suite.chainA.GetSimApp().AccountKeeper.GetModuleAddress(types.ModuleName).String() | ||
}, | ||
false, | ||
}, | ||
{ | ||
"channel does not exist", | ||
func() { | ||
msg.SourceChannel = "channel-100" | ||
}, | ||
false, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
suite.SetupTest() | ||
|
||
path := NewTransferPath(suite.chainA, suite.chainB) | ||
suite.coordinator.Setup(path) | ||
|
||
coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)) | ||
msg = types.NewMsgTransfer( | ||
path.EndpointA.ChannelConfig.PortID, | ||
path.EndpointA.ChannelID, | ||
coin, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), | ||
suite.chainB.GetTimeoutHeight(), 0, // only use timeout height | ||
) | ||
|
||
tc.malleate() | ||
|
||
res, err := suite.chainA.GetSimApp().TransferKeeper.Transfer(sdk.WrapSDKContext(suite.chainA.GetContext()), msg) | ||
|
||
if tc.expPass { | ||
suite.Require().NoError(err) | ||
suite.Require().NotNil(res) | ||
} else { | ||
suite.Require().Error(err) | ||
suite.Require().Nil(res) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters