Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_delete_reply_07_filetest.gno

1.17 Kb · 51 lines
 1// Open board: Test deleting a reply as the non member user that created it
 2package main
 3
 4// SEND: 1000000ugnot
 5
 6import (
 7	"chain"
 8	"testing"
 9
10	"gno.land/p/gnoland/boards"
11
12	boards2 "gno.land/r/gnoland/boards2/v1"
13)
14
15const (
16	owner address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq"
17	user  address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
18)
19
20var (
21	bid      boards.ID // Operate on board DAO
22	tid, rid boards.ID
23)
24
25func init() {
26	testing.SetRealm(testing.NewUserRealm(owner))
27	bid = boards2.CreateBoard(cross, "test123", false, true)
28	tid = boards2.CreateThread(cross, bid, "Title", "Body")
29
30	// Make sure user account has the required amount of GNOT for open board actions
31	testing.IssueCoins(user, chain.Coins{{"ugnot", 3_000_000_000}})
32
33	// Create a new reply as a non member user
34	testing.SetRealm(testing.NewUserRealm(user))
35	rid = boards2.CreateReply(cross, bid, tid, 0, "Comment")
36}
37
38func main() {
39	testing.SetRealm(testing.NewUserRealm(user))
40
41	// Delete the reply as the non member user that created it
42	boards2.DeleteReply(cross, bid, tid, rid)
43
44	// Ensure reply doesn't exist
45	println(rid == 2)
46	println(boards2.Render("test123/1/2"))
47}
48
49// Output:
50// true
51// Reply not found