Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_4_a_filetest.gno

0.85 Kb · 44 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	name  = "B"
13)
14
15var daoID 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	// Create a couple of DAOs
23	testing.SetRealm(testing.NewUserRealm(user))
24	testing.SetRealm(testing.NewCodeRealm("gno.land/r/test"))
25	commondao.New(cross, "A")
26	daoID = commondao.New(cross, name).ID()
27	commondao.New(cross, "C")
28}
29
30func main() {
31	testing.SetRealm(testing.NewCodeRealm("gno.land/r/test"))
32
33	dao := commondao.Get(daoID)
34	if dao == nil {
35		panic("expected DAO to be found")
36	}
37
38	println(dao.Name() == name)
39	println(dao.ID() == daoID)
40}
41
42// Output:
43// true
44// true