Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_delete_reply_07_filetest.gno

1.31 Kb · 53 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_delete_reply_07_filetest
 2
 3// Open board: Test deleting a reply as the non member user that created it
 4package z_delete_reply_07_filetest
 5
 6// SEND: 1000000ugnot
 7
 8import (
 9	"chain"
10	"testing"
11
12	"gno.land/p/gnoland/boards"
13
14	boards2 "gno.land/r/gnoland/boards2/v1"
15)
16
17const (
18	owner address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
19	user  address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
20)
21
22var (
23	bid      boards.ID // Operate on board DAO
24	tid, rid boards.ID
25)
26
27func init(cur realm) {
28	testing.SetRealm(testing.NewUserRealm(owner))
29	bid = boards2.CreateBoard(cross(cur), "test123", false, true)
30	tid = boards2.CreateThread(cross(cur), bid, "Title", "Body")
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	rid = boards2.CreateReply(cross(cur), bid, tid, 0, "Comment")
38}
39
40func main(cur realm) {
41	testing.SetRealm(testing.NewUserRealm(user))
42
43	// Delete the reply as the non member user that created it
44	boards2.DeleteReply(cross(cur), bid, tid, rid)
45
46	// Ensure reply doesn't exist
47	println(rid == 2)
48	println(boards2.Render("test123/1/2"))
49}
50
51// Output:
52// true
53// Reply not found