Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_commondao_execute_2_filetest.gno

1.01 Kb ยท 45 lines
 1// PKGPATH: gno.land/r/test
 2package test
 3
 4import (
 5	"time"
 6
 7	"gno.land/p/devx000/wip/nt/commondao"
 8)
 9
10const member = address("g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq") // @devx
11
12var (
13	dao      *commondao.CommonDAO
14	proposal *commondao.Proposal
15)
16
17type testPropDef struct{}
18
19func (testPropDef) Title() string               { return "" }
20func (testPropDef) Body() string                { return "" }
21func (testPropDef) VotingPeriod() time.Duration { return time.Hour } // Voting ends in 1 hour
22func (testPropDef) Execute(cur realm) error     { return nil }
23
24func (testPropDef) Tally(commondao.ReadonlyVotingRecord, commondao.MemberSet) (bool, error) {
25	return true, nil
26}
27
28func init() {
29	dao = commondao.New(
30		commondao.WithMember(member),
31		commondao.DisableVotingDeadlineCheck(), // Disable to be able to execute before voting deadline
32	)
33	proposal = dao.MustPropose(member, testPropDef{})
34}
35
36func main() {
37	err := dao.Execute(proposal.ID())
38
39	println(err == nil)
40	println(string(proposal.Status()))
41}
42
43// Output:
44// true
45// passed