Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_2_a_filetest.gno

0.97 Kb · 45 lines
 1package main
 2
 3import (
 4	"chain"
 5	"testing"
 6
 7	"gno.land/r/nt/commondao/v0"
 8)
 9
10const (
11	owner = address("g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq") // @devx
12	user  = address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
13	name  = "Foo"
14)
15
16var realmAddr = chain.PackageAddress("gno.land/r/demo/test")
17
18func init() {
19	// Invite a user to be able to start creating DAOs
20	testing.SetRealm(testing.NewUserRealm(owner))
21	commondao.Invite(cross, user)
22}
23
24func main() {
25	// The origin must be the invited user where invitation
26	// is removed after the first user call to create a DAO
27	testing.SetRealm(testing.NewUserRealm(user))
28	testing.SetRealm(testing.NewCodeRealm("gno.land/r/demo/test"))
29
30	dao := commondao.New(cross, name)
31	if dao == nil {
32		panic("expected DAO to be created")
33	}
34
35	println(dao.Name() == name)
36	println(commondao.IsOwner(realmAddr, dao.ID()))
37	println(commondao.IsInvited(user))
38	println(commondao.GetOptions(dao.ID()) != nil)
39}
40
41// Output:
42// true
43// true
44// false
45// true