Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pre-register test1 user to make interaction with boards easier #2823

Merged
merged 9 commits into from
Sep 26, 2024
1 change: 1 addition & 0 deletions examples/gno.land/r/demo/users/gno.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ module gno.land/r/demo/users
require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/avlhelpers v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/users v0.0.0-latest
)
3 changes: 3 additions & 0 deletions examples/gno.land/r/demo/users/preregister.gno
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ var preRegisteredUsers = []struct {
{"nt", "g15ge0ae9077eh40erwrn2eq0xw6wupwqthpv34l"}, // -> @r_nt
{"sys", "g1r929wt2qplfawe4lvqv9zuwfdcz4vxdun7qh8l"}, // -> @r_sys
{"x", "g164sdpew3c2t3rvxj3kmfv7c7ujlvcw2punzzuz"}, // -> @r_x

// test1 user
{"test1", "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5"}, // -> @test1
}

func init() {
Expand Down
13 changes: 13 additions & 0 deletions examples/gno.land/r/demo/users/users_test.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package users

import (
"testing"

"gno.land/p/demo/uassert"
)

func TestPreRegisteredTest1(t *testing.T) {
names := ListUsersByPrefix("test1", 1)
uassert.Equal(t, len(names), 1)
uassert.Equal(t, names[0], "test1")
}
22 changes: 22 additions & 0 deletions examples/gno.land/r/demo/users/z_13_filetest.gno
hthieu1110 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

// SEND: 200000000ugnot
thehowl marked this conversation as resolved.
Show resolved Hide resolved

import (
"strconv"

"gno.land/r/demo/users"
)

func main() {
{
hthieu1110 marked this conversation as resolved.
Show resolved Hide resolved
// Verify pre-registered test1 user
names := users.ListUsersByPrefix("test1", 1)
println("# names: " + strconv.Itoa(len(names)))
println("name: " + names[0])
}
}

// Output:
// # names: 1
// name: test1
1 change: 1 addition & 0 deletions examples/gno.land/r/demo/users/z_5_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func main() {
// * [nt](/r/demo/users:nt)
// * [satoshi](/r/demo/users:satoshi)
// * [sys](/r/demo/users:sys)
// * [test1](/r/demo/users:test1)
// * [x](/r/demo/users:x)
//
// ========================================
Expand Down
Loading