Skip to content

Commit 7fe0553

Browse files
chore: update tests to use new SendPacket API (backport #2567) (#2591)
* chore: update tests to use new SendPacket API (#2567) * chore: update tests to use new SendPacket API * add changelog * remove source port and source channel from parameter list of SendPacket Co-authored-by: Carlos Rodriguez <crodveg@gmail.com> (cherry picked from commit 8ce603d) # Conflicts: # modules/core/ante/ante_test.go # modules/light-clients/07-tendermint/client_state_test.go * fix conflicts * fix merge conflict * fixing conflicts * alignment * alignment * delete file * review comment Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
1 parent 01b4f3a commit 7fe0553

File tree

9 files changed

+352
-257
lines changed

9 files changed

+352
-257
lines changed

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

+10-7
Original file line numberDiff line numberDiff line change
@@ -391,20 +391,21 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() {
391391
{
392392
"packet already timed out",
393393
func() {
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)
394+
timeoutHeight := clienttypes.GetSelfHeight(suite.chainB.GetContext())
397395

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

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

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)
408409
msg.PacketId = packetID
409410
},
410411
false,
@@ -461,11 +462,13 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() {
461462
suite.SetupTest()
462463
suite.coordinator.Setup(suite.path) // setup channel
463464

465+
timeoutHeight := clienttypes.NewHeight(clienttypes.ParseChainID(suite.chainB.ChainID), 100)
466+
464467
// send a packet to incentivize
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)
468+
sequence, err := suite.path.EndpointA.SendPacket(timeoutHeight, 0, ibctesting.MockPacketData)
468469
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)
469472

470473
fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee)
471474
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-
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)
344+
sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, 0, ibctesting.MockPacketData)
346345
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-
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)
438+
sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, 0, ibctesting.MockPacketData)
440439
suite.Require().NoError(err)
441440

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

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-
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)
543+
sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, 0, ibctesting.MockPacketData)
545544
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-
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)
643+
sequence, err := path.EndpointA.SendPacket(defaultTimeoutHeight, 0, ibctesting.MockPacketData)
645644
suite.Require().NoError(err)
646645

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

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)