Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_0_prop1_filetest.gno

3.99 Kb · 159 lines
  1// PKGPATH: gno.land/r/sys/namereg/v1/filetests/z_0_prop1_filetest
  2
  3package z_0_prop1_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/v3/init"
 13	users "gno.land/r/sys/namereg/v1"
 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/v1"))
 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 change name
 36	testing.SetOriginCaller(c)
 37	testing.SetRealm(testing.NewUserRealm(c))
 38	pr := users.ProposeNewName(cross(cur), alice, "alice_new123")
 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("alice_new123")
 63	println(data.Addr())
 64}
 65
 66// Output:
 67// --
 68// # GovDAO
 69// ## Members
 70// [> Go to Memberstore <](/r/gov/dao/v3/memberstore)
 71// ## Proposals
 72// ### [Prop #0 - User Registry V1: Rename user \`nym\-alice123\` to \`alice\_new123\`](/r/gov/dao:0)
 73// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
 74//
 75// Status: ACTIVE
 76//
 77// Tiers eligible to vote: T1, T2, T3
 78//
 79// ---
 80//
 81//
 82// --
 83// ## Prop #0 - User Registry V1: Rename user \`nym\-alice123\` to \`alice\_new123\`
 84// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
 85//
 86//
 87//
 88//
 89//
 90// ---
 91//
 92// ### Stats
 93// - **Proposal is open for votes**
 94// - Tiers eligible to vote: T1, T2, T3
 95// - YES PERCENT: 0%
 96// - NO PERCENT: 0%
 97// - ABSTAIN PERCENT: 0%
 98//
 99// [Detailed voting list](/r/gov/dao:0/votes)
100//
101// ---
102//
103// ### Actions
104// [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)
105//
106// WARNING: Please double check transaction data before voting.
107// --
108// --
109// ## Prop #0 - User Registry V1: Rename user \`nym\-alice123\` to \`alice\_new123\`
110// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
111//
112//
113//
114//
115//
116// ---
117//
118// ### Stats
119// - **Proposal is open for votes**
120// - Tiers eligible to vote: T1, T2, T3
121// - YES PERCENT: 100%
122// - NO PERCENT: 0%
123// - ABSTAIN PERCENT: 0%
124//
125// [Detailed voting list](/r/gov/dao:0/votes)
126//
127// ---
128//
129// ### Actions
130// [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)
131//
132// WARNING: Please double check transaction data before voting.
133// --
134// --
135// ## Prop #0 - User Registry V1: Rename user \`nym\-alice123\` to \`alice\_new123\`
136// Author: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
137//
138//
139//
140//
141//
142// ---
143//
144// ### Stats
145// - **PROPOSAL HAS BEEN ACCEPTED**
146// - Tiers eligible to vote: T1, T2, T3
147// - YES PERCENT: 100%
148// - NO PERCENT: 0%
149// - ABSTAIN PERCENT: 0%
150//
151// [Detailed voting list](/r/gov/dao:0/votes)
152//
153// ---
154//
155// ### Actions
156// [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)
157//
158// WARNING: Please double check transaction data before voting.
159// g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh