z2c_update_client_filetest.gno
1.23 Kb · 39 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// UpdateClient trustedHeight not found
13func main(cur realm) {
14 // CreateClient and RegisterCounterparty
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 // Update clientID
26 var (
27 newHeight = clientState.LatestHeight.RevisionHeight + 3
28 newTimestamp = consensusState.Timestamp.Add(time.Minute)
29 trustedHeight = types.NewHeight(2, 3)
30 msgHeader = tmtesting.GenMsgHeader(
31 chainID, newTimestamp, apphash, newHeight, trustedHeight, trustedValset, trustedValset, trustedValset,
32 )
33 )
34
35 core.UpdateClient(cross(cur), clientID, msgHeader)
36}
37
38// Error:
39// could not get trusted consensus state for Header at TrustedHeight: 2/3