Search Apps Documentation Source Content File Folder Download Copy Actions Download

z7b_recv_packet_filetest.gno

1.32 Kb · 48 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	"gno.land/p/aib/ics23"
10	"gno.land/r/aib/ibc/core"
11)
12
13// RecvPacket assert ValidateBasic invoked
14func main(cur realm) {
15	var (
16		chainID        = "chain-id-2"
17		trustedHeight  = types.NewHeight(2, 2)
18		clientState    = tmtesting.NewClientState(chainID, trustedHeight)
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	// Receive the packet
27	recvPacket := types.MsgRecvPacket{
28		Packet: types.Packet{
29			Sequence:          1,
30			SourceClient:      clientID,
31			DestinationClient: "",
32			Payloads: []types.Payload{{
33				SourcePort:      "appID",
34				DestinationPort: "destinationPort",
35				Encoding:        "application/json",
36				Value:           []byte("{}"),
37				Version:         "v1",
38			}},
39		},
40		ProofCommitment: []ics23.CommitmentProof{},
41		ProofHeight:     trustedHeight,
42	}
43
44	core.RecvPacket(cross(cur), recvPacket)
45}
46
47// Error:
48// proof commitment can not be empty