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

test: ensure ics27 optimistic packet sends are disallowed #842

Merged
merged 1 commit into from
Feb 3, 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
// absolute timeoutTimestamp must be provided. If the packet is timed out, the channel will be closed.
// In the case of channel closure, a new channel may be reopened to reconnect to the host chain.
func (k Keeper) SendTx(ctx sdk.Context, chanCap *capabilitytypes.Capability, connectionID, portID string, icaPacketData icatypes.InterchainAccountPacketData, timeoutTimestamp uint64) (uint64, error) {
activeChannelID, found := k.GetActiveChannelID(ctx, connectionID, portID)
activeChannelID, found := k.GetOpenActiveChannel(ctx, connectionID, portID)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetActiveChannelID is no longer used in both controller and host submodules. All previous calls are now using GetOpenActiveChannel

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vote to still leave the helper fn in for the time being. Having standard getters/setters around sometimes is no harm.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @seantking. If the active channel closes, it'd be nice to have a way to get the channel id

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure, I agree in principle. My only nit is just: is it really an "active channel" if it's not in an OPEN state? When I think "active channel" its almost implicit in my mind that it's OPEN, but maybe just me! My only fear is that it may be a little misleading

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it can be misleading, but then we need to change the naming of the mapping. I think we are getting into over engineering territory. Hopefully we will delete all of this within a year

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree++

if !found {
return 0, sdkerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel on connection %s for port %s", connectionID, portID)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ func (suite *KeeperTestSuite) TestSendTx() {
},
false,
},
{
"channel in INIT state - optimistic packet sends fail",
func() {
channel, found := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)
suite.Require().True(found)

channel.State = channeltypes.INIT
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel)
},
false,
},
{
"sendPacket fails - channel closed",
func() {
Expand Down