Skip to content

Commit 6927904

Browse files
committedOct 22, 2022
Revert "chore: update tests to use new SendPacket API"
This reverts commit 0729a1c.
1 parent 0729a1c commit 6927904

File tree

8 files changed

+226
-322
lines changed

8 files changed

+226
-322
lines changed
 

‎modules/apps/29-fee/keeper/msg_server_test.go

+7-10
Original file line numberDiff line numberDiff line change
@@ -391,21 +391,20 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() {
391391
{
392392
"packet already timed out",
393393
func() {
394-
timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext())
394+
// try to incentivze a packet which is timed out
395+
packetID := channeltypes.NewPacketID(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, msg.PacketId.Sequence+1)
396+
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)
395397

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

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

404-
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)
405405
err = suite.path.EndpointA.TimeoutPacket(packet)
406406
suite.Require().NoError(err)
407407

408-
packetID := channeltypes.NewPacketID(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, sequence)
409408
msg.PacketId = packetID
410409
},
411410
false,
@@ -462,13 +461,11 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() {
462461
suite.SetupTest()
463462
suite.coordinator.Setup(suite.path) // setup channel
464463

465-
timeoutHeight := clienttypes.NewHeight(clienttypes.ParseChainID(suite.chainB.ChainID), 100)
466-
467464
// send a packet to incentivize
468-
sequence, err := suite.path.EndpointA.SendPacket(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, timeoutHeight, 0, ibctesting.MockPacketData)
465+
packetID := channeltypes.NewPacketID(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, 1)
466+
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)
467+
err := suite.path.EndpointA.SendPacket(packet)
469468
suite.Require().NoError(err)
470-
packetID := channeltypes.NewPacketID(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, sequence)
471-
packet = channeltypes.NewPacket(ibctesting.MockPacketData, packetID.Sequence, packetID.PortId, packetID.ChannelId, suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID, timeoutHeight, 0)
472469

473470
fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee)
474471
packetFee := types.NewPacketFee(fee, suite.chainA.SenderAccount.GetAddress().String(), nil)

‎modules/core/03-connection/keeper/verify_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ func (suite *KeeperTestSuite) TestVerifyPacketCommitment() {
341341
path = ibctesting.NewPath(suite.chainA, suite.chainB)
342342
suite.coordinator.Setup(path)
343343

344-
sequence, err := path.EndpointA.SendPacket(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, defaultTimeoutHeight, 0, ibctesting.MockPacketData)
344+
packet = channeltypes.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, 0)
345+
err := path.EndpointA.SendPacket(packet)
345346
suite.Require().NoError(err)
346-
packet = channeltypes.NewPacket(ibctesting.MockPacketData, sequence, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, defaultTimeoutHeight, 0)
347347

348348
// reset variables
349349
heightDiff = 0
@@ -435,14 +435,14 @@ func (suite *KeeperTestSuite) TestVerifyPacketAcknowledgement() {
435435
suite.coordinator.Setup(path)
436436

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

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

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

@@ -540,9 +540,9 @@ func (suite *KeeperTestSuite) TestVerifyPacketReceiptAbsence() {
540540
suite.coordinator.Setup(path)
541541

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

547547
// reset variables
548548
heightDiff = 0
@@ -640,14 +640,14 @@ func (suite *KeeperTestSuite) TestVerifyNextSequenceRecv() {
640640
suite.coordinator.Setup(path)
641641

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

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

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

0 commit comments

Comments
 (0)