Search Apps Documentation Source Content File Folder Download Copy Actions Download

z1d_on_send_packet_filetest.gno

1.27 Kb · 44 lines
 1// PKGPATH: gno.land/r/aib/main
 2package main
 3
 4import (
 5	"time"
 6
 7	tmtesting "gno.land/p/aib/ibc/lightclient/tendermint/testing"
 8	"gno.land/p/aib/ibc/types"
 9
10	"gno.land/r/aib/ibc/apps/transfer"
11	"gno.land/r/aib/ibc/core"
12)
13
14// OnSendPacket: invalid Value
15func main(cur realm) {
16	var (
17		chainID        = "chain-id-2"
18		clientState    = tmtesting.NewClientState(chainID, types.NewHeight(2, 2))
19		apphash        = tmtesting.Hash("apphash")
20		trustedValset  = tmtesting.GenValset()
21		consensusState = tmtesting.GenConsensusState(time.Now(), apphash, trustedValset.Hash())
22	)
23	clientID := core.CreateClient(cross(cur), clientState, consensusState)
24	core.RegisterCounterparty(cross(cur), clientID, [][]byte{[]byte("iavlStoreKey"), []byte("prefix2")}, "07-tendermint-2")
25
26	packet := types.MsgSendPacket{
27		SourceClient:     clientID,
28		TimeoutTimestamp: uint64(time.Now().Add(time.Hour).Unix()),
29		Payloads: []types.Payload{
30			{
31				SourcePort:      transfer.PortID,
32				DestinationPort: transfer.PortID,
33				Encoding:        transfer.EncodingProtobuf,
34				Value:           []byte("{}"),
35				Version:         transfer.V1,
36			},
37		},
38	}
39
40	core.SendPacket(cross(cur), packet)
41}
42
43// Error:
44// send packet failed for payload #0 app "transfer": decoding FungibleTokenPacketData: unexpected wire type 3 for field 15