Skip to content

Commit

Permalink
Added txtar test
Browse files Browse the repository at this point in the history
  • Loading branch information
deelawn committed Oct 27, 2023
1 parent 09df263 commit cec8f0d
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions gno.land/cmd/gnoland/testdata/append.txtar
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

0 comments on commit cec8f0d

Please sign in to comment.