z5g_acknowledgement_filetest.gno
1.81 Kb · 66 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 appstesting "gno.land/r/aib/ibc/apps/testing"
11 "gno.land/r/aib/ibc/core"
12)
13
14// Acknowledgement no commitment found returns noop (res=1)
15func main(cur realm) {
16 var (
17 chainID = "chain-id-2"
18 trustedHeight = types.NewHeight(2, 2)
19 clientState = tmtesting.NewClientState(chainID, trustedHeight)
20 apphash = tmtesting.Hash("apphash")
21 trustedValset = tmtesting.GenValset()
22 consensusState = tmtesting.GenConsensusState(time.Now(), apphash, trustedValset.Hash())
23 counterpartyID = "07-tendermint-42"
24 )
25 clientID := core.CreateClient(cross(cur), clientState, consensusState)
26 core.RegisterCounterparty(cross(cur), clientID, [][]byte{[]byte("iavlStoreKey"), []byte("prefix2")}, counterpartyID)
27 // Register app
28 var (
29 app = appstesting.NewApp(cross(cur))
30 appPortID = "app"
31 )
32 core.RegisterApp(cross(cur), appPortID, app)
33
34 // Acknowledge the packet
35 ackPacket := types.MsgAcknowledgement{
36 Packet: types.Packet{
37 Sequence: 42,
38 SourceClient: clientID,
39 DestinationClient: counterpartyID,
40 TimeoutTimestamp: 1,
41 Payloads: []types.Payload{{
42 SourcePort: appPortID,
43 DestinationPort: "destinationPort",
44 Encoding: "application/json",
45 Value: []byte("{}"),
46 Version: "v1",
47 }},
48 },
49 Acknowledgement: types.Acknowledgement{
50 AppAcknowledgements: [][]byte{[]byte("ack")},
51 },
52 ProofAcked: []ics23.CommitmentProof{
53 ics23.CommitmentProof_Exist{
54 Exist: &ics23.ExistenceProof{},
55 },
56 },
57 ProofHeight: trustedHeight,
58 }
59
60 res := core.Acknowledgement(cross(cur), ackPacket)
61
62 println("res:", res)
63}
64
65// Output:
66// res: (1 gno.land/p/aib/ibc/types.ResponseResultType)