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

Add flush status check in SendPacket #3912

Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion modules/core/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (k Keeper) SendPacket(
return 0, errorsmod.Wrap(types.ErrChannelNotFound, sourceChannel)
}

if channel.State != types.OPEN {
if channel.State != types.OPEN || channel.FlushStatus != types.NOTINFLUSH {
charleenfei marked this conversation as resolved.
Show resolved Hide resolved
return 0, errorsmod.Wrapf(
types.ErrInvalidChannelState,
"channel is not OPEN (got %s)", channel.State.String(),
Expand Down
24 changes: 24 additions & 0 deletions modules/core/04-channel/keeper/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,30 @@ func (suite *KeeperTestSuite) TestSendPacket() {

channelCap = capabilitytypes.NewCapability(5)
}, false},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

does it make sense to add an additional check for channel state? I.e:

{
    "channel is in INITUPGRADE stage", 
    func() {
	suite.coordinator.Setup(path)

	path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion
	path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = ibcmock.UpgradeVersion

	err := path.EndpointA.ChanUpgradeInit()
	suite.Require().NoError(err)
    }, 
    false
},

"invalid flush status: FLUSHING",
func() {
suite.coordinator.Setup(path)
sourceChannel = path.EndpointA.ChannelID

channel := path.EndpointA.GetChannel()
channel.FlushStatus = types.FLUSHING
path.EndpointA.SetChannel(channel)
},
false,
},
{
"invalid flush status: FLUSHCOMPLETE",
func() {
suite.coordinator.Setup(path)
sourceChannel = path.EndpointA.ChannelID

channel := path.EndpointA.GetChannel()
channel.FlushStatus = types.FLUSHCOMPLETE
path.EndpointA.SetChannel(channel)
},
false,
},
}

for i, tc := range testCases {
Expand Down