Skip to content

Commit

Permalink
fixing txtar
Browse files Browse the repository at this point in the history
  • Loading branch information
leohhhn committed Jan 17, 2025
1 parent 73d698d commit 3a71236
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 62 deletions.
58 changes: 10 additions & 48 deletions gno.land/pkg/integration/testdata/addpkg_namespace.txtar
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
loadpkg gno.land/r/demo/users
loadpkg gno.land/r/sys/users
loadpkg gno.land/r/gnoland/users/v1
loadpkg gno.land/r/sys/names

adduser admin
adduser gui
Expand All @@ -8,39 +8,6 @@ patchpkg "g1manfred47kzduec920z88wfr64ylksmdcedlf5" $admin_user_addr # use our c

gnoland start

## When `sys/users` is disabled

# Should be disabled by default, addpkg should work by default

# Check if sys/users is disabled
# gui call -> sys/users.IsEnable
gnokey maketx call -pkgpath gno.land/r/sys/users -func IsEnabled -gas-fee 100000ugnot -gas-wanted 200000 -broadcast -chainid tendermint_test gui
stdout 'OK!'
stdout 'false'

# Gui should be able to addpkg on test1 addr
# gui addpkg -> gno.land/r/<addr_test1>/mysuperpkg
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/$test1_user_addr/mysuperpkg -gas-fee 1000000ugnot -gas-wanted 400000 -broadcast -chainid=tendermint_test gui
stdout 'OK!'

# Gui should be able to addpkg on random name
# gui addpkg -> gno.land/r/randomname/mysuperpkg
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/randomname/mysuperpkg -gas-fee 1000000ugnot -gas-wanted 350000 -broadcast -chainid=tendermint_test gui
stdout 'OK!'

## When `sys/users` is enabled

# Enable `sys/users`
# admin call -> sys/users.AdminEnable
gnokey maketx call -pkgpath gno.land/r/sys/users -func AdminEnable -gas-fee 100000ugnot -gas-wanted 1000000 -broadcast -chainid tendermint_test admin
stdout 'OK!'

# Check that `sys/users` has been enabled
# gui call -> sys/users.IsEnable
gnokey maketx call -pkgpath gno.land/r/sys/users -func IsEnabled -gas-fee 100000ugnot -gas-wanted 200000 -broadcast -chainid tendermint_test gui
stdout 'OK!'
stdout 'true'

# Try to add a pkg an with unregistered user
# gui addpkg -> gno.land/r/<addr_test1>/one
! gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/$test1_user_addr/one -gas-fee 1000000ugnot -gas-wanted 1000000 -broadcast -chainid=tendermint_test gui
Expand All @@ -61,25 +28,20 @@ stderr 'unauthorized user'

## Test registered namespace

# Test admin invites gui
# admin call -> demo/users.Invite
gnokey maketx call -pkgpath gno.land/r/demo/users -func Invite -gas-fee 1000000ugnot -gas-wanted 2500000 -broadcast -chainid=tendermint_test -args $gui_user_addr admin
stdout 'OK!'

# test gui register namespace
# gui call -> demo/users.Register
gnokey maketx call -pkgpath gno.land/r/demo/users -func Register -gas-fee 1000000ugnot -gas-wanted 2500000 -broadcast -chainid=tendermint_test -args $admin_user_addr -args 'guiland' -args 'im gui' gui
# gui call -> gnoland/users/v1.Register
gnokey maketx call -pkgpath gno.land/r/gnoland/users/v1 -func Register -gas-fee 1000000ugnot -gas-wanted 2500000 -broadcast -chainid=tendermint_test -args "gui123" gui
stdout 'OK!'

# Test gui publishing on guiland/one
# gui addpkg -> gno.land/r/guiland/one
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/guiland/one -gas-fee 1000000ugnot -gas-wanted 1800000 -broadcast -chainid=tendermint_test gui
# Test gui publishing on gui123/one
# gui addpkg -> gno.land/r/gui123/one
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/gui123/one -gas-fee 1000000ugnot -gas-wanted 1800000 -broadcast -chainid=tendermint_test gui
stdout 'OK!'

# Test admin publishing on guiland/two
# admin addpkg -> gno.land/r/guiland/two
# Test admin publishing on gui123/two
# admin addpkg -> gno.land/r/gui123/two
# This is expected to fail at the transaction simulation stage, which is why we set gas-wanted to 1.
! gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/guiland/two -gas-fee 1000000ugnot -gas-wanted 1 -broadcast -chainid=tendermint_test admin
! gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/gui123/two -gas-fee 1000000ugnot -gas-wanted 1 -broadcast -chainid=tendermint_test admin
stderr 'unauthorized user'

-- one.gno --
Expand Down
22 changes: 10 additions & 12 deletions gno.land/pkg/integration/testdata/grc721_emit.txtar
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Test for https://github.com/gnolang/gno/pull/3102
loadpkg gno.land/p/demo/grc/grc721
loadpkg gno.land/r/demo/users
loadpkg gno.land/r/gnoland/users/v1
loadpkg gno.land/r/foo721 $WORK/foo721

gnoland start
Expand Down Expand Up @@ -33,9 +33,7 @@ import (
"std"

"gno.land/p/demo/grc/grc721"
"gno.land/r/demo/users"

pusers "gno.land/p/demo/users"
"gno.land/r/gnoland/users/v1"
)

var (
Expand All @@ -45,33 +43,33 @@ var (

// Setters

func Approve(user pusers.AddressOrName, tid grc721.TokenID) {
err := foo.Approve(users.Resolve(user), tid)
func Approve(user std.Address, tid grc721.TokenID) {
err := foo.Approve(user, tid)
if err != nil {
panic(err)
}
}

func SetApprovalForAll(user pusers.AddressOrName, approved bool) {
err := foo.SetApprovalForAll(users.Resolve(user), approved)
func SetApprovalForAll(user std.Address, approved bool) {
err := foo.SetApprovalForAll(user, approved)
if err != nil {
panic(err)
}
}

func TransferFrom(from, to pusers.AddressOrName, tid grc721.TokenID) {
err := foo.TransferFrom(users.Resolve(from), users.Resolve(to), tid)
func TransferFrom(from, to std.Address, tid grc721.TokenID) {
err := foo.TransferFrom(from, to, tid)
if err != nil {
panic(err)
}
}

// Admin

func Mint(to pusers.AddressOrName, tid grc721.TokenID) {
func Mint(to std.Address, tid grc721.TokenID) {
caller := std.PrevRealm().Addr()
assertIsAdmin(caller)
err := foo.Mint(users.Resolve(to), tid)
err := foo.Mint(to, tid)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion gno.land/pkg/integration/testdata/issue_2283.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# These are not necessary, but they "alleviate" add_feeds.tx from the
# responsibility of loading standard libraries, thus not making it exceed
# the --gas-wanted.
loadpkg gno.land/r/demo/users
loadpkg gno.land/r/gnoland/users/v1
loadpkg gno.land/r/demo/boards
loadpkg gno.land/r/demo/imports $WORK/imports

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# These are not necessary, but they "alleviate" add_feeds.tx from the
# responsibility of loading standard libraries, thus not making it exceed
# the --gas-wanted.
loadpkg gno.land/r/demo/users
loadpkg gno.land/r/gnoland/users/v1
loadpkg gno.land/r/demo/boards

gnoland start
Expand Down

0 comments on commit 3a71236

Please sign in to comment.