admin_test.gno
1.58 Kb · 47 lines
1package valopers
2
3import (
4 "testing"
5
6 "gno.land/p/moul/authz"
7 "gno.land/p/nt/uassert/v0"
8)
9
10// Earlier this test also asserted a panic ("action can only be
11// executed by the contract") when called without SetOriginCaller.
12// That panic was emitted by a `unsafe.CurrentRealm() == contractAddr`
13// check inside authz.ContractAuthority.Authorize, which has been
14// removed — it was .Title()-bypassable (runtime.CurrentRealm inside a
15// non-crossing closure walks past non-crossing frames to the
16// most-recent crossing ancestor, so a malicious caller could shape
17// the call chain to make the check resolve to contractAddr).
18//
19// Caller authentication is now upstream of the deleted gate:
20// authz.Authorizer.DoByCurrent requires `rlm.IsCurrent()`, and the
21// contract handler closure (registered at init in this realm) is the
22// remaining Class-4 trust root by lexical capture. There is no
23// negative path here to assert, so the prior expectation was retired
24// along with its source.
25func TestUpdateInstructions(cur realm, t *testing.T) {
26 auth = authz.NewWithAuthority(
27 authz.NewContractAuthority(
28 "gno.land/r/gov/dao",
29 func(title string, action authz.PrivilegedAction) error {
30 return action()
31 },
32 ),
33 )
34
35 newInstructions := "new instructions"
36
37 uassert.NotPanics(t, cur, func() {
38 updateInstructions(0, cur, newInstructions)
39 })
40
41 uassert.Equal(t, newInstructions, instructions)
42}
43
44// TestUpdateMinFee was removed: register_fee now lives in sysparams
45// (node:valoper:register_fee), governed via the generic
46// NewSysParamUint64PropRequest factory. See proposal.gno for the
47// replacement flow.