Search Apps Documentation Source Content File Folder Download Copy Actions Download

z_0_prop1_filetest.gno

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