z_delete_reply_08_filetest.gno
1.34 Kb · 49 lines
1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_delete_reply_08_filetest
2
3// Open board: Test deleting a reply of another non member user
4package z_delete_reply_08_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 user2 address = "g125t352u4pmdrr57emc4pe04y40sknr5ztng5mt"
21)
22
23var (
24 bid boards.ID // Operate on board DAO
25 tid, rid boards.ID
26)
27
28func init(cur realm) {
29 testing.SetRealm(testing.NewUserRealm(owner))
30 bid = boards2.CreateBoard(cross(cur), "test123", false, true)
31 tid = boards2.CreateThread(cross(cur), bid, "Title", "Body")
32
33 // Make sure user account has the required amount of GNOT for open board actions
34 testing.IssueCoins(user, chain.Coins{{"ugnot", 3_000_000_000}})
35
36 // Create a new reply as a non member user
37 testing.SetRealm(testing.NewUserRealm(user))
38 rid = boards2.CreateReply(cross(cur), bid, tid, 0, "Comment")
39}
40
41func main(cur realm) {
42 testing.SetRealm(testing.NewUserRealm(user2))
43
44 // Try to delete the reply of another non member user
45 boards2.DeleteReply(cross(cur), bid, tid, rid)
46}
47
48// Error:
49// unauthorized, user g125t352u4pmdrr57emc4pe04y40sknr5ztng5mt doesn't have the required permission