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