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_thread_05_filetest.gno

1.72 Kb · 61 lines
 1// PKGPATH: gno.land/r/gnoland/boards2/v0/filetests/z_create_thread_05_filetest
 2
 3// Open board: Test creating a new thread as a non member user
 4package z_create_thread_05_filetest
 5
 6// SEND: 1000000ugnot
 7
 8import (
 9	"chain"
10	"testing"
11
12	"gno.land/p/gnoland/boards/v0"
13
14	boards2 "gno.land/r/gnoland/boards2/v0"
15)
16
17const (
18	owner address = "g1skl80cuz8zq3lul9pgz5pc35l2pfzgxgfpsqkx"
19	user  address = "g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj" // @test2
20	title         = "Test Thread"
21	body          = "Test body"
22)
23
24var bid boards.ID // Operate on board DAO
25
26func init(cur realm) {
27	testing.SetRealm(testing.NewUserRealm(owner))
28	bid = boards2.CreateBoard(cross(cur), "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
34func main(cur realm) {
35	testing.SetRealm(testing.NewUserRealm(user))
36
37	// Non members should be able to create threads
38	tid := boards2.CreateThread(cross(cur), bid, title, body)
39
40	// Ensure that returned ID is right
41	println(tid == 1)
42
43	// Render content must contains thread's title and body
44	println(boards2.Render("test123/1"))
45}
46
47// Output:
48// true
49// # [Boards](/r/gnoland/boards2/v0) › [test123](/r/gnoland/boards2/v0:test123)
50// ## Test Thread
51//
52// **[g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj](/u/g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj)** · 2009-02-13 11:31pm UTC
53//
54//
55// <gno-foreign>
56// Test body
57// </gno-foreign>
58//
59//
60//
61// ↳ [Flag](/r/gnoland/boards2/v0:test123/1/flag) • [Repost](/r/gnoland/boards2/v0:test123/1/repost) • [Comment](/r/gnoland/boards2/v0:test123/1/reply) • [Edit](/r/gnoland/boards2/v0:test123/1/edit) • [Delete](/r/gnoland/boards2/v0$help&func=DeleteThread&boardID=1&threadID=1)