z10b_upgrade_client_filetest.gno
1.28 Kb · 37 lines
1// PKGPATH: gno.land/r/aib/main
2package main
3
4
5import (
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// UpgradeClient failure: caller not in relayer whitelist
14func main(cur realm) {
15 // Bootstrap: the test caller is admin, but we add a DIFFERENT address
16 // as the only authorized relayer. Subsequent core entrypoints called
17 // from the test caller fail the relayer gate.
18 core.SetAdmin(cross(cur), "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")
19 core.AddRelayer(cross(cur), "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")
20
21 var (
22 clientState = tmtesting.NewClientState("chain-id-2", types.NewHeight(2, 2))
23 trustedValset = tmtesting.GenValset()
24 consensusState = tmtesting.GenConsensusState(time.Now(), tmtesting.Hash("apphash"), trustedValset.Hash())
25 )
26 clientID := core.CreateClient(cross(cur), clientState, consensusState)
27
28 // Replace the whitelist entry with a different address so the test
29 // caller is no longer authorized.
30 core.RemoveRelayer(cross(cur), "g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm")
31 core.AddRelayer(cross(cur), "g100000000000000000000000000000000000000")
32
33 core.UpgradeClient(cross(cur), clientID, nil, nil, nil, nil)
34}
35
36// Error:
37// unauthorized relayer g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm