Search Apps Documentation Source Content File Folder Download Copy Actions Download

z3f_send_packet_filetest.gno

1.30 Kb · 45 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/r/aib/ibc/core"
11)
12
13// SendPacket fails client status Expired
14func main(cur realm) {
15	var (
16		chainID        = "chain-id-2"
17		clientState    = tmtesting.NewClientState(chainID, types.NewHeight(2, 2))
18		apphash        = tmtesting.Hash("apphash")
19		trustedValset  = tmtesting.GenValset()
20		consensusState = tmtesting.GenConsensusState(time.Now(), apphash, trustedValset.Hash())
21	)
22	clientID := core.CreateClient(cross(cur), clientState, consensusState)
23	core.RegisterCounterparty(cross(cur), clientID, [][]byte{[]byte("iavlStoreKey"), []byte("prefix2")}, "07-tendermint-2")
24
25	// Change block time to expire the lightclient
26	ctx := testing.GetContext()
27	ctx.Time = time.Now().Add(clientState.TrustingPeriod)
28	testing.SetContext(ctx)
29
30	packet := types.MsgSendPacket{
31		SourceClient:     clientID,
32		TimeoutTimestamp: uint64(ctx.Time.Add(time.Hour).Unix()),
33		Payloads: []types.Payload{{
34			SourcePort:      "transfer",
35			DestinationPort: "transfer",
36			Encoding:        "application/json",
37			Value:           []byte("{}"),
38			Version:         "v1",
39		}},
40	}
41	core.SendPacket(cross(cur), packet)
42}
43
44// Error:
45// client (07-tendermint-1) status is Expired