PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/moul/x/envelope/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
moul / x / envelope
Files
4 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/moul/x/envelope/v0
gno
0.9

Files (4)

  • README.mdmarkdown
  • gnomod.tomltoml
  • envelope.gnogno
  • envelope_test.gnogno
envelope_test.gnogno
1package envelope23import (4	"chain"5	"testing"67	"gno.land/p/nt/uassert/v0"8)910const (11	coin  = "/gno.land/r/moul/x/moultest/v0:moultest"12	other = "ugnot"13)1415func pay(coins ...chain.Coin) {16	testing.SetOriginSend(chain.NewCoins(coins...))17}1819func TestReadsAnEmptyEnvelope(cur realm, t *testing.T) {20	pay()21	uassert.True(t, IsEmpty())22	uassert.Equal(t, int64(0), Amount(coin))23	uassert.Equal(t, 0, len(All()))24	uassert.PanicsContains(t, cur, "must be paid", func() { Require(coin) })25}2627func TestReadsAPaidEnvelope(cur realm, t *testing.T) {28	pay(chain.NewCoin(coin, 250))29	uassert.False(t, IsEmpty())30	uassert.Equal(t, int64(250), Amount(coin))31	uassert.Equal(t, int64(250), Require(coin))32	uassert.Equal(t, int64(0), Amount(other), "a denom that did not arrive reads zero")33	pay()34}3536func TestFloorsAndPrices(cur realm, t *testing.T) {37	pay(chain.NewCoin(coin, 100))3839	uassert.Equal(t, int64(100), RequireAtLeast(coin, 100), "the floor is inclusive")40	uassert.Equal(t, int64(100), RequireAtLeast(coin, 99))41	uassert.PanicsContains(t, cur, "costs at least 101", func() { RequireAtLeast(coin, 101) })4243	uassert.Equal(t, int64(100), RequireExactly(coin, 100))44	uassert.PanicsContains(t, cur, "costs exactly 99", func() { RequireExactly(coin, 99) },45		"being overpaid is refused too, not quietly kept")46	uassert.PanicsContains(t, cur, "costs exactly 101", func() { RequireExactly(coin, 101) })47	pay()48}4950func TestOnlyRefusesAMixedEnvelope(cur realm, t *testing.T) {51	pay(chain.NewCoin(coin, 100))52	uassert.Equal(t, int64(100), Only(coin))5354	pay(chain.NewCoin(coin, 100), chain.NewCoin(other, 7))55	uassert.Equal(t, int64(100), Amount(coin), "the mixed envelope still reads fine")56	uassert.Equal(t, int64(7), Amount(other))57	uassert.PanicsContains(t, cur, "also carried 7ugnot", func() { Only(coin) })5859	// Only still requires the denom it was asked about, mixed or not.60	pay(chain.NewCoin(other, 7))61	uassert.PanicsContains(t, cur, "must be paid", func() { Only(coin) })62	pay()63}6465func TestRequireNamesTheFlagToFix(cur realm, t *testing.T) {66	// The abort is the realm's user interface at the moment somebody got it67	// wrong, so it carries the flag and the denom, not a status code.68	pay()69	uassert.PanicsContains(t, cur, "-send <amount>"+coin, func() { Require(coin) })70}71

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.