Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_commondao_must_execute_1_filetest.gno

0.80 Kb · 33 lines
 1// PKGPATH: gno.land/r/test
 2package test
 3
 4import (
 5	"errors"
 6	"testing"
 7	"time"
 8
 9	"gno.land/p/nt/commondao/v0"
10)
11
12type testPropDef struct{}
13
14func (testPropDef) Title() string                               { return "" }
15func (testPropDef) Body() string                                { return "" }
16func (testPropDef) VotingPeriod() time.Duration                 { return 0 }
17func (testPropDef) Tally(commondao.VotingContext) (bool, error) { return true, nil }
18
19func (testPropDef) Executor() commondao.ExecFunc {
20	return func(realm) error {
21		return errors.New("boom!")
22	}
23}
24
25func main() {
26	// Make sure proposal is executed in a realm different than the one where definition has been defined
27	testing.SetRealm(testing.NewCodeRealm("gno.land/r/testing/dao"))
28
29	commondao.MustExecute(testPropDef{})
30}
31
32// Error:
33// boom!