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_05_filetest.gno

1.24 Kb · 52 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_delete_thread_05_filetest
 2
 3// Open board: Test deleting a thread as the non member user that created it
 4package z_delete_thread_05_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)
21
22var (
23	bid boards.ID // Operate on board DAO
24	tid boards.ID
25)
26
27func init(cur realm) {
28	testing.SetRealm(testing.NewUserRealm(owner))
29	bid = boards2.CreateBoard(cross(cur), "test123", false, true)
30
31	// Make sure user account has the required amount of GNOT for open board actions
32	testing.IssueCoins(user, chain.Coins{{"ugnot", 3_000_000_000}})
33
34	// Create a new reply as a non member user
35	testing.SetRealm(testing.NewUserRealm(user))
36	tid = boards2.CreateThread(cross(cur), bid, "Title", "Body")
37}
38
39func main(cur realm) {
40	testing.SetRealm(testing.NewUserRealm(user))
41
42	// Delete the thread as the non member user that created it
43	boards2.DeleteThread(cross(cur), bid, tid)
44
45	// Ensure reply doesn't exist
46	println(tid == 1)
47	println(boards2.Render("test123/1"))
48}
49
50// Output:
51// true
52// Thread not found