Skip to content

Commit

Permalink
Revert "chore: update tests to use new SendPacket API"
Browse files Browse the repository at this point in the history
This reverts commit 0729a1c.
  • Loading branch information
crodriguezvega committed Oct 22, 2022
1 parent 0729a1c commit 6927904
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 322 deletions.
17 changes: 7 additions & 10 deletions modules/apps/29-fee/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,21 +391,20 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() {
{
"packet already timed out",
func() {
timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext())
// try to incentivze a packet which is timed out
packetID := channeltypes.NewPacketID(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, msg.PacketId.Sequence+1)
packet = channeltypes.NewPacket(ibctesting.MockPacketData, packetID.Sequence, packetID.PortId, packetID.ChannelId, suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID, clienttypes.GetSelfHeight(suite.chainB.GetContext()), 0)

// try to incentivize a packet which is timed out
sequence, err := suite.path.EndpointA.SendPacket(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, timeoutHeight, 0, ibctesting.MockPacketData)
err := suite.path.EndpointA.SendPacket(packet)
suite.Require().NoError(err)

// need to update chainA's client representing chainB to prove missing ack
err = suite.path.EndpointA.UpdateClient()
suite.Require().NoError(err)

packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID, timeoutHeight, 0)
err = suite.path.EndpointA.TimeoutPacket(packet)
suite.Require().NoError(err)

packetID := channeltypes.NewPacketID(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, sequence)
msg.PacketId = packetID
},
false,
Expand Down Expand Up @@ -462,13 +461,11 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() {
suite.SetupTest()
suite.coordinator.Setup(suite.path) // setup channel

timeoutHeight := clienttypes.NewHeight(clienttypes.ParseChainID(suite.chainB.ChainID), 100)

// send a packet to incentivize
sequence, err := suite.path.EndpointA.SendPacket(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, timeoutHeight, 0, ibctesting.MockPacketData)
packetID := channeltypes.NewPacketID(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, 1)
packet = channeltypes.NewPacket(ibctesting.MockPacketData, packetID.Sequence, packetID.PortId, packetID.ChannelId, suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID, clienttypes.NewHeight(clienttypes.ParseChainID(suite.chainB.ChainID), 100), 0)
err := suite.path.EndpointA.SendPacket(packet)
suite.Require().NoError(err)
packetID := channeltypes.NewPacketID(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, sequence)
packet = channeltypes.NewPacket(ibctesting.MockPacketData, packetID.Sequence, packetID.PortId, packetID.ChannelId, suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID, timeoutHeight, 0)

fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee)
packetFee := types.NewPacketFee(fee, suite.chainA.SenderAccount.GetAddress().String(), nil)
Expand Down
16 changes: 8 additions & 8 deletions modules/core/03-connection/keeper/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() {
path = ibctesting.NewPath(suite.chainA, suite.chainB)
suite.coordinator.Setup(path)

sequence, err := path.EndpointA.SendPacket(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, defaultTimeoutHeight, 0, ibctesting.MockPacketData)
packet = channeltypes.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, 0)
err := path.EndpointA.SendPacket(packet)
suite.Require().NoError(err)
packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, 0)

// reset variables
heightDiff = 0
Expand Down Expand Up @@ -435,14 +435,14 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() {
suite.coordinator.Setup(path)

// send and receive packet
sequence, err := path.EndpointA.SendPacket(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, defaultTimeoutHeight, 0, ibctesting.MockPacketData)
packet := channeltypes.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, 0)
err := path.EndpointA.SendPacket(packet)
suite.Require().NoError(err)

// increment receiving chain's (chainB) time by 2 hour to always pass receive
suite.coordinator.IncrementTimeBy(time.Hour * 2)
suite.coordinator.CommitBlock(suite.chainB)

packet := channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, 0)
err = path.EndpointB.RecvPacket(packet)
suite.Require().NoError(err)

Expand Down Expand Up @@ -540,9 +540,9 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() {
suite.coordinator.Setup(path)

// send, only receive in malleate if applicable
sequence, err := path.EndpointA.SendPacket(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, defaultTimeoutHeight, 0, ibctesting.MockPacketData)
packet = channeltypes.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, 0)
err := path.EndpointA.SendPacket(packet)
suite.Require().NoError(err)
packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, 0)

// reset variables
heightDiff = 0
Expand Down Expand Up @@ -640,14 +640,14 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() {
suite.coordinator.Setup(path)

// send and receive packet
sequence, err := path.EndpointA.SendPacket(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, defaultTimeoutHeight, 0, ibctesting.MockPacketData)
packet := channeltypes.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, 0)
err := path.EndpointA.SendPacket(packet)
suite.Require().NoError(err)

// increment receiving chain's (chainB) time by 2 hour to always pass receive
suite.coordinator.IncrementTimeBy(time.Hour * 2)
suite.coordinator.CommitBlock(suite.chainB)

packet := channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, 0)
err = path.EndpointB.RecvPacket(packet)
suite.Require().NoError(err)

Expand Down
Loading

0 comments on commit 6927904

Please sign in to comment.