z2j_update_client_filetest.gno
1.30 Kb · 41 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 revision number mismatch
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 + 1
28 newTimestamp = consensusState.Timestamp.Add(time.Minute)
29 trustedHeight = clientState.LatestHeight
30 )
31 // Alter chainID (same revision number)
32 chainID = "other-chain-id-2"
33 msgHeader := tmtesting.GenMsgHeader(
34 chainID, newTimestamp, apphash, newHeight, trustedHeight, trustedValset, trustedValset, trustedValset,
35 )
36
37 core.UpdateClient(cross(cur), clientID, msgHeader)
38}
39
40// Error:
41// header belongs to another chain "other-chain-id-2", not "chain-id-2"