Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_5_e_filetest.gno

1.30 Kb · 55 lines
 1package main
 2
 3import (
 4	"testing"
 5	"time"
 6
 7	pdao "gno.land/p/nt/commondao/v0"
 8
 9	"gno.land/r/nt/commondao/v0"
10)
11
12const (
13	owner = address("g16jpf0puufcpcjkph5nxueec8etpcldz7zwgydq") // @devx
14	user  = address("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // @test1
15)
16
17type propDef struct{}
18
19func (propDef) Title() string                          { return "" }
20func (propDef) Body() string                           { return "" }
21func (propDef) VotingPeriod() time.Duration            { return time.Hour }
22func (propDef) Validate() error                        { return nil }
23func (propDef) Tally(pdao.VotingContext) (bool, error) { return false, nil }
24
25var (
26	daoID    uint64
27	proposal *pdao.Proposal
28)
29
30func init() {
31	// Invite a user to be able to start creating DAOs
32	testing.SetRealm(testing.NewUserRealm(owner))
33	commondao.Invite(cross, user)
34
35	// Create a new DAO which gives ownership to `test`
36	testing.SetRealm(testing.NewUserRealm(user))
37	testing.SetRealm(testing.NewCodeRealm("gno.land/r/test"))
38	dao := commondao.New(cross, "Foo")
39	daoID = dao.ID()
40
41	// Configure DAO
42	dao.Members().Add(user)
43
44	// Create a new proposal
45	proposal, _ = dao.Propose(user, propDef{})
46}
47
48func main() {
49	testing.SetRealm(testing.NewUserRealm(user))
50
51	commondao.Vote(cross, daoID, proposal.ID(), "invalid", "")
52}
53
54// Error:
55// invalid vote choice