Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

z_1_prop2_filetest.gno

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