admin_test.gno

1.20 Kb ยท 59 lines
 1package valopers
 2
 3import (
 4	"std"
 5	"testing"
 6
 7	"gno.land/p/demo/uassert"
 8	"gno.land/p/moul/authz"
 9)
10
11func TestUpdateInstructions(t *testing.T) {
12	auth = authz.NewWithAuthority(
13		authz.NewContractAuthority(
14			"gno.land/r/gov/dao",
15			func(title string, action authz.PrivilegedAction) error {
16				return action()
17			},
18		),
19	)
20
21	newInstructions := "new instructions"
22
23	uassert.PanicsWithMessage(t, "action can only be executed by the contract", func() {
24		updateInstructions(newInstructions)
25	})
26
27	testing.SetOriginCaller(std.DerivePkgAddr("gno.land/r/gov/dao"))
28
29	uassert.NotPanics(t, func() {
30		updateInstructions(newInstructions)
31	})
32
33	uassert.Equal(t, newInstructions, instructions)
34}
35
36func TestUpdateMinFee(t *testing.T) {
37	auth = authz.NewWithAuthority(
38		authz.NewContractAuthority(
39			"gno.land/r/gov/dao",
40			func(title string, action authz.PrivilegedAction) error {
41				return action()
42			},
43		),
44	)
45
46	newMinFee := int64(100)
47
48	uassert.PanicsWithMessage(t, "action can only be executed by the contract", func() {
49		updateMinFee(newMinFee)
50	})
51
52	testing.SetOriginCaller(std.DerivePkgAddr("gno.land/r/gov/dao"))
53
54	uassert.NotPanics(t, func() {
55		updateMinFee(newMinFee)
56	})
57
58	uassert.Equal(t, newMinFee, minFee.Amount)
59}