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