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

Instruction to reproduce weird bug on append #1170

Closed
wants to merge 1 commit into from
Closed
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
27 changes: 27 additions & 0 deletions append_bug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# cd gno.land && go run ./cmd/gnoland start in an other terminal first
#
# Call Append 1
gnokey maketx call -pkgpath "gno.land/r/demo/bug/append" -func "Append" -gas-fee 1000000ugnot -gas-wanted 2000000 -send "" -broadcast -chainid "dev" -args "1" -remote "127.0.0.1:26657" $1
# Call Append 2
gnokey maketx call -pkgpath "gno.land/r/demo/bug/append" -func "Append" -gas-fee 1000000ugnot -gas-wanted 2000000 -send "" -broadcast -chainid "dev" -args "2" -remote "127.0.0.1:26657" $1
# Call Append 3
gnokey maketx call -pkgpath "gno.land/r/demo/bug/append" -func "Append" -gas-fee 1000000ugnot -gas-wanted 2000000 -send "" -broadcast -chainid "dev" -args "3" -remote "127.0.0.1:26657" $1

# Call render
gnokey maketx call -pkgpath "gno.land/r/demo/bug/append" -func "Render" -gas-fee 1000000ugnot -gas-wanted 2000000 -send "" -broadcast -chainid "dev" -args "" -remote "127.0.0.1:26657" $1
# Outputs ("1</br>2</br>3</br>" string) -> OK

# Call Pop
gnokey maketx call -pkgpath "gno.land/r/demo/bug/append" -func "Pop" -gas-fee 1000000ugnot -gas-wanted 2000000 -send "" -broadcast -chainid "dev" -remote "127.0.0.1:26657" $1
# Call render
gnokey maketx call -pkgpath "gno.land/r/demo/bug/append" -func "Render" -gas-fee 1000000ugnot -gas-wanted 2000000 -send "" -broadcast -chainid "dev" -args "" -remote "127.0.0.1:26657" $1
# Outputs ("1</br>2</br>" string) -> WRONG! Pop removes the first item so
# it should be ("2</br>3</br>" 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 "dev" -args "42" -remote "127.0.0.1:26657" $1

# Call render
gnokey maketx call -pkgpath "gno.land/r/demo/bug/append" -func "Render" -gas-fee 1000000ugnot -gas-wanted 2000000 -send "" -broadcast -chainid "dev" -args "" -remote "127.0.0.1:26657" $1
# Ouputs ("1</br>2</br>3</br>" string) -> WTF where is 42 ???

25 changes: 25 additions & 0 deletions examples/gno.land/r/demo/bug/append/append.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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</br>", a[i].i)
}
return s
}
1 change: 1 addition & 0 deletions examples/gno.land/r/demo/bug/append/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/r/demo/bug/append
Loading