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: add account number / sequence as env in txtar #3477

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions gno.land/pkg/integration/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,17 @@
// The path where the gnoland node stores its configuration and data. It's
// set only if the node has started.
//
// - USER_SEED_test1:
// Contains the seed for the test1 account.
// - xxx_user_seed:
// Where `xxx` is the account name; Contains the seed for the test1 account.
//
// - USER_ADDR_test1:
// Contains the address for the test1 account.
// - xxx_user_addr:
// Where `xxx` is the account name; Contains the address for the test1 account.
//
// - xxx_account_num:
// Where `xxx` is the account name; Contains the account number for the test1 account.
//
// - xxx_account_seq:
// Where `xxx` is the account name; Contains the address for the test1 account.
//
// - RPC_ADDR:
// Points to the gnoland node's remote address. It's set only if the node has started.
Expand Down
4 changes: 2 additions & 2 deletions gno.land/pkg/integration/testdata/addpkg.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
gnoland start

## deploy realm
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/$USER_ADDR_test1/hello -gas-fee 1000000ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/$test1_user_addr/hello -gas-fee 1000000ugnot -gas-wanted 100000000 -broadcast -chainid=tendermint_test test1

## check output
stdout OK!
Expand All @@ -15,7 +15,7 @@ stdout 'EVENTS: \[\]'
stdout 'TX HASH: '

## call added realm
gnokey maketx call -pkgpath gno.land/r/$USER_ADDR_test1/hello -chainid=tendermint_test -func SayHello -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast test1
gnokey maketx call -pkgpath gno.land/r/$test1_user_addr/hello -chainid=tendermint_test -func SayHello -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast test1

## check output
stdout '\("hello world!" string\)'
Expand Down
12 changes: 6 additions & 6 deletions gno.land/pkg/integration/testdata/addpkg_namespace.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ loadpkg gno.land/r/sys/users
adduser admin
adduser gui

patchpkg "g1manfred47kzduec920z88wfr64ylksmdcedlf5" $USER_ADDR_admin # use our custom admin
patchpkg "g1manfred47kzduec920z88wfr64ylksmdcedlf5" $admin_user_addr # use our custom admin

gnoland start

Expand All @@ -20,7 +20,7 @@ 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/$USER_ADDR_test1/mysuperpkg -gas-fee 1000000ugnot -gas-wanted 400000 -broadcast -chainid=tendermint_test gui
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
Expand All @@ -43,12 +43,12 @@ 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/$USER_ADDR_test1/one -gas-fee 1000000ugnot -gas-wanted 1000000 -broadcast -chainid=tendermint_test gui
! gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/$test1_user_addr/one -gas-fee 1000000ugnot -gas-wanted 1000000 -broadcast -chainid=tendermint_test gui
stderr 'unauthorized user'

# Try to add a pkg with an unregistered user, on their own address as namespace
# gui addpkg -> gno.land/r/<addr_gui>/one
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/$USER_ADDR_gui/one -gas-fee 1000000ugnot -gas-wanted 1000000 -broadcast -chainid=tendermint_test gui
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/$gui_user_addr/one -gas-fee 1000000ugnot -gas-wanted 1000000 -broadcast -chainid=tendermint_test gui
stdout 'OK!'

## Test unregistered namespace
Expand All @@ -63,12 +63,12 @@ stderr 'unauthorized user'

# 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 $USER_ADDR_gui admin
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 $USER_ADDR_admin -args 'guiland' -args 'im gui' gui
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
stdout 'OK!'

# Test gui publishing on guiland/one
Expand Down
4 changes: 2 additions & 2 deletions gno.land/pkg/integration/testdata/adduserfrom.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ stdout 'g1mtmrdmqfu0aryqfl4aw65n35haw2wdjkh5p4cp'
gnoland start

## check users initial balance
gnokey query bank/balances/${USER_ADDR_user1}
gnokey query bank/balances/$user1_user_addr
stdout '10000000ugnot'

gnokey query bank/balances/g18e22n23g462drp4pyszyl6e6mwxkaylthgeeq4
stdout '10000000ugnot'

gnokey query auth/accounts/${USER_ADDR_user3}
gnokey query auth/accounts/$user3_user_addr
stdout 'height: 0'
stdout 'data: {'
stdout ' "BaseAccount": {'
Expand Down
9 changes: 4 additions & 5 deletions gno.land/pkg/integration/testdata/event_multi_msg.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ gnokey query auth/accounts/g1c0j899h88nwyvnzvh5jagpq6fkkyuj76nld6t0
stdout 'height: 0'
stdout 'data: {'
stdout ' "BaseAccount": {'
stdout ' "address": "g1c0j899h88nwyvnzvh5jagpq6fkkyuj76nld6t0",'
stdout ' "address": "'${user1_user_addr}'",'
stdout ' "coins": "[0-9]*ugnot",' # dynamic
stdout ' "public_key": null,'
stdout ' "account_number": "57",'
stdout ' "sequence": "0"'
stdout ' "account_number": "'${user1_account_num}'",'
stdout ' "sequence": "'${user1_account_seq}'"'
stdout ' }'
stdout '}'
! stderr '.+' # empty


## sign
gnokey sign -tx-path $WORK/multi/multi_msg.tx -chainid=tendermint_test -account-number 57 -account-sequence 0 user1
gnokey sign -tx-path $WORK/multi/multi_msg.tx -chainid=tendermint_test -account-number $user1_account_num -account-sequence $user1_account_seq user1
stdout 'Tx successfully signed and saved to '

## broadcast
Expand All @@ -51,4 +51,3 @@ func Event(value string) {

-- multi/multi_msg.tx --
{"msg":[{"@type":"/vm.m_call","caller":"g1c0j899h88nwyvnzvh5jagpq6fkkyuj76nld6t0","send":"","pkg_path":"gno.land/r/demo/simple_event","func":"Event","args":["value11"]},{"@type":"/vm.m_call","caller":"g1c0j899h88nwyvnzvh5jagpq6fkkyuj76nld6t0","send":"","pkg_path":"gno.land/r/demo/simple_event","func":"Event","args":["value22"]}],"fee":{"gas_wanted":"2000000","gas_fee":"1000000ugnot"},"signatures":null,"memo":""}

11 changes: 5 additions & 6 deletions gno.land/pkg/integration/testdata/gnokey.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@
# golden files have been generated using UPDATE_SCRIPTS=true

# add a random user
adduserfrom user1 'alpha ability feed thrive color fee grace message chief helmet laundry inmate index brave luxury toddler spawn vague index able zone shoe collect escape'
stdout 'g16v6rp3f4vehjspcu0g0xwz9xvehdkac9kslk5m'
adduser user1

# start gnoland
gnoland start

## test1 account should be available on default
gnokey query auth/accounts/g16v6rp3f4vehjspcu0g0xwz9xvehdkac9kslk5m
gnokey query auth/accounts/$user1_user_addr
stdout 'height: 0'
stdout 'data: {'
stdout ' "BaseAccount": {'
stdout ' "address": "g16v6rp3f4vehjspcu0g0xwz9xvehdkac9kslk5m",'
stdout ' "address": "'${user1_user_addr}'",'
stdout ' "coins": "[0-9]*ugnot",' # dynamic
stdout ' "public_key": null,'
stdout ' "account_number": "57",'
stdout ' "sequence": "0"'
stdout ' "account_number": "'${user1_account_num}'",'
stdout ' "sequence": "'${user1_account_seq}'"'
stdout ' }'
stdout '}'
! stderr '.+' # empty
Expand Down
20 changes: 10 additions & 10 deletions gno.land/pkg/integration/testdata/gnokey_simulate.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,41 @@ loadpkg gno.land/r/hello $WORK/hello
gnoland start

# Initial state: assert that sequence == 0.
gnokey query auth/accounts/$USER_ADDR_test1
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "1"'

# attempt adding the "test" package.
# the package has a syntax error; simulation should catch this ahead of time and prevent the tx.
# -simulate test
! gnokey maketx addpkg -pkgdir $WORK/test -pkgpath gno.land/r/test -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate test test1
gnokey query auth/accounts/$USER_ADDR_test1
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "1"'
# -simulate only
! gnokey maketx addpkg -pkgdir $WORK/test -pkgpath gno.land/r/test -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate only test1
gnokey query auth/accounts/$USER_ADDR_test1
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "1"'
# -simulate skip
! gnokey maketx addpkg -pkgdir $WORK/test -pkgpath gno.land/r/test -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test -simulate skip test1
gnokey query auth/accounts/$USER_ADDR_test1
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "2"'

# attempt calling hello.SetName correctly.
# -simulate test and skip should do it successfully, -simulate only should not.
# -simulate test
gnokey maketx call -pkgpath gno.land/r/hello -func SetName -args John -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate test test1
gnokey query auth/accounts/$USER_ADDR_test1
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "3"'
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, John!'
# -simulate only
gnokey maketx call -pkgpath gno.land/r/hello -func SetName -args Paul -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate only test1
gnokey query auth/accounts/$USER_ADDR_test1
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "3"'
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, John!'
# -simulate skip
gnokey maketx call -pkgpath gno.land/r/hello -func SetName -args George -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate skip test1
gnokey query auth/accounts/$USER_ADDR_test1
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "4"'
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, George!'
Expand All @@ -50,19 +50,19 @@ stdout 'Hello, George!'
# none should change the name (ie. panic rollbacks).
# -simulate test
! gnokey maketx call -pkgpath gno.land/r/hello -func Grumpy -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate test test1
gnokey query auth/accounts/$USER_ADDR_test1
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "4"'
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, George!'
# -simulate only
! gnokey maketx call -pkgpath gno.land/r/hello -func Grumpy -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate only test1
gnokey query auth/accounts/$USER_ADDR_test1
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "4"'
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, George!'
# -simulate skip
! gnokey maketx call -pkgpath gno.land/r/hello -func Grumpy -gas-wanted 2000000 -gas-fee 1000000ugnot -broadcast -chainid tendermint_test -simulate skip test1
gnokey query auth/accounts/$USER_ADDR_test1
gnokey query auth/accounts/$test1_user_addr
stdout '"sequence": "5"'
gnokey query vm/qeval --data "gno.land/r/hello.Hello()"
stdout 'Hello, George!'
Expand Down
4 changes: 2 additions & 2 deletions gno.land/pkg/integration/testdata/patchpkg.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ loadpkg gno.land/r/dev/admin $WORK

adduser dev

patchpkg "g1abcde" $USER_ADDR_dev
patchpkg "g1abcde" $dev_user_addr

gnoland start

gnokey maketx call -pkgpath gno.land/r/dev/admin -func Render -gas-fee 1000000ugnot -gas-wanted 2000000 -args '' -broadcast -chainid=tendermint_test test1
! stdout g1abcde
stdout $USER_ADDR_dev
stdout $dev_user_addr

-- admin.gno --
package admin
Expand Down
30 changes: 15 additions & 15 deletions gno.land/pkg/integration/testdata/prevrealm.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -30,65 +30,65 @@ loadpkg gno.land/p/demo/bar $WORK/p/demo/bar
## start a new node
gnoland start

env RFOO_ADDR=g1evezrh92xaucffmtgsaa3rvmz5s8kedffsg469
env RFOO_USER_ADDR=g1evezrh92xaucffmtgsaa3rvmz5s8kedffsg469

# Test cases
## 1. MsgCall -> myrlm.A: user address
gnokey maketx call -pkgpath gno.land/r/myrlm -func A -gas-fee 100000ugnot -gas-wanted 700000 -broadcast -chainid tendermint_test test1
stdout ${USER_ADDR_test1}
stdout ${test1_user_addr}

## 2. MsgCall -> myrealm.B -> myrlm.A: user address
gnokey maketx call -pkgpath gno.land/r/myrlm -func B -gas-fee 100000ugnot -gas-wanted 800000 -broadcast -chainid tendermint_test test1
stdout ${USER_ADDR_test1}
stdout ${test1_user_addr}

## 3. MsgCall -> r/foo.A -> myrlm.A: r/foo
gnokey maketx call -pkgpath gno.land/r/foo -func A -gas-fee 100000ugnot -gas-wanted 800000 -broadcast -chainid tendermint_test test1
stdout ${RFOO_ADDR}
stdout ${RFOO_USER_ADDR}

## 4. MsgCall -> r/foo.B -> myrlm.B -> r/foo.A: r/foo
gnokey maketx call -pkgpath gno.land/r/foo -func B -gas-fee 100000ugnot -gas-wanted 800000 -broadcast -chainid tendermint_test test1
stdout ${RFOO_ADDR}
stdout ${RFOO_USER_ADDR}

## remove due to update to maketx call can only call realm (case 5, 6, 13)
## 5. MsgCall -> p/demo/bar.A: user address
## gnokey maketx call -pkgpath gno.land/p/demo/bar -func A -gas-fee 100000ugnot -gas-wanted 4000000 -broadcast -chainid tendermint_test test1
## stdout ${USER_ADDR_test1}
## stdout ${test1_user_addr}

## 6. MsgCall -> p/demo/bar.B: user address
## gnokey maketx call -pkgpath gno.land/p/demo/bar -func B -gas-fee 100000ugnot -gas-wanted 4000000 -broadcast -chainid tendermint_test test1
## stdout ${USER_ADDR_test1}
## stdout ${test1_user_addr}

## 7. MsgRun -> myrlm.A: user address
gnokey maketx run -gas-fee 100000ugnot -gas-wanted 12000000 -broadcast -chainid tendermint_test test1 $WORK/run/myrlmA.gno
stdout ${USER_ADDR_test1}
stdout ${test1_user_addr}

## 8. MsgRun -> myrealm.B -> myrlm.A: user address
gnokey maketx run -gas-fee 100000ugnot -gas-wanted 12000000 -broadcast -chainid tendermint_test test1 $WORK/run/myrlmB.gno
stdout ${USER_ADDR_test1}
stdout ${test1_user_addr}

## 9. MsgRun -> r/foo.A -> myrlm.A: r/foo
gnokey maketx run -gas-fee 100000ugnot -gas-wanted 12000000 -broadcast -chainid tendermint_test test1 $WORK/run/fooA.gno
stdout ${RFOO_ADDR}
stdout ${RFOO_USER_ADDR}

## 10. MsgRun -> r/foo.B -> myrlm.B -> r/foo.A: r/foo
gnokey maketx run -gas-fee 100000ugnot -gas-wanted 12000000 -broadcast -chainid tendermint_test test1 $WORK/run/fooB.gno
stdout ${RFOO_ADDR}
stdout ${RFOO_USER_ADDR}

## 11. MsgRun -> p/demo/bar.A -> myrlm.A: user address
gnokey maketx run -gas-fee 100000ugnot -gas-wanted 12000000 -broadcast -chainid tendermint_test test1 $WORK/run/barA.gno
stdout ${USER_ADDR_test1}
stdout ${test1_user_addr}

## 12. MsgRun -> p/demo/bar.B -> myrlm.B -> r/foo.A: user address
gnokey maketx run -gas-fee 100000ugnot -gas-wanted 12000000 -broadcast -chainid tendermint_test test1 $WORK/run/barB.gno
stdout ${USER_ADDR_test1}
stdout ${test1_user_addr}

## 13. MsgCall -> std.PrevRealm(): user address
## gnokey maketx call -pkgpath std -func PrevRealm -gas-fee 100000ugnot -gas-wanted 4000000 -broadcast -chainid tendermint_test test1
## stdout ${USER_ADDR_test1}
## stdout ${test1_user_addr}

## 14. MsgRun -> std.PrevRealm(): user address
gnokey maketx run -gas-fee 100000ugnot -gas-wanted 12000000 -broadcast -chainid tendermint_test test1 $WORK/run/baz.gno
stdout ${USER_ADDR_test1}
stdout ${test1_user_addr}

-- r/myrlm/myrlm.gno --
package myrlm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@ gnokey maketx addpkg -pkgdir $WORK/invalid_realm_denom -pkgpath gno.land/r/test/
gnokey maketx send -send "9999999ugnot" -to g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5 -gas-fee 1ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test2

## check test2 balance
gnokey query bank/balances/${USER_ADDR_test2}
gnokey query bank/balances/${test2_user_addr}
stdout ''

## mint coin from banker
gnokey maketx call -pkgpath gno.land/r/test/realm_banker -func Mint -args ${USER_ADDR_test2} -args "ugnot" -args "31337" -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/test/realm_banker -func Mint -args ${test2_user_addr} -args "ugnot" -args "31337" -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1

## check balance after minting, without patching banker will return '31337ugnot'
gnokey query bank/balances/${USER_ADDR_test2}
gnokey query bank/balances/${test2_user_addr}
stdout '"31337/gno.land/r/test/realm_banker:ugnot"'

## burn coin
gnokey maketx call -pkgpath gno.land/r/test/realm_banker -func Burn -args ${USER_ADDR_test2} -args "ugnot" -args "7" -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1
gnokey maketx call -pkgpath gno.land/r/test/realm_banker -func Burn -args ${test2_user_addr} -args "ugnot" -args "7" -gas-fee 1000000ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1

## check balance after burning
gnokey query bank/balances/${USER_ADDR_test2}
gnokey query bank/balances/${test2_user_addr}
stdout '"31330/gno.land/r/test/realm_banker:ugnot"'

## transfer 1ugnot to test2 for gas-fee of below tx
gnokey maketx send -send "1ugnot" -to ${USER_ADDR_test2} -gas-fee 1ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1
gnokey maketx send -send "1ugnot" -to ${test2_user_addr} -gas-fee 1ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test1

## transfer coin
gnokey maketx send -send "1330/gno.land/r/test/realm_banker:ugnot" -to g1yr0dpfgthph7y6mepdx8afuec4q3ga2lg8tjt0 -gas-fee 1ugnot -gas-wanted 10000000 -broadcast -chainid=tendermint_test test2

## check sender balance
gnokey query bank/balances/${USER_ADDR_test2}
gnokey query bank/balances/${test2_user_addr}
stdout '"30000/gno.land/r/test/realm_banker:ugnot"'

## check receiver balance
Expand Down Expand Up @@ -121,4 +121,4 @@ func Mint(addr std.Address, denom string, amount int64) {
func Burn(addr std.Address, denom string, amount int64) {
banker := std.GetBanker(std.BankerTypeRealmIssue)
banker.RemoveCoin(addr, denom, amount)
}
}
Loading
Loading