From ef501721bafb64393fc32b30fdcd7fee0d03f1e3 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Mon, 25 Sep 2023 11:10:52 -0700 Subject: [PATCH] chore: txtar for 1170 Signed-off-by: moul <94029+moul@users.noreply.github.com> --- gno.land/cmd/gnoland/testdata/bug-1170.txtar | 76 ++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 gno.land/cmd/gnoland/testdata/bug-1170.txtar diff --git a/gno.land/cmd/gnoland/testdata/bug-1170.txtar b/gno.land/cmd/gnoland/testdata/bug-1170.txtar new file mode 100644 index 00000000000..7b9e251e1ea --- /dev/null +++ b/gno.land/cmd/gnoland/testdata/bug-1170.txtar @@ -0,0 +1,76 @@ +# test for add package + +## start a new node +gnoland start + +gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/demo/bug/append -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 + +# Call Append 1 +gnokey maketx call -pkgpath 'gno.land/r/demo/bug/append' -func 'Append' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' -args '1' test1 +# Call Append 2 +gnokey maketx call -pkgpath 'gno.land/r/demo/bug/append' -func 'Append' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' -args '2' test1 +# Call Append 3 +gnokey maketx call -pkgpath 'gno.land/r/demo/bug/append' -func 'Append' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' -args '3' test1 + +# Call render +gnokey maketx call -pkgpath 'gno.land/r/demo/bug/append' -func 'Render' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' -args '' test1 +cmp stdout render1.golden + +# Call Pop +gnokey maketx call -pkgpath 'gno.land/r/demo/bug/append' -func 'Pop' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' test1 +# Call render +gnokey maketx call -pkgpath 'gno.land/r/demo/bug/append' -func 'Render' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' -args '' test1 +cmp stdout render2.golden +# Outputs ('1
2
' string) -> WRONG! Pop removes the first item so +# it should be ('2
3
' string) + +# Call Append 42 +gnokey maketx call -pkgpath 'gno.land/r/demo/bug/append' -func 'Append' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' -args '42' test1 + +# Call render +gnokey maketx call -pkgpath 'gno.land/r/demo/bug/append' -func 'Render' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' -args '' test1 +cmp stdout render3.golden +# Ouputs ('1
2
3
' string) -> WTF where is 42 ??? + +-- append.gno -- +package append + +import ( + "gno.land/p/demo/ufmt" +) + +type T struct{ i int } + +var a []T + +func Append(i int) { + a = append(a, T{i: i}) +} + +func Pop() { + a = append(a[:0], a[1:]...) +} + +func Render(_ string) string { + var s string + for i := 0; i < len(a); i++ { + s += ufmt.Sprintf("%d
", a[i].i) + } + return s +} + +-- render1.golden -- +("1
2
3
" string) +OK! +GAS WANTED: 2000000 +GAS USED: 107530 +-- render2.golden -- +("1
2
" string) +OK! +GAS WANTED: 2000000 +GAS USED: 105888 +-- render3.golden -- +("1
2
3
" string) +OK! +GAS WANTED: 2000000 +GAS USED: 107530 \ No newline at end of file