Search Apps Documentation Source Content File Folder Download Copy Actions Download

z2l_update_client_filetest.gno

1.50 Kb · 43 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 validatorhash and nextValidatorHash 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		valset        = tmtesting.GenValset()
31		nextValset    = tmtesting.GenValset()
32	)
33	// Alter valset
34	valset.Validators[0].VotingPower++
35	msgHeader := tmtesting.GenMsgHeader(
36		chainID, newTimestamp, apphash, newHeight, trustedHeight, valset, nextValset, trustedValset,
37	)
38
39	core.UpdateClient(cross(cur), clientID, msgHeader)
40}
41
42// Error:
43// expected old header next validators (ffd80d3732ba201715593c01b2c913aeb2a4fd2433776f61d703fc2d81496caa) to match those from new header (6091db5499156b9e20fce74692a505af4ec365378e16f58777947f852ccc5aa1)