z_3_g_filetest.gno

1.15 Kb ยท 44 lines
 1package main
 2
 3// SEND: 1000000ugnot
 4
 5import (
 6	"std"
 7	"testing"
 8
 9	boards2 "gno.land/r/gnoland/boards2/v1"
10	users "gno.land/r/gnoland/users/v1"
11)
12
13const (
14	owner   = std.Address("g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq") // @devx
15	member  = std.Address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
16	member2 = std.Address("g1vh7krmmzfua5xjmkatvmx09z37w34lsvd2mxa5")
17	name    = "foo123"
18	newName = "barbaz123"
19)
20
21var bid boards2.BoardID // Operate on board DAO
22
23func init() {
24	testing.SetRealm(std.NewUserRealm(owner))
25	bid = boards2.CreateBoard(cross, name, false)
26	boards2.InviteMember(cross, bid, member, boards2.RoleOwner)
27
28	// Test1 is the boards owner and its address has a user already registered
29	// so a new member must register a user with the new board name.
30	testing.SetRealm(std.NewUserRealm(member))
31	users.Register(cross, newName)
32
33	// Invite a new member that doesn't own the user that matches the new board name
34	boards2.InviteMember(cross, bid, member2, boards2.RoleOwner)
35}
36
37func main() {
38	testing.SetRealm(std.NewUserRealm(member2))
39
40	boards2.RenameBoard(cross, name, newName)
41}
42
43// Error:
44// board name is a user name registered to a different user