z_32_a_filetest.gno
1.28 Kb ยท 53 lines
1// Open board: Test deleting a thread 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 boards.ID
24)
25
26func init() {
27 testing.SetRealm(testing.NewUserRealm(owner))
28 bid = boards2.CreateBoard(cross, "test123", false, true)
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 // Register a username which is required to be able to add
34 // a reply and then create a new reply as a non member user.
35 testing.SetRealm(testing.NewUserRealm(user))
36 users.Register(cross, "user123")
37 tid = boards2.CreateThread(cross, bid, "Title", "Body")
38}
39
40func main() {
41 testing.SetRealm(testing.NewUserRealm(user))
42
43 // Delete the thread as the non member user that created it
44 boards2.DeleteThread(cross, bid, tid)
45
46 // Ensure reply doesn't exist
47 println(tid == 1)
48 println(boards2.Render("test123/1"))
49}
50
51// Output:
52// true
53// Thread does not exist with ID: 1