zp_1_a_filetest.gno
1.21 Kb · 57 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 title = "General Proposal"
15 body = "Foo Bar"
16 votingDays = uint8(1)
17)
18
19var dao *pcommondao.CommonDAO
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 dao.Members().Add(owner)
30
31 options := commondao.GetOptions(dao.ID())
32 options.SetAllowTextProposals(true)
33}
34
35func main() {
36 testing.SetRealm(testing.NewUserRealm(user))
37
38 pID := commondao.CreateTextProposal(cross, dao.ID(), title, body, votingDays)
39
40 p := dao.ActiveProposals().Get(pID)
41 if p == nil {
42 panic("expected proposal to be created")
43 }
44
45 println(string(p.Status()))
46 println(p.Creator() == user)
47 println(p.Definition().Title() == title)
48 println(p.VotingDeadline())
49 println(p.Definition().Body())
50}
51
52// Output:
53// active
54// true
55// true
56// 2009-02-14 23:31:30 +0000 UTC
57// Foo Bar