Search Apps Documentation Source Content File Folder Download Copy Actions Download

govdao_execute_proposal_01_filetest.gno

2.10 Kb · 80 lines
 1// PKGPATH: gno.land/r/test/govdao
 2package govdao
 3
 4import (
 5	"strconv"
 6	"testing"
 7
 8	"gno.land/r/gov/dao"
 9	"gno.land/r/gov/dao/v3/impl"
10	"gno.land/r/gov/dao/v3/memberstore"
11)
12
13const user address = "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5"
14
15var (
16	executor   dao.Executor
17	proposalID dao.ProposalID
18	renderPath string
19	govdao     = impl.NewGovDAO()
20)
21
22func init() {
23	// Initialize GovDAO members
24	memberstore.Get().DeleteAll()
25	memberstore.Get().SetTier(memberstore.T1)
26	memberstore.Get().SetMember(memberstore.T1, user, &memberstore.Member{InvitationPoints: 3})
27	dao.UpdateImpl(cross, dao.UpdateRequest{DAO: impl.NewGovDAO()})
28
29	// Create a dummy executor
30	cb := func(realm) error { return nil }
31	executor = dao.NewSimpleExecutor(cb, "")
32
33	// Create a proposal request that pass on execution
34	request := dao.NewProposalRequest("Test", "This proposal always pass on execution", executor)
35
36	// Create the proposal from a realm so GovDAO instance is able to render the proposal
37	testing.SetRealm(testing.NewUserRealm(user))
38	proposalID = dao.MustCreateProposal(cross, request)
39	renderPath = strconv.FormatUint(uint64(proposalID), 10)
40
41	// Register proposal with the local GovDAO instance
42	govdao.PostCreateProposal(request, proposalID)
43}
44
45func main() {
46	// Execute proposal, status should be ACTIVE
47	err := govdao.ExecuteProposal(proposalID, executor)
48
49	println(err == nil)
50	println()
51	println(govdao.Render("gno.land/r/gov/dao/v3/impl", renderPath))
52}
53
54// Output:
55// true
56//
57// ## Prop #0 - Test
58// Author: g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5
59//
60// This proposal always pass on execution
61//
62//
63//
64// ---
65//
66// ### Stats
67// - **Proposal is open for votes**
68// - Tiers eligible to vote: T1, T2, T3
69// - YES PERCENT: 0%
70// - NO PERCENT: 0%
71// - ABSTAIN PERCENT: 0%
72//
73// [Detailed voting list](/r/gov/dao/v3/impl:0/votes)
74//
75// ---
76//
77// ### Actions
78// [Vote YES](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=YES&pid=0) | [Vote NO](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=NO&pid=0) | [Vote ABSTAIN](/r/gov/dao$help&func=MustVoteOnProposalSimple&option=ABSTAIN&pid=0)
79//
80// WARNING: Please double check transaction data before voting.