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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

z_happy_path_filetest.gno

2.10 Kb · 76 lines
 1// PKGPATH: gno.land/r/nym-ololade001/guildhall/v1/filetests/z_happy_path_filetest
 2
 3package z_happy_path_filetest
 4
 5import (
 6	"testing"
 7
 8	"chain"
 9
10	"gno.land/p/nt/testutils/v0"
11	"gno.land/r/nym-ololade001/guildhall/v1"
12)
13
14var (
15	poster = testutils.TestAddress("poster")
16	worker = testutils.TestAddress("worker")
17)
18
19func realmAddr() address {
20	return chain.PackageAddress("gno.land/r/nym-ololade001/guildhall/v1")
21}
22
23func ugnot(amt int64) chain.Coins {
24	return chain.NewCoins(chain.NewCoin("ugnot", amt))
25}
26
27func init(cur realm) {
28	testing.SetHeight(1000)
29	testing.IssueCoins(realmAddr(), ugnot(5000000))
30	testing.SetRealm(testing.NewUserRealm(poster))
31	testing.SetOriginSend(ugnot(5000000))
32	id := guildhall.Post(cross(cur), "Write a haiku", "three lines about gno", 600, 1200, 20000)
33	println("posted", id)
34}
35
36func main(cur realm) {
37	testing.SetHeight(1100)
38	testing.SetOriginSend(nil)
39	testing.SetRealm(testing.NewUserRealm(worker))
40	guildhall.Claim(cross(cur), 1)
41	guildhall.Submit(cross(cur), 1, "https://example.com/haiku", "done")
42
43	testing.SetRealm(testing.NewUserRealm(poster))
44	guildhall.Accept(cross(cur), 1)
45	println(guildhall.Render("q/1"))
46}
47
48// Output:
49// posted 1
50// # Write a haiku
51//
52// - **Status:** paid
53// - **Reward:** 5 GNOT
54// - **Poster:** [g1wphhxar9wf047h6lta047h6lta047h6l054qau](/r/nym-ololade001/guildhall/v1:u/g1wphhxar9wf047h6lta047h6lta047h6l054qau)
55// - **Worker:** [g1wahhy6m9wf047h6lta047h6lta047h6ltyyhl8](/r/nym-ololade001/guildhall/v1:u/g1wahhy6m9wf047h6lta047h6lta047h6ltyyhl8)
56// - **Lease:** 600 blocks
57// - **Review window:** 1200 blocks
58// - **Deadline:** block 20000
59// - **Proof:** [https://example\.com/haiku](https://example.com/haiku)
60// - **Note:** done
61//
62// ## Spec
63//
64//
65// three lines about gno
66//
67//
68//
69// ## History
70//
71// - block 1000 — `g1wphhxar9wf047h6lta047h6lta047h6l054qau` posted
72// - block 1100 — `g1wahhy6m9wf047h6lta047h6lta047h6ltyyhl8` claimed
73// - block 1100 — `g1wahhy6m9wf047h6lta047h6lta047h6ltyyhl8` submitted — https://example\.com/haiku
74// - block 1100 — `g1wphhxar9wf047h6lta047h6lta047h6l054qau` accepted
75//
76// [Back to the board](/r/nym-ololade001/guildhall/v1)