Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_1_prop2_filetest.gno

3.82 Kb · 162 lines
  1package main
  2
  3import (
  4	"chain"
  5	"chain/runtime"
  6	"testing"
  7
  8	"gno.land/p/nt/testutils/v0"
  9	"gno.land/r/gov/dao"
 10	daov3init "gno.land/r/gov/dao/v3/init"
 11	users "gno.land/r/sys/namereg/v1"
 12	susers "gno.land/r/sys/users"
 13)
 14
 15// Test updating a name via GovDAO
 16var c address = runtime.OriginCaller()
 17
 18func init() {
 19	// Whitelist this realm as a controller so its Register() can reach r/sys/users.
 20	testing.SetHeight(0)
 21	susers.AddControllerAtGenesis(cross, chain.PackageAddress("gno.land/r/sys/namereg/v1"))
 22	testing.SetHeight(123)
 23
 24	daov3init.InitWithUsers(c)
 25
 26	alice := testutils.TestAddress("alice")
 27
 28	// Register alice
 29	testing.SetOriginCaller(alice)
 30	testing.SetRealm(testing.NewUserRealm(alice))
 31	users.Register(cross, "nym-alice123")
 32
 33	// Prop to delete user
 34	testing.SetOriginCaller(c)
 35	testing.SetRealm(testing.NewUserRealm(c))
 36	pr := users.ProposeDeleteUser(alice, "delete user test")
 37	dao.MustCreateProposal(cross, pr)
 38}
 39
 40func main() {
 41	testing.SetOriginCaller(c)
 42
 43	println("--")
 44	println(dao.Render(""))
 45	println("--")
 46	println(dao.Render("0"))
 47	println("--")
 48
 49	dao.MustVoteOnProposal(cross, dao.VoteRequest{
 50		Option:     dao.YesVote,
 51		ProposalID: dao.ProposalID(0),
 52	})
 53
 54	println("--")
 55	println(dao.Render("0"))
 56	println("--")
 57
 58	dao.ExecuteProposal(cross, dao.ProposalID(0))
 59
 60	println("--")
 61	println(dao.Render("0"))
 62
 63	data, _ := susers.ResolveName("nym-alice123")
 64	if data == nil {
 65		println("Successfully deleted alice")
 66	}
 67}
 68
 69// Output:
 70// --
 71// # GovDAO
 72// ## Members
 73// [> Go to Memberstore <](/r/gov/dao/v3/memberstore)
 74// ## Proposals
 75// ### [Prop #0 - User Registry V1: Delete user \`nym\-alice123\`](/r/gov/dao:0)
 76// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
 77//
 78// Status: ACTIVE
 79//
 80// Tiers eligible to vote: T1, T2, T3
 81//
 82// ---
 83//
 84//
 85// --
 86// ## Prop #0 - User Registry V1: Delete user \`nym\-alice123\`
 87// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
 88//
 89// delete user test
 90//
 91//
 92//
 93// ---
 94//
 95// ### Stats
 96// - **Proposal is open for votes**
 97// - Tiers eligible to vote: T1, T2, T3
 98// - YES PERCENT: 0%
 99// - NO PERCENT: 0%
100// - ABSTAIN PERCENT: 0%
101//
102// [Detailed voting list](/r/gov/dao:0/votes)
103//
104// ---
105//
106// ### Actions
107// [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)
108//
109// WARNING: Please double check transaction data before voting.
110// --
111// --
112// ## Prop #0 - User Registry V1: Delete user \`nym\-alice123\`
113// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
114//
115// delete user test
116//
117//
118//
119// ---
120//
121// ### Stats
122// - **Proposal is open for votes**
123// - Tiers eligible to vote: T1, T2, T3
124// - YES PERCENT: 100%
125// - NO PERCENT: 0%
126// - ABSTAIN PERCENT: 0%
127//
128// [Detailed voting list](/r/gov/dao:0/votes)
129//
130// ---
131//
132// ### Actions
133// [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)
134//
135// WARNING: Please double check transaction data before voting.
136// --
137// --
138// ## Prop #0 - User Registry V1: Delete user \`nym\-alice123\`
139// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
140//
141// delete user test
142//
143//
144//
145// ---
146//
147// ### Stats
148// - **PROPOSAL HAS BEEN ACCEPTED**
149// - Tiers eligible to vote: T1, T2, T3
150// - YES PERCENT: 100%
151// - NO PERCENT: 0%
152// - ABSTAIN PERCENT: 0%
153//
154// [Detailed voting list](/r/gov/dao:0/votes)
155//
156// ---
157//
158// ### Actions
159// [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)
160//
161// WARNING: Please double check transaction data before voting.
162// Successfully deleted alice