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

z_addr_validation_test.gno

0.81 Kb · 26 lines
 1package impl
 2
 3import (
 4	"testing"
 5
 6	"gno.land/p/nt/urequire/v0"
 7	"gno.land/r/gov/dao/memberstore/v0"
 8)
 9
10// Member addresses arrive as raw MsgCall strings (the VM does not validate an
11// `address` arg), so a non-bech32 value — blank, oversized, or carrying
12// markdown/pipe/HTML metachars — would otherwise be stored and then injected
13// into the members render table. Both admission points reject it, matching the
14// InitWithUsers precedent.
15func TestNewAddMemberRequestRejectsInvalidAddress(cur realm, t *testing.T) {
16	testing.SetOriginCaller(m1)
17	testing.SetRealm(testing.NewUserRealm(m1))
18
19	for _, bad := range []string{"evil|**pwn**", "", "not-an-address"} {
20		urequire.PanicsWithMessage(t, cur,
21			"invalid member address: "+bad,
22			func() {
23				NewAddMemberRequest(cur, address(bad), memberstore.T2, "portfolio")
24			})
25	}
26}