Search Apps Documentation Source Content File Folder Download Copy Actions Download

z3h_send_packet_filetest.gno

1.13 Kb · 40 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/r/aib/ibc/core"
10)
11
12// SendPacket fails no registered app
13func main(cur realm) {
14	var (
15		chainID        = "chain-id-2"
16		clientState    = tmtesting.NewClientState(chainID, types.NewHeight(2, 2))
17		apphash        = tmtesting.Hash("apphash")
18		trustedValset  = tmtesting.GenValset()
19		consensusState = tmtesting.GenConsensusState(time.Now(), apphash, trustedValset.Hash())
20	)
21	clientID := core.CreateClient(cross(cur), clientState, consensusState)
22	core.RegisterCounterparty(cross(cur), clientID, [][]byte{[]byte("iavlStoreKey"), []byte("prefix2")}, "07-tendermint-2")
23
24	packet := types.MsgSendPacket{
25		SourceClient:     clientID,
26		TimeoutTimestamp: uint64(time.Now().Add(time.Hour).Unix()),
27		Payloads: []types.Payload{{
28			SourcePort:      "sourcePort",
29			DestinationPort: "destinationPort",
30			Encoding:        "application/json",
31			Value:           []byte("{}"),
32			Version:         "v1",
33		}},
34	}
35
36	core.SendPacket(cross(cur), packet)
37}
38
39// Error:
40// no registered app for port sourcePort