z_5_e_filetest.gno

1.50 Kb ยท 56 lines
 1package main
 2
 3import (
 4	"testing"
 5	"time"
 6
 7	pdao "gno.land/p/nt/commondao"
 8
 9	"gno.land/r/nt/commondao"
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.ReadonlyVotingRecord, pdao.MemberSet) (bool, error) { return false, nil }
24func (propDef) Execute() error                                                { return nil }
25
26var (
27	daoID    uint64
28	proposal *pdao.Proposal
29)
30
31func init() {
32	// Invite a user to be able to start creating DAOs
33	testing.SetRealm(testing.NewUserRealm(owner))
34	commondao.Invite(cross, user)
35
36	// Create a new DAO which gives ownership to `test`
37	testing.SetRealm(testing.NewUserRealm(user))
38	testing.SetRealm(testing.NewCodeRealm("gno.land/r/test"))
39	dao := commondao.New(cross, "Foo")
40	daoID = dao.ID()
41
42	// Configure DAO
43	dao.Members().Add(user)
44
45	// Create a new proposal
46	proposal, _ = dao.Propose(user, propDef{})
47}
48
49func main() {
50	testing.SetRealm(testing.NewUserRealm(user))
51
52	commondao.Vote(cross, daoID, proposal.ID(), "invalid", "")
53}
54
55// Error:
56// invalid vote choice