Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

security_test.gno

0.83 Kb · 26 lines
 1package game_world
 2
 3import (
 4	"chain"
 5	"testing"
 6
 7	"gno.land/p/nt/uassert/v0"
 8)
 9
10func TestGameWorldInterrealmSecurity(cur realm, t *testing.T) {
11	setupGameWorld(cross(cur), t)
12	setPolicyForTest(cross(cur), testGameTypeJump, 0, CreationModePublicCreator)
13
14	testing.SetOriginCaller(testCreator)
15	testing.SetOriginSend(chain.Coins{})
16	testing.SetRealm(testing.NewCodeRealm("gno.land/r/example/game_world_relay"))
17	uassert.AbortsWithMessage(t, cur, "contract calls not allowed: function must be called directly by user", func() {
18		CreateGameWorld(cross(cur), testGameTypeJump)
19	})
20
21	testing.SetOriginCaller(testAdmin)
22	testing.SetRealm(testing.NewCodeRealm("gno.land/r/example/game_world_admin_relay"))
23	uassert.AbortsWithMessage(t, cur, "admin or operator access required", func() {
24		AddApprovedCreator(cross(cur), testGameTypeJump, testCreator)
25	})
26}