forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# start a new node | ||
gnoland start | ||
|
||
gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/append -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
|
||
# Call Append 1 | ||
gnokey maketx call -pkgpath gno.land/r/append -func Append -gas-fee 1000000ugnot -gas-wanted 2000000 -args '1' -broadcast -chainid=tendermint_test test1 | ||
# Call Append 2 | ||
gnokey maketx call -pkgpath gno.land/r/append -func Append -gas-fee 1000000ugnot -gas-wanted 2000000 -args '2' -broadcast -chainid=tendermint_test test1 | ||
# Call Append 3 | ||
gnokey maketx call -pkgpath gno.land/r/append -func Append -gas-fee 1000000ugnot -gas-wanted 2000000 -args '3' -broadcast -chainid=tendermint_test test1 | ||
|
||
# Call render | ||
gnokey maketx call -pkgpath gno.land/r/append -func Render -gas-fee 1000000ugnot -gas-wanted 2000000 -args '' -broadcast -chainid=tendermint_test test1 | ||
|
||
cmp stdout stdout.golden.1 | ||
|
||
# Call Pop | ||
gnokey maketx call -pkgpath gno.land/r/append -func Pop -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 | ||
# Call render | ||
gnokey maketx call -pkgpath gno.land/r/append -func Render -gas-fee 1000000ugnot -gas-wanted 2000000 -args '' -broadcast -chainid=tendermint_test test1 | ||
|
||
cmp stdout stdout.golden.2 | ||
|
||
# Call Append 42 | ||
gnokey maketx call -pkgpath gno.land/r/append -func Append -gas-fee 1000000ugnot -gas-wanted 2000000 -args '42' -broadcast -chainid=tendermint_test test1 | ||
|
||
# Call render | ||
gnokey maketx call -pkgpath gno.land/r/append -func Render -gas-fee 1000000ugnot -gas-wanted 2000000 -args '' -broadcast -chainid=tendermint_test test1 | ||
|
||
cmp stdout stdout.golden.3 | ||
|
||
-- append.gno -- | ||
package append | ||
|
||
import ( | ||
"gno.land/p/demo/ufmt" | ||
) | ||
|
||
type T struct{ i int } | ||
|
||
var a []T | ||
|
||
func init() { | ||
a = make([]T, 0, 1) | ||
} | ||
|
||
func Pop() { | ||
a = append(a[:0], a[1:]...) | ||
} | ||
|
||
func Append(i int) { | ||
a = append(a, T{i: i}) | ||
} | ||
|
||
func Render(path string) string { | ||
var s string | ||
for i:=0;i<len(a);i++{ | ||
s+=ufmt.Sprintf("%d-", a[i].i) | ||
} | ||
return s | ||
} | ||
-- stdout.golden.1 -- | ||
("1-2-3-" string) | ||
OK! | ||
GAS WANTED: 2000000 | ||
GAS USED: 95179 | ||
-- stdout.golden.2 -- | ||
("2-3-" string) | ||
OK! | ||
GAS WANTED: 2000000 | ||
GAS USED: 93546 | ||
-- stdout.golden.3 -- | ||
("2-3-42-" string) | ||
OK! | ||
GAS WANTED: 2000000 | ||
GAS USED: 95191 |