Skip to content

Commit

Permalink
chore: try to automate bug in gnoverse/gnochess#97
Browse files Browse the repository at this point in the history
Signed-off-by: moul <94029+moul@users.noreply.github.com>
  • Loading branch information
moul committed Sep 25, 2023
1 parent f5c62d4 commit 73d1505
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions gno.land/cmd/gnoland/testdata/bug-gnochess-97.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# test for https://github.com/gnolang/gnochess/issues/97

## start a new node
gnoland start

gnokey maketx addpkg -pkgdir $WORK -pkgpath gno.land/r/demo/bug97 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1

gnokey maketx call -pkgpath 'gno.land/r/demo/bug97' -func 'Render' -args '' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' test1
stdout '("default:a,b,c\\n" string)'

gnokey maketx call -pkgpath 'gno.land/r/demo/bug97' -func 'Bar' -args 'hello' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' test1
gnokey maketx call -pkgpath 'gno.land/r/demo/bug97' -func 'Render' -args '' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' test1
stdout '("default:a,b,c\\narr0:a,hello,c\\n" string)'


gnokey maketx call -pkgpath 'gno.land/r/demo/bug97' -func 'Bar' -args 'hi' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' test1
gnokey maketx call -pkgpath 'gno.land/r/demo/bug97' -func 'Render' -args '' -gas-fee 1000000ugnot -gas-wanted 2000000 -send '' -broadcast -chainid='tendermint_test' test1
stdout '("default:a,b,c\\narr0:a,hello,c\\narr1:a,hi,c\\n" string)'

-- bug97.gno --
package bug97

import "strings"
import "gno.land/p/demo/ufmt"

var defaultSlice = [...]string{"a", "b", "c"}

var arrays = [][...]string{}

func NewSlice() [...]string { return defaultSlice }

func Bar(replace string) {
bar := NewSlice()
bar[1] = replace
arrays = append(arrays, bar)
}

func Render(_ string) string {
output := ufmt.Sprintf("default:%s\n", strings.Join(defaultSlice[:], ","))
for idx, arr := range arrays {
output += ufmt.Sprintf("arr%d:%s\n", idx, strings.Join(arr[:], ","))
}
return output
}

0 comments on commit 73d1505

Please sign in to comment.