Search Apps Documentation Source Content File Folder Download Copy Actions Download

z2g_update_client_filetest.gno

1.54 Kb · 44 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 consensusState.NextValidatorHash and nextValset 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 trustedValset
34	trustedValset.Validators[0].VotingPower = 42
35	msgHeader := tmtesting.GenMsgHeader(
36		chainID, newTimestamp, apphash, newHeight, trustedHeight, valset,
37		nextValset, trustedValset,
38	)
39
40	core.UpdateClient(cross(cur), clientID, msgHeader)
41}
42
43// Error:
44// trusted validators do not hash to latest trusted validators. Expected: "ffd80d3732ba201715593c01b2c913aeb2a4fd2433776f61d703fc2d81496caa", got: "9232cad0b329a571879d270410b02ff96635f8b71f77544cb768a5fcf56f0719"