Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_commondao_execute_1_filetest.gno

0.95 Kb ยท 48 lines
 1// PKGPATH: gno.land/r/test
 2package test
 3
 4import (
 5	"errors"
 6	"time"
 7
 8	"gno.land/p/devx000/wip/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 }
23
24func (testPropDef) Tally(commondao.ReadonlyVotingRecord, commondao.MemberSet) (bool, error) {
25	return true, nil
26}
27
28func (testPropDef) Execute(cur realm) error {
29	return errors.New("test error")
30}
31
32func init() {
33	dao = commondao.New(commondao.WithMember(member))
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	println(proposal.StatusReason())
43}
44
45// Output:
46// true
47// failed
48// test error