github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/wasm/ibc_test.go (about)

     1  package wasm
     2  
     3  //import (
     4  //	"testing"
     5  //
     6  //	wasmvmtypes "github.com/CosmWasm/wasmvm/types"
     7  //	clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types"
     8  //	channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
     9  //	"github.com/stretchr/testify/assert"
    10  //)
    11  //
    12  //func TestMapToWasmVMIBCPacket(t *testing.T) {
    13  //	var myTimestamp uint64 = 1
    14  //	specs := map[string]struct {
    15  //		src channeltypes.Packet
    16  //		exp wasmvmtypes.IBCPacket
    17  //	}{
    18  //		"with height timeout": {
    19  //			src: IBCPacketFixture(),
    20  //			exp: wasmvmtypes.IBCPacket{
    21  //				Data:     []byte("myData"),
    22  //				Src:      wasmvmtypes.IBCEndpoint{PortID: "srcPort", ChannelID: "channel-1"},
    23  //				Dest:     wasmvmtypes.IBCEndpoint{PortID: "destPort", ChannelID: "channel-2"},
    24  //				Sequence: 1,
    25  //				Timeout:  wasmvmtypes.IBCTimeout{Block: &wasmvmtypes.IBCTimeoutBlock{Height: 1, Revision: 2}},
    26  //			},
    27  //		},
    28  //		"with time timeout": {
    29  //			src: IBCPacketFixture(func(p *channeltypes.Packet) {
    30  //				p.TimeoutTimestamp = myTimestamp
    31  //				p.TimeoutHeight = clienttypes.Height{}
    32  //			}),
    33  //			exp: wasmvmtypes.IBCPacket{
    34  //				Data:     []byte("myData"),
    35  //				Src:      wasmvmtypes.IBCEndpoint{PortID: "srcPort", ChannelID: "channel-1"},
    36  //				Dest:     wasmvmtypes.IBCEndpoint{PortID: "destPort", ChannelID: "channel-2"},
    37  //				Sequence: 1,
    38  //				Timeout:  wasmvmtypes.IBCTimeout{Timestamp: myTimestamp},
    39  //			},
    40  //		}, "with time and height timeout": {
    41  //			src: IBCPacketFixture(func(p *channeltypes.Packet) {
    42  //				p.TimeoutTimestamp = myTimestamp
    43  //			}),
    44  //			exp: wasmvmtypes.IBCPacket{
    45  //				Data:     []byte("myData"),
    46  //				Src:      wasmvmtypes.IBCEndpoint{PortID: "srcPort", ChannelID: "channel-1"},
    47  //				Dest:     wasmvmtypes.IBCEndpoint{PortID: "destPort", ChannelID: "channel-2"},
    48  //				Sequence: 1,
    49  //				Timeout: wasmvmtypes.IBCTimeout{
    50  //					Block:     &wasmvmtypes.IBCTimeoutBlock{Height: 1, Revision: 2},
    51  //					Timestamp: myTimestamp,
    52  //				},
    53  //			},
    54  //		},
    55  //	}
    56  //	for name, spec := range specs {
    57  //		t.Run(name, func(t *testing.T) {
    58  //			got := newIBCPacket(spec.src)
    59  //			assert.Equal(t, spec.exp, got)
    60  //		})
    61  //	}
    62  //}
    63  //
    64  //func IBCPacketFixture(mutators ...func(p *channeltypes.Packet)) channeltypes.Packet {
    65  //	r := channeltypes.Packet{
    66  //		Sequence:           1,
    67  //		SourcePort:         "srcPort",
    68  //		SourceChannel:      "channel-1",
    69  //		DestinationPort:    "destPort",
    70  //		DestinationChannel: "channel-2",
    71  //		Data:               []byte("myData"),
    72  //		TimeoutHeight: clienttypes.Height{
    73  //			RevisionHeight: 1,
    74  //			RevisionNumber: 2,
    75  //		},
    76  //		TimeoutTimestamp: 0,
    77  //	}
    78  //	for _, m := range mutators {
    79  //		m(&r)
    80  //	}
    81  //	return r
    82  //}