Skip to content

Commit adc8e58

Browse files
committed
Review fixes
Better comments and naming as well as removed some dead code
1 parent a114fc6 commit adc8e58

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

tests/e2e/ibc2_test.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package e2e_test
22

33
import (
4-
"encoding/json"
54
"testing"
65
"time"
76

@@ -57,21 +56,11 @@ func TestIBC2SendMsg(t *testing.T) {
5756

5857
// IBC v2 Payload from contract on Chain B to contract on Chain A
5958
payload := mockv2.NewMockPayload(contractPortB, contractPortA)
60-
type PacketMsg struct {
61-
ChannelID string `json:"channel_id"`
62-
}
63-
64-
packetMsg := PacketMsg{
65-
ChannelID: path.EndpointB.ClientID,
66-
}
67-
packetMsgBz, err := json.Marshal(packetMsg)
68-
require.NoError(t, err)
69-
payload.Value = packetMsgBz
7059

7160
// Message timeout
7261
timeoutTimestamp := uint64(chainB.GetContext().BlockTime().Add(time.Minute * 5).Unix())
7362

74-
_, err = path.EndpointB.MsgSendPacket(timeoutTimestamp, payload)
63+
_, err := path.EndpointB.MsgSendPacket(timeoutTimestamp, payload)
7564
require.NoError(t, err)
7665

7766
// First message send through test

tests/wasmibctesting/utils.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ func (chain *WasmTestChain) CaptureIBCEvents(result *abci.ExecTxResult) {
117117
// IBCv1 and IBCv2 `EventTypeSendPacket` are the same
118118
// and the [`ParsePacketsFromEvents`] parses both of them as they were IBCv1
119119
// so we have to filter them here.
120+
//
121+
// While parsing IBC2 events in IBC1 context the only overlapping event is the
122+
// `AttributeKeyTimeoutTimestamp` so to determine if the wrong set of events was parsed
123+
// we should be able to check if any other field in the packet is not set.
120124
var toSendFiltered []channeltypes.Packet
121125
for _, packet := range toSend {
122126
if packet.SourcePort != "" {
@@ -361,7 +365,7 @@ func RelayPacketWithoutAck(path *ibctesting.Path, packet channeltypes.Packet) er
361365
// if a relay step fails or the packet commitment does not exist on either endpoint.
362366
// In contrast to RelayPacket, this function does not acknowledge the packet and expects it to have no acknowledgement yet.
363367
// It is useful for testing async acknowledgement.
364-
func RelayPacketV2(path *WasmPath, packet channeltypesv2.Packet) error {
368+
func RelayPacketWithoutAckV2(path *WasmPath, packet channeltypesv2.Packet) error {
365369
pc := path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeperV2.GetPacketCommitment(path.EndpointA.Chain.GetContext(), packet.GetSourceClient(), packet.GetSequence())
366370
if bytes.Equal(pc, channeltypesv2.CommitPacket(packet)) {
367371
// packet found, relay from A to B
@@ -443,7 +447,7 @@ func RelayPendingPacketsV2(path *WasmPath) error {
443447
require.NoError(path.chainA, src.UpdateClient())
444448
path.chainA.Logf("Relay: %d PacketsV2 A->B, %d PacketsV2 B->A\n", len(*path.chainA.PendingSendPacketsV2), len(*path.chainB.PendingSendPacketsV2))
445449
for _, v := range *path.chainA.PendingSendPacketsV2 {
446-
err := RelayPacketV2(path, v)
450+
err := RelayPacketWithoutAckV2(path, v)
447451
if err != nil {
448452
return err
449453
}
@@ -454,7 +458,7 @@ func RelayPendingPacketsV2(path *WasmPath) error {
454458
src = path.EndpointB
455459
require.NoError(path.chainB, src.UpdateClient())
456460
for _, v := range *path.chainB.PendingSendPacketsV2 {
457-
err := RelayPacketV2(path, v)
461+
err := RelayPacketWithoutAckV2(path, v)
458462
if err != nil {
459463
return err
460464
}

0 commit comments

Comments
 (0)