z_commondao_execute_1_filetest.gno
1.00 Kb · 48 lines
1// PKGPATH: gno.land/r/test
2package test
3
4import (
5 "errors"
6 "time"
7
8 "gno.land/p/nt/commondao/v0"
9)
10
11const member 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 0 }
23func (testPropDef) Tally(commondao.VotingContext) (bool, error) { return true, nil }
24
25func (testPropDef) Executor() commondao.ExecFunc {
26 return func(realm) error {
27 return errors.New("test error")
28 }
29}
30
31func init() {
32 dao = commondao.New(commondao.WithMember(member))
33 proposal = dao.MustPropose(member, testPropDef{})
34}
35
36func main() {
37 err := dao.Execute(proposal.ID())
38 if err != nil {
39 panic(err)
40 }
41
42 println(string(proposal.Status()))
43 println(proposal.StatusReason())
44}
45
46// Output:
47// failed
48// test error