z_hub_0_c_filetest.gno
1.10 Kb · 42 lines
1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_hub_0_c_filetest
2
3// Test that reads are open to any caller
4package z_hub_0_c_filetest
5
6import (
7 "testing"
8
9 "gno.land/p/gnoland/boards"
10
11 boards2 "gno.land/r/gnoland/boards2/v1"
12)
13
14const owner address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
15
16var boardID boards.ID
17
18func init(cur realm) {
19 testing.SetRealm(testing.NewUserRealm(owner))
20 boardID = boards2.CreateBoard(cross(cur), "test123", false, false)
21}
22
23func main(cur realm) {
24 // The read API performs no caller authorization: an EOA and a realm
25 // outside the Boards2 namespace must both be able to read.
26 testing.SetRealm(testing.NewUserRealm(owner))
27 _, found := boards2.GetBoard(uint64(boardID))
28 println("user realm:", found)
29
30 testing.SetRealm(testing.NewCodeRealm("gno.land/r/unrelated/caller"))
31 _, found = boards2.GetBoard(uint64(boardID))
32 println("unrelated realm:", found)
33
34 println("threads:", len(boards2.GetThreads(uint64(boardID), 0, 10)))
35 println("members:", len(boards2.GetMembers(uint64(boardID), 0, 10)))
36}
37
38// Output:
39// user realm: true
40// unrelated realm: true
41// threads: 0
42// members: 1