Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_34_a_filetest.gno

1.34 Kb ยท 54 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	users "gno.land/r/gnoland/users/v1"
14)
15
16const (
17	owner address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq" // @devx
18	user  address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
19)
20
21var (
22	bid      boards.ID // Operate on board DAO
23	tid, rid boards.ID
24)
25
26func init() {
27	testing.SetRealm(testing.NewUserRealm(owner))
28	bid = boards2.CreateBoard(cross, "test123", false, true)
29	tid = boards2.CreateThread(cross, bid, "Title", "Body")
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	// Register a username which is required to be able to add
35	// a reply and then create a new reply as a non member user.
36	testing.SetRealm(testing.NewUserRealm(user))
37	users.Register(cross, "user123")
38	rid = boards2.CreateReply(cross, bid, tid, 0, "Comment")
39}
40
41func main() {
42	testing.SetRealm(testing.NewUserRealm(user))
43
44	// Delete the reply as the non member user that created it
45	boards2.DeleteReply(cross, bid, tid, rid)
46
47	// Ensure reply doesn't exist
48	println(rid == 2)
49	println(boards2.Render("test123/1/2"))
50}
51
52// Output:
53// true
54// Reply does not exist with ID: 2