z5b_acknowledgement_filetest.gno
1.76 Kb · 62 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 assert ValidateBasic invoked
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 )
24 clientID := core.CreateClient(cross(cur), clientState, consensusState)
25 core.RegisterCounterparty(cross(cur), clientID, [][]byte{[]byte("iavlStoreKey"), []byte("prefix2")}, "07-tendermint-2")
26 // Register app
27 var (
28 app = appstesting.NewApp(cross(cur))
29 appPortID = "app"
30 )
31 core.RegisterApp(cross(cur), appPortID, app)
32 // Send a packet
33 sendPacket := types.MsgSendPacket{
34 SourceClient: clientID,
35 TimeoutTimestamp: uint64(time.Now().Add(time.Hour).Unix()),
36 Payloads: []types.Payload{{
37 SourcePort: appPortID,
38 DestinationPort: "destinationPort",
39 Encoding: "application/json",
40 Value: []byte("{}"),
41 Version: "v1",
42 }},
43 }
44 sequence := core.SendPacket(cross(cur), sendPacket)
45
46 // Acknowledge the packet
47 ackPacket := types.MsgAcknowledgement{
48 Packet: types.Packet{
49 Sequence: sequence,
50 SourceClient: clientID,
51 DestinationClient: "",
52 Payloads: sendPacket.Payloads,
53 },
54 ProofAcked: []ics23.CommitmentProof{},
55 ProofHeight: trustedHeight,
56 }
57
58 core.Acknowledgement(cross(cur), ackPacket)
59}
60
61// Error:
62// cannot submit an empty acknowledgement proof