z7j_recv_packet_filetest.gno
1.70 Kb · 57 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 fails invalid proof
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 counterpartyID = "07-tendermint-42"
23 )
24 clientID := core.CreateClient(cross(cur), clientState, consensusState)
25 core.RegisterCounterparty(cross(cur), clientID, [][]byte{[]byte("iavlStoreKey"), []byte("prefix2")}, counterpartyID)
26
27 // Receive the packet
28 recvPacket := types.MsgRecvPacket{
29 Packet: types.Packet{
30 Sequence: 1,
31 SourceClient: counterpartyID,
32 DestinationClient: clientID,
33 TimeoutTimestamp: uint64(time.Now().Add(time.Hour).Unix()),
34 Payloads: []types.Payload{{
35 SourcePort: "appID",
36 DestinationPort: "destinationPort",
37 Encoding: "application/json",
38 Value: []byte("{}"),
39 Version: "v1",
40 }},
41 },
42 ProofCommitment: []ics23.CommitmentProof{
43 ics23.CommitmentProof_Exist{
44 Exist: &ics23.ExistenceProof{},
45 },
46 ics23.CommitmentProof_Exist{
47 Exist: &ics23.ExistenceProof{},
48 },
49 },
50 ProofHeight: trustedHeight,
51 }
52
53 core.RecvPacket(cross(cur), recvPacket)
54}
55
56// Error:
57// failed packet commitment verification for client (07-tendermint-1): could not calculate proof root at index 0, merkle tree may be empty. existence Proof needs defined LeafOp