Skip to content

Commit

Permalink
Remove check on flush status for send packet. (#4384)
Browse files Browse the repository at this point in the history
* Remove check on flush status for send packet.

* Rename test, remove duplicate test.
  • Loading branch information
DimitrisJim authored Aug 18, 2023
1 parent cd250cb commit e78a308
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
9 changes: 1 addition & 8 deletions modules/core/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@ func (k Keeper) SendPacket(
}

if channel.State != types.OPEN {
return 0, errorsmod.Wrapf(
types.ErrInvalidChannelState,
"channel is not OPEN (got %s)", channel.State.String(),
)
}

if channel.FlushStatus != types.NOTINFLUSH {
return 0, errorsmod.Wrapf(types.ErrInvalidFlushStatus, "expected flush status to be %s during packet send, got %s", types.NOTINFLUSH, channel.FlushStatus)
return 0, errorsmod.Wrapf(types.ErrInvalidChannelState, "channel is not OPEN (got %s)", channel.State)
}

if !k.scopedKeeper.AuthenticateCapability(ctx, channelCap, host.ChannelCapabilityPath(sourcePort, sourceChannel)) {
Expand Down
24 changes: 8 additions & 16 deletions modules/core/04-channel/keeper/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,37 +218,29 @@ func (suite *KeeperTestSuite) TestSendPacket() {
channelCap = capabilitytypes.NewCapability(5)
}, false},
{
"invalid flush status: FLUSHING",
"channel is in FLUSH_COMPLETE state",
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
channel.State = types.STATE_FLUSHCOMPLETE
path.EndpointA.SetChannel(channel)
},
false,
},
{
"channel is in INITUPGRADE state",
"channel is in FLUSHING state",
func() {
suite.coordinator.Setup(path)

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

err := path.EndpointB.ChanUpgradeInit()
suite.Require().NoError(err)

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

0 comments on commit e78a308

Please sign in to comment.