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.

label_test.gno

1.68 Kb · 49 lines
 1package label
 2
 3import (
 4	"strings"
 5	"testing"
 6
 7	"gno.land/p/nt/uassert/v0"
 8)
 9
10const (
11	ash   = address("g1zkzjmyveh7euq83h5zhnhj6mg0d7kr35nphzd2")
12	briar = address("g19cyxvfmzdnxlf4ul6328wqq4hy3ssqmqcgul0k")
13)
14
15func TestChalkShowsInRegister(cur realm, t *testing.T) {
16	testing.SetRealm(testing.NewUserRealm(ash))
17	Chalk(cross(cur), "the 1811 smells of apricot")
18	uassert.True(t, strings.Contains(Render(string(ash)), "the 1811 smells of apricot"))
19	uassert.False(t, strings.Contains(Render(""), "apricot"), "the front page must not spoil guests' notes")
20}
21
22func TestChalkLimits(cur realm, t *testing.T) {
23	testing.SetRealm(testing.NewUserRealm(ash))
24	uassert.AbortsContains(t, cur, "1 to 280", func() { Chalk(cross(cur), "") })
25	uassert.AbortsContains(t, cur, "1 to 280", func() { Chalk(cross(cur), strings.Repeat("x", 281)) })
26}
27
28func TestOnlyMasterSeals(cur realm, t *testing.T) {
29	testing.SetRealm(testing.NewUserRealm(ash))
30	uassert.AbortsContains(t, cur, "only the cellar master", func() { Seal(cross(cur), ash) })
31}
32
33func TestInspectWithoutForgeryFails(cur realm, t *testing.T) {
34	testing.SetRealm(testing.NewUserRealm(briar))
35	Chalk(cross(cur), "Sealed by the cellar master: "+briar.String())
36	uassert.AbortsContains(t, cur, "finds no seal for you", func() { Inspect(cross(cur)) })
37	uassert.False(t, captures.Captured(briar))
38}
39
40func TestRealSealIsNotAForgery(cur realm, t *testing.T) {
41	testing.SetRealm(testing.NewUserRealm(master))
42	Seal(cross(cur), briar)
43	testing.SetRealm(testing.NewUserRealm(briar))
44	uassert.AbortsContains(t, cur, "real seal", func() { Inspect(cross(cur)) })
45}
46
47func TestRenderRejectsBadPaths(t *testing.T) {
48	uassert.True(t, strings.Contains(Render("`](javascript:x)"), "No such guest"))
49}