Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_create_reply_14_filetest.gno

1.20 Kb · 50 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v1/filetests/z_create_reply_14_filetest
 2
 3// Open board: Test creating a new reply as a non member user
 4package z_create_reply_14_filetest
 5
 6// SEND: 1000000ugnot
 7
 8import (
 9	"chain"
10	"strings"
11	"testing"
12
13	"gno.land/p/gnoland/boards"
14
15	boards2 "gno.land/r/gnoland/boards2/v1"
16)
17
18const (
19	owner   address = "g1rp7cmetn27eqlpjpc4vuusf8kaj746tysc0qgh"
20	user    address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
21	comment         = "Test Comment"
22)
23
24var (
25	bid boards.ID // Operate on board DAO
26	tid boards.ID
27)
28
29func init(cur realm) {
30	testing.SetRealm(testing.NewUserRealm(owner))
31	bid = boards2.CreateBoard(cross(cur), "test123", false, true)
32	tid = boards2.CreateThread(cross(cur), bid, "Title", "Body")
33
34	// Make sure user account has the required amount of GNOT for open board actions
35	testing.IssueCoins(user, chain.Coins{{"ugnot", 3_000_000_000}})
36}
37
38func main(cur realm) {
39	testing.SetRealm(testing.NewUserRealm(user))
40
41	// Non members should be able to add replies
42	boards2.CreateReply(cross(cur), bid, tid, 0, comment)
43
44	// Render content must contain the reply
45	content := boards2.Render("test123/1")
46	println(strings.Contains(content, "\n> "+comment))
47}
48
49// Output:
50// true