Search Apps Documentation Source Content File Folder Download Copy Actions Download

zp_3_b_filetest.gno

1.40 Kb · 64 lines
 1package main
 2
 3import (
 4	"testing"
 5
 6	pcommondao "gno.land/p/nt/commondao/v0"
 7
 8	"gno.land/r/nt/commondao/v0"
 9)
10
11const (
12	owner = address("g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq") // @devx
13	user  = address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
14)
15
16var (
17	dao    *pcommondao.CommonDAO
18	subDAO *pcommondao.CommonDAO
19)
20
21func init() {
22	testing.SetRealm(testing.NewUserRealm(owner))
23	commondao.Invite(cross, user)
24
25	testing.SetRealm(testing.NewUserRealm(user))
26	testing.SetRealm(testing.NewCodeRealm("gno.land/r/demo/test"))
27	dao = commondao.New(cross, "Foo")
28	dao.Members().Add(user)
29
30	options := commondao.GetOptions(dao.ID())
31	options.SetAllowDissolutionProposals(true)
32
33	// Create a SubDAO to be dissolveed
34	subDAO = commondao.NewSubDAO(cross, "Bar", dao.ID())
35}
36
37func main() {
38	testing.SetRealm(testing.NewUserRealm(user))
39
40	pID := commondao.CreateDissolutionProposal(cross, subDAO.ID())
41
42	p := dao.ActiveProposals().Get(pID)
43	if p == nil {
44		panic("expected proposal to be created in the parent DAO")
45	}
46
47	// Make sure proposal doesn't exists in the SubDAO
48	println(subDAO.ActiveProposals().Get(pID) == nil)
49
50	println(string(p.Status()))
51	println(p.Creator() == user)
52	println(p.Definition().Title() == ("Dissolve DAO: " + dao.Name()))
53	println(p.VotingDeadline())
54	println(p.Definition().Body())
55}
56
57// Output:
58// true
59// active
60// true
61// false
62// 2009-02-20 23:31:30 +0000 UTC
63// **DAO:**
64// [Bar](/r/nt/commondao/v0:3)