Search Apps Documentation Source Content File Folder Download Copy Actions Download

z7g_recv_packet_filetest.gno

1.60 Kb · 54 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 wrong number of proofs compared to specs
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		},
47		ProofHeight: trustedHeight,
48	}
49
50	core.RecvPacket(cross(cur), recvPacket)
51}
52
53// Error:
54// failed packet commitment verification for client (07-tendermint-1): length of specs: 2 not equal to length of proof: 1