Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_33_a_filetest.gno

1.27 Kb ยท 53 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	users "gno.land/r/gnoland/users/v1"
15)
16
17const (
18	owner   address = "g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq" // @devx
19	user    address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
20	comment         = "Test Comment"
21)
22
23var (
24	bid boards.ID // Operate on board DAO
25	tid boards.ID
26)
27
28func init() {
29	testing.SetRealm(testing.NewUserRealm(owner))
30	bid = boards2.CreateBoard(cross, "test123", false, true)
31	tid = boards2.CreateThread(cross, bid, "Title", "Body")
32
33	// Register a username which is required to be able to add a reply
34	testing.SetRealm(testing.NewUserRealm(user))
35	users.Register(cross, "user123")
36
37	// Make sure user account has the required amount of GNOT for open board actions
38	testing.IssueCoins(user, chain.Coins{{"ugnot", 3_000_000_000}})
39}
40
41func main() {
42	testing.SetRealm(testing.NewUserRealm(user))
43
44	// Non members should be able to add replies
45	boards2.CreateReply(cross, bid, tid, 0, comment)
46
47	// Render content must contain the reply
48	content := boards2.Render("test123/1")
49	println(strings.Contains(content, "\n> "+comment+"\n"))
50}
51
52// Output:
53// true