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