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/helplink/v0

Package
Open in gnoweb ↗

Overview

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

Files (3)

  • gnomod.tomltoml
  • helplink.gnogno
  • helplink_test.gnogno
helplink_test.gnogno
1package helplink23import (4	"chain/runtime"5	"testing"67	"gno.land/p/nt/urequire/v0"8)910func TestFunc(t *testing.T) {11	cd := runtime.ChainDomain()12	tests := []struct {13		title     string14		fn        string15		args      []string16		want      string17		realm_XXX Realm18	}{19		{"Example", "foo", []string{"bar", "1", "baz", "2"}, "[Example](/p/moul/helplink/v0$help&func=foo&bar=1&baz=2)", ""},20		{"Realm Example", "foo", []string{"bar", "1", "baz", "2"}, "[Realm Example](/r/lorem/ipsum$help&func=foo&bar=1&baz=2)", Realm(cd + "/r/lorem/ipsum")},21		{"Single Arg", "testFunc", []string{"key", "value"}, "[Single Arg](/p/moul/helplink/v0$help&func=testFunc&key=value)", ""},22		{"No Args", "noArgsFunc", []string{}, "[No Args](/p/moul/helplink/v0$help&func=noArgsFunc)", ""},23		{"Odd Args", "oddArgsFunc", []string{"key"}, "[Odd Args](/p/moul/helplink/v0$help&func=oddArgsFunc&error=odd+number+of+arguments)", ""},24	}2526	for _, tt := range tests {27		t.Run(tt.title, func(t *testing.T) {28			if tt.fn == "oddArgsFunc" {29				defer func() {30					if r := recover(); r != nil {31						if r != "odd number of arguments" {32							t.Errorf("expected panic with message 'odd number of arguments', got: %v", r)33						}34					} else {35						t.Error("expected panic for odd number of arguments, but did not panic")36					}37				}()38			}39			got := tt.realm_XXX.Func(tt.title, tt.fn, tt.args...)40			urequire.Equal(t, tt.want, got)41		})42	}43}4445func TestFuncURL(t *testing.T) {46	cd := runtime.ChainDomain()47	tests := []struct {48		fn        string49		args      []string50		want      string51		realm_XXX Realm52	}{53		{"foo", []string{"bar", "1", "baz", "2"}, "/p/moul/helplink/v0$help&func=foo&bar=1&baz=2", ""},54		{"testFunc", []string{"key", "value"}, "/p/moul/helplink/v0$help&func=testFunc&key=value", ""},55		{"noArgsFunc", []string{}, "/p/moul/helplink/v0$help&func=noArgsFunc", ""},56		{"oddArgsFunc", []string{"key"}, "/p/moul/helplink/v0$help&func=oddArgsFunc&error=odd+number+of+arguments", ""},57		{"foo", []string{"bar", "1", "baz", "2"}, "/r/lorem/ipsum$help&func=foo&bar=1&baz=2", Realm(cd + "/r/lorem/ipsum")},58		{"testFunc", []string{"key", "value"}, "/r/lorem/ipsum$help&func=testFunc&key=value", Realm(cd + "/r/lorem/ipsum")},59		{"noArgsFunc", []string{}, "/r/lorem/ipsum$help&func=noArgsFunc", Realm(cd + "/r/lorem/ipsum")},60		{"oddArgsFunc", []string{"key"}, "/r/lorem/ipsum$help&func=oddArgsFunc&error=odd+number+of+arguments", Realm(cd + "/r/lorem/ipsum")},61		{"foo", []string{"bar", "1", "baz", "2"}, "https://gno.world/r/lorem/ipsum$help&func=foo&bar=1&baz=2", "gno.world/r/lorem/ipsum"},62		{"testFunc", []string{"key", "value"}, "https://gno.world/r/lorem/ipsum$help&func=testFunc&key=value", "gno.world/r/lorem/ipsum"},63		{"noArgsFunc", []string{}, "https://gno.world/r/lorem/ipsum$help&func=noArgsFunc", "gno.world/r/lorem/ipsum"},64		{"oddArgsFunc", []string{"key"}, "https://gno.world/r/lorem/ipsum$help&func=oddArgsFunc&error=odd+number+of+arguments", "gno.world/r/lorem/ipsum"},65	}6667	for _, tt := range tests {68		title := tt.fn69		t.Run(title, func(t *testing.T) {70			if tt.fn == "oddArgsFunc" {71				defer func() {72					if r := recover(); r != nil {73						if r != "odd number of arguments" {74							t.Errorf("expected panic with message 'odd number of arguments', got: %v", r)75						}76					} else {77						t.Error("expected panic for odd number of arguments, but did not panic")78					}79				}()80			}81			got := tt.realm_XXX.FuncURL(tt.fn, tt.args...)82			urequire.Equal(t, tt.want, got)83		})84	}85}8687func TestHome(t *testing.T) {88	testing.SetRealm(testing.NewCodeRealm("gno.land/r/test/helplink"))89	cd := runtime.ChainDomain()90	tests := []struct {91		realm_XXX Realm92		want      string93	}{94		{"", "/r/test/helplink$help"},95		{Realm(cd + "/r/lorem/ipsum"), "/r/lorem/ipsum$help"},96		{"gno.world/r/lorem/ipsum", "https://gno.world/r/lorem/ipsum$help"},97	}9899	for _, tt := range tests {100		t.Run(string(tt.realm_XXX), func(t *testing.T) {101			got := tt.realm_XXX.Home()102			urequire.Equal(t, tt.want, got)103		})104	}105}106

Functions

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

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