z_1_a_filetest.gno

1.91 Kb ยท 78 lines
 1// PKGPATH: gno.land/r/demo/groups_test
 2package groups_test
 3
 4// SEND: 200000000ugnot
 5
 6import (
 7	"std"
 8
 9	"gno.land/p/demo/testutils"
10	"gno.land/r/demo/groups"
11	"gno.land/r/demo/users"
12)
13
14var gid groups.GroupID
15
16const admin = std.Address("g1u7y667z64x2h7vc6fmpcprgey4ck233jaww9zq")
17
18func main() {
19	caller := std.GetOrigCaller() // main
20	users.Register("", "gnouser0", "my profile 1")
21
22	std.TestSetOrigCaller(admin)
23	users.GrantInvites(caller.String() + ":1")
24	// switch back to caller
25	std.TestSetOrigCaller(caller)
26	// invite another addr
27	test1 := testutils.TestAddress("gnouser1")
28	users.Invite(test1.String())
29	// switch to test1
30	std.TestSetOrigCaller(test1)
31	users.Register(caller, "gnouser1", "my other profile 1")
32
33	std.TestSetOrigCaller(admin)
34	users.GrantInvites(caller.String() + ":1")
35	// switch back to caller
36	std.TestSetOrigCaller(caller)
37	// invite another addr
38	test2 := testutils.TestAddress("gnouser2")
39	users.Invite(test2.String())
40	// switch to test1
41	std.TestSetOrigCaller(test2)
42	users.Register(caller, "gnouser2", "my other profile 2")
43
44	std.TestSetOrigCaller(admin)
45	users.GrantInvites(caller.String() + ":1")
46	// switch back to caller
47	std.TestSetOrigCaller(caller)
48	// invite another addr
49	test3 := testutils.TestAddress("gnouser3")
50	users.Invite(test3.String())
51	// switch to test1
52	std.TestSetOrigCaller(test3)
53	users.Register(caller, "gnouser3", "my other profile 3")
54
55	std.TestSetOrigCaller(caller)
56
57	gid = groups.CreateGroup("test_group")
58	println(gid)
59
60	groups.AddMember(gid, test3.String(), 32, "i am from UAE")
61	println(groups.Render("test_group"))
62}
63
64// Output:
65// 1
66// Group ID: 0000000001
67//
68// Group Name: test_group
69//
70// Group Creator: gnouser0
71//
72// Group createdAt: 2009-02-13 23:31:30 +0000 UTC m=+1234567890.000000001
73//
74// Group Last MemberID: 0000000001
75//
76// Group Members:
77//
78// 			[0000000000, g1vahx7atnv4erxh6lta047h6lta047h6ll85gpy, 32, i am from UAE, 2009-02-13 23:31:30 +0000 UTC m=+1234567890.000000001],