z5l_acknowledgement_filetest.gno
2.17 Kb · 74 lines
1// PKGPATH: gno.land/r/aib/main
2package main
3
4import (
5 "testing"
6 "time"
7
8 tmtesting "gno.land/p/aib/ibc/lightclient/tendermint/testing"
9 "gno.land/p/aib/ibc/types"
10 "gno.land/p/aib/ics23"
11 appstesting "gno.land/r/aib/ibc/apps/testing"
12 "gno.land/r/aib/ibc/core"
13)
14
15// Acknowledgement unauthorized relayer
16func main(cur realm) {
17 core.SetAdmin(cross(cur), "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")
18 core.AddRelayer(cross(cur), "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")
19 var (
20 chainID = "chain-id-2"
21 trustedHeight = types.NewHeight(2, 2)
22 clientState = tmtesting.NewClientState(chainID, trustedHeight)
23 apphash = tmtesting.Hash("apphash")
24 trustedValset = tmtesting.GenValset()
25 consensusState = tmtesting.GenConsensusState(time.Now(), apphash, trustedValset.Hash())
26 counterpartyID = "07-tendermint-42"
27 )
28 clientID := core.CreateClient(cross(cur), clientState, consensusState)
29 core.RegisterCounterparty(cross(cur), clientID, [][]byte{[]byte("iavlStoreKey"), []byte("prefix2")}, counterpartyID)
30
31 var (
32 app = appstesting.NewApp(cross(cur))
33 appPortID = "app"
34 )
35 core.RegisterApp(cross(cur), appPortID, app)
36
37 sendPacket := types.MsgSendPacket{
38 SourceClient: clientID,
39 TimeoutTimestamp: uint64(time.Now().Add(time.Hour).Unix()),
40 Payloads: []types.Payload{{
41 SourcePort: appPortID,
42 DestinationPort: "destinationPort",
43 Encoding: "application/json",
44 Value: []byte("{}"),
45 Version: "v1",
46 }},
47 }
48 sequence := core.SendPacket(cross(cur), sendPacket)
49
50 ackPacket := types.MsgAcknowledgement{
51 Packet: types.Packet{
52 Sequence: sequence,
53 SourceClient: clientID,
54 DestinationClient: counterpartyID,
55 TimeoutTimestamp: 1,
56 Payloads: sendPacket.Payloads,
57 },
58 Acknowledgement: types.Acknowledgement{
59 AppAcknowledgements: [][]byte{[]byte("ack")},
60 },
61 ProofAcked: []ics23.CommitmentProof{
62 ics23.CommitmentProof_Exist{
63 Exist: &ics23.ExistenceProof{},
64 },
65 },
66 ProofHeight: trustedHeight,
67 }
68
69 testing.SetOriginCaller("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsx")
70 core.Acknowledgement(cross(cur), ackPacket)
71}
72
73// Error:
74// unauthorized relayer g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsx