z_create_reply_14_filetest.gno
1.08 Kb · 48 lines
1// Open board: Test creating a new reply as a non member user
2package main
3
4// SEND: 1000000ugnot
5
6import (
7 "chain"
8 "strings"
9 "testing"
10
11 "gno.land/p/gnoland/boards"
12
13 boards2 "gno.land/r/gnoland/boards2/v1"
14)
15
16const (
17 owner address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq"
18 user address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
19 comment = "Test Comment"
20)
21
22var (
23 bid boards.ID // Operate on board DAO
24 tid 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
36func main() {
37 testing.SetRealm(testing.NewUserRealm(user))
38
39 // Non members should be able to add replies
40 boards2.CreateReply(cross, bid, tid, 0, comment)
41
42 // Render content must contain the reply
43 content := boards2.Render("test123/1")
44 println(strings.Contains(content, "\n> "+comment+"\n"))
45}
46
47// Output:
48// true