z_0_prop1_filetest.gno

2.56 Kb ยท 136 lines
  1package main
  2
  3// SEND: 1000000ugnot
  4
  5import (
  6	"std"
  7	"testing"
  8
  9	"gno.land/p/demo/testutils"
 10	users "gno.land/r/gnoland/users/v1"
 11	"gno.land/r/gov/dao"
 12	"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 std.Address = std.OriginCaller()
 18
 19func init() {
 20	init.InitWithUsers(c)
 21
 22	alice := testutils.TestAddress("alice")
 23
 24	// Register alice
 25	testing.SetOriginCaller(alice)
 26	testing.SetRealm(std.NewUserRealm(alice))
 27	users.Register("alice123")
 28
 29	// Prop to change name
 30	testing.SetOriginCaller(c)
 31	testing.SetRealm(std.NewUserRealm(c))
 32	pr := users.ProposeNewName(alice, "alice_new123")
 33	dao.MustCreateProposal(pr)
 34}
 35
 36func main() {
 37	testing.SetOriginCaller(c)
 38
 39	println("--")
 40	println(dao.Render(""))
 41	println("--")
 42	println(dao.Render("0"))
 43	println("--")
 44
 45	dao.MustVoteOnProposal(dao.VoteRequest{
 46		Option:     dao.YesVote,
 47		ProposalID: dao.ProposalID(0),
 48	})
 49	println("--")
 50	println(dao.Render("0"))
 51	println("--")
 52	dao.ExecuteProposal(dao.ProposalID(0))
 53	println("--")
 54	println(dao.Render("0"))
 55
 56	data, _ := susers.ResolveName("alice_new123")
 57	println(data.Addr())
 58}
 59
 60// Output:
 61// --
 62// # Active Proposals:
 63// ## Proposal with id: 0
 64// ### Title: Propose a new name using users/v1 realm
 65//
 66// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
 67//
 68//
 69//
 70//
 71// ### Proposal Status:
 72//
 73// - **Proposal open for votes**
 74// - Allowed tiers to vote: T1 T2 T3
 75// - YES PERCENT: 0%
 76// - NO PERCENT: 0%
 77// - [Go to votes list](/r/gov/dao:0/votes).
 78//
 79//
 80// --
 81// ## Proposal with id: 0
 82// ### Title: Propose a new name using users/v1 realm
 83//
 84// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
 85//
 86//
 87//
 88//
 89// ### Proposal Status:
 90//
 91// - **Proposal open for votes**
 92// - Allowed tiers to vote: T1 T2 T3
 93// - YES PERCENT: 0%
 94// - NO PERCENT: 0%
 95// - [Go to votes list](/r/gov/dao:0/votes).
 96//
 97//
 98// --
 99// --
100// ## Proposal with id: 0
101// ### Title: Propose a new name using users/v1 realm
102//
103// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
104//
105//
106//
107//
108// ### Proposal Status:
109//
110// - **Proposal open for votes**
111// - Allowed tiers to vote: T1 T2 T3
112// - YES PERCENT: 100%
113// - NO PERCENT: 0%
114// - [Go to votes list](/r/gov/dao:0/votes).
115//
116//
117// --
118// --
119// ## Proposal with id: 0
120// ### Title: Propose a new name using users/v1 realm
121//
122// ### Proposed by: g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm
123//
124//
125//
126//
127// ### Proposal Status:
128//
129// - **PROPOSAL HAS BEEN ACCEPTED**
130// - Allowed tiers to vote: T1 T2 T3
131// - YES PERCENT: 100%
132// - NO PERCENT: 0%
133// - [Go to votes list](/r/gov/dao:0/votes).
134//
135//
136// g1v9kxjcm9ta047h6lta047h6lta047h6lzd40gh