Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

z_create_reply_14_filetest.gno

1.21 Kb · 50 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/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/v0"
14
15	boards2 "gno.land/r/gnoland/boards2/v0"
16)
17
18const (
19	owner   address = "g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"
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