z_3_f_filetest.gno

1.04 Kb ยท 45 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	name    = "foo123"
17	newName = "barbaz123"
18)
19
20var bid boards2.BoardID // Operate on board DAO
21
22func init() {
23	testing.SetRealm(std.NewUserRealm(owner))
24
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
34func main() {
35	testing.SetRealm(std.NewUserRealm(member))
36
37	boards2.RenameBoard(cross, name, newName)
38
39	// Ensure board is renamed by another board owner
40	bid2, _ := boards2.GetBoardIDFromName(cross, newName)
41	println("IDs match =", bid == bid2)
42}
43
44// Output:
45// IDs match = true