Search Apps Documentation Source Content File Folder Download Copy Actions Download

z6l_timeout_filetest.gno

2.07 Kb · 71 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// Timeout 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	timeoutPacket := types.MsgTimeout{
51		Packet: types.Packet{
52			Sequence:          sequence,
53			SourceClient:      clientID,
54			DestinationClient: counterpartyID,
55			TimeoutTimestamp:  1,
56			Payloads:          sendPacket.Payloads,
57		},
58		ProofUnreceived: []ics23.CommitmentProof{
59			ics23.CommitmentProof_Nonexist{
60				Nonexist: &ics23.NonExistenceProof{},
61			},
62		},
63		ProofHeight: trustedHeight,
64	}
65
66	testing.SetOriginCaller("g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsx")
67	core.Timeout(cross(cur), timeoutPacket)
68}
69
70// Error:
71// unauthorized relayer g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsx