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