Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

render_example_test.gno

2.20 Kb · 66 lines
 1package faucet
 2
 3// ExampleRender pins the faucet as it ships: no requests, an empty float, one
 4// approver. That IS the deployed state, since nothing is seeded here.
 5//
 6// reset() first: realm globals persist for the whole test binary and examples
 7// run after every Test. The float is NOT a realm global and reset() cannot
 8// clear it, so every test above withdraws what it funded; a test that leaves
 9// coins behind shows up as a diff here, which is the point.
10func ExampleRender() {
11	reset()
12	print(Render(""))
13	// Output:
14	// # GNOT faucet
15	//
16	// Somebody you trust has no GNOT and cannot use the public faucet. File a
17	// request on their behalf, an approver releases it, and both halves stay on
18	// this page with a reason attached. The faucet only ever spends what has been
19	// sent to its own address.
20	//
21	// | | |
22	// | --- | ---: |
23	// | Float available | **0 GNOT** |
24	// | Paid out | 0 GNOT over 0 request(s) |
25	// | Open requests | 0 |
26	// | Refused | 0 |
27	// | Cap per request | 200 GNOT |
28	// | Float address | `g18jy5sp2hx5n8kkwvvs3l908ynyqdxgfh44ay88` |
29	//
30	// ## Open
31	//
32	// _Nothing here yet._
33	//
34	// ## Decided
35	//
36	// _Nothing here yet._
37	//
38	// ## Approvers
39	//
40	// - `g1manfred47kzduec920z88wfr64ylksmdcedlf5`
41	//
42	// ## How
43	//
44	// `Request(to, amount, reason)` is open to anyone and moves no money.
45	// `Approve(id, to, amount)` pays it, and only an approver can call it.
46	//
47	// Send both in **one transaction**: a tm2 transaction stops at the first
48	// message that fails and writes none of their state, so the ask and its
49	// answer land together or not at all. Read `NextID` to address the approval,
50	// and pass the recipient and the amount into it as well: if another request
51	// takes that id first, the mismatch fails the transaction instead of paying
52	// the wrong account.
53}
54
55// ExampleRenderUnknownRequest pins the per-request path on the one state it
56// can reach deterministically from a reset faucet. A request page proper needs
57// a crossing call to exist, and an Example func cannot take `cur realm`, so
58// the filled-in version is asserted in TestRenderEscapesTheReason instead.
59func ExampleRenderUnknownRequest() {
60	reset()
61	print(Render("req/7"))
62	// Output:
63	// # Request 7
64	//
65	// _No such request._
66}