z_7_e_filetest.gno
0.95 Kb · 39 lines
1package main
2
3import (
4 "testing"
5
6 "gno.land/r/nt/commondao/v0"
7)
8
9const (
10 owner = address("g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq") // @devx
11 user = address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
12 caller = address("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj") // @test2
13)
14
15var parentID uint64
16
17func init() {
18 // Invite a user to be able to start creating DAOs
19 testing.SetRealm(testing.NewUserRealm(owner))
20 commondao.Invite(cross, user)
21
22 // The origin must be the invited user where invitation
23 // is removed after the first user call to create a DAO
24 testing.SetRealm(testing.NewUserRealm(user))
25
26 // Create the root DAO
27 testing.SetRealm(testing.NewCodeRealm("gno.land/r/test"))
28 parentID = commondao.New(cross, "Parent DAO").ID()
29}
30
31func main() {
32 // Call with a realm that is not the owner of the parent DAO
33 testing.SetRealm(testing.NewCodeRealm("gno.land/r/demo/test"))
34
35 commondao.NewSubDAO(cross, "Foo", parentID)
36}
37
38// Error:
39// unauthorized