z_commondao_execute_1_filetest.gno
0.98 Kb ยท 43 lines
1// PKGPATH: gno.land/r/test
2package test
3
4import (
5 "errors"
6 "time"
7
8 "gno.land/p/nt/commondao"
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 }
24func (testPropDef) Execute(cur realm) error { return errors.New("test error") }
25
26func init() {
27 dao = commondao.New(commondao.WithMember(member))
28 proposal = dao.MustPropose(member, testPropDef{})
29}
30
31func main() {
32 err := dao.Execute(proposal.ID())
33 if err != nil {
34 panic(err)
35 }
36
37 println(string(proposal.Status()))
38 println(proposal.StatusReason())
39}
40
41// Output:
42// failed
43// test error