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/nt/ownable/exts/authorizable/v0

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v0
Namespace
nt / ownable / exts / authorizable
Files
5 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/nt/ownable/exts/authorizable/v0
gno
0.9

Files (5)

  • README.mdmarkdown
  • gnomod.tomltoml
  • authorizable.gnogno
  • errors.gnogno
  • authorizable_test.gnogno
authorizable_test.gnogno
1package authorizable23import (4	"testing"56	"gno.land/p/nt/ownable/v0"7	"gno.land/p/nt/testutils/v0"8	"gno.land/p/nt/uassert/v0"9)1011// cur is a zero-value realm used as a placeholder when forwarding to12// uassert/urequire dispatch helpers that gained an `rlm realm` param.13// These tests pass `func()` callbacks (no crossing inside the callback),14// so rlm is ignored — a nil realm here is safe.15var cur realm16var (17	alice   = testutils.TestAddress("alice")18	bob     = testutils.TestAddress("bob")19	charlie = testutils.TestAddress("charlie")20)2122func TestNew(cur realm, t *testing.T) {23	testing.SetRealm(testing.NewUserRealm(alice))2425	a := New(ownable.NewWithAddress(alice))26	got := a.Owner()2728	if alice != got {29		t.Fatalf("Expected %s, got: %s", alice, got)30	}31}3233func TestOnAuthList(cur realm, t *testing.T) {34	a := New(ownable.NewWithAddress(alice))35	testing.SetRealm(testing.NewUserRealm(alice))3637	// After SetRealm, cur is the test-frame HIV with addr=alice;38	// OnAuthList reports on rlm.Address() (i.e. cur.Address()).39	if err := a.OnAuthList(0, cur); err == ErrNotInAuthList {40		t.Fatalf("expected alice to be on the list")41	}42}4344func TestNotOnAuthList(cur realm, t *testing.T) {45	a := New(ownable.NewWithAddress(alice))46	testing.SetRealm(testing.NewUserRealm(bob))4748	if err := a.OnAuthList(0, cur); err == nil {49		t.Fatalf("expected bob to not be on the list")50	}51}5253func TestAddToAuthList(cur realm, t *testing.T) {54	a := New(ownable.NewWithAddress(alice))5556	testing.SetRealm(testing.NewUserRealm(alice))57	var err error58	func(cur realm) { err = a.AddToAuthList(0, cur, bob) }(cross(cur))59	if err != nil {60		t.Fatalf("Expected no error, got %v", err)61	}6263	testing.SetRealm(testing.NewUserRealm(bob))64	func(cur realm) { err = a.AddToAuthList(0, cur, bob) }(cross(cur))65	if err == nil {66		t.Fatalf("Expected AddToAuth to error while bob called it, but it didn't")67	}68}6970func TestDeleteFromList(cur realm, t *testing.T) {71	a := New(ownable.NewWithAddress(alice))7273	testing.SetRealm(testing.NewUserRealm(alice))74	var err error75	func(cur realm) { err = a.AddToAuthList(0, cur, bob) }(cross(cur))76	if err != nil {77		t.Fatalf("Expected no error, got %v", err)78	}7980	func(cur realm) { err = a.AddToAuthList(0, cur, charlie) }(cross(cur))81	if err != nil {82		t.Fatalf("Expected no error, got %v", err)83	}8485	// Try an unauthorized deletion (bob is not the superuser).86	testing.SetRealm(testing.NewUserRealm(bob))87	func(cur realm) { err = a.DeleteFromAuthList(0, cur, alice) }(cross(cur))88	if err == nil {89		t.Fatalf("Expected DelFromAuth to error with %v", err)90	}9192	testing.SetRealm(testing.NewUserRealm(alice))93	func(cur realm) { err = a.DeleteFromAuthList(0, cur, charlie) }(cross(cur))94	if err != nil {95		t.Fatalf("Expected no error, got %v", err)96	}97}9899func TestAssertOnList(cur realm, t *testing.T) {100	a := New(ownable.NewWithAddress(alice))101102	testing.SetRealm(testing.NewUserRealm(bob))103104	uassert.PanicsWithMessage(t, cur, ErrNotInAuthList.Error(), func() {105		a.AssertOnAuthList(0, cur)106	})107}108

Functions

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

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