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

z_delete_thread_06_filetest.gno

1.27 Kb · 48 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_delete_thread_06_filetest
 2
 3// Open board: Test deleting a reply of another non member user
 4package z_delete_thread_06_filetest
 5
 6// SEND: 1000000ugnot
 7
 8import (
 9	"chain"
10	"testing"
11
12	"gno.land/p/gnoland/boards/v0"
13
14	boards2 "gno.land/r/gnoland/boards2/v0"
15)
16
17const (
18	owner address = "g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"
19	user  address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
20	user2 address = "g125t352u4pmdrr57emc4pe04y40sknr5ztng5mt"
21)
22
23var (
24	bid boards.ID // Operate on board DAO
25	tid boards.ID
26)
27
28func init(cur realm) {
29	testing.SetRealm(testing.NewUserRealm(owner))
30	bid = boards2.CreateBoard(cross(cur), "test123", false, true)
31
32	// Make sure user account has the required amount of GNOT for open board actions
33	testing.IssueCoins(user, chain.Coins{{"ugnot", 3_000_000_000}})
34
35	// Create a new reply as a non member user
36	testing.SetRealm(testing.NewUserRealm(user))
37	tid = boards2.CreateThread(cross(cur), bid, "Title", "Body")
38}
39
40func main(cur realm) {
41	testing.SetRealm(testing.NewUserRealm(user2))
42
43	// Try to delete the thread of another non member user
44	boards2.DeleteThread(cross(cur), bid, tid)
45}
46
47// Error:
48// unauthorized, user g125t352u4pmdrr57emc4pe04y40sknr5ztng5mt doesn't have the required permission