z_34_b_filetest.gno
1.27 Kb ยท 50 lines
1// Open board: Test deleting a reply of another non member user
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 user2 address = "g125t352u4pmdrr57emc4pe04y40sknr5ztng5mt"
20)
21
22var (
23 bid boards.ID // Operate on board DAO
24 tid, rid boards.ID
25)
26
27func init() {
28 testing.SetRealm(testing.NewUserRealm(owner))
29 bid = boards2.CreateBoard(cross, "test123", false, true)
30 tid = boards2.CreateThread(cross, 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 // Register a username which is required to be able to add
36 // a reply and then create a new reply as a non member user.
37 testing.SetRealm(testing.NewUserRealm(user))
38 users.Register(cross, "user123")
39 rid = boards2.CreateReply(cross, bid, tid, 0, "Comment")
40}
41
42func main() {
43 testing.SetRealm(testing.NewUserRealm(user2))
44
45 // Try to delete the reply of another non member user
46 boards2.DeleteReply(cross, bid, tid, rid)
47}
48
49// Error:
50// unauthorized