Skip to content

Commit

Permalink
Merge branch 'master' into feat/gno-forms
Browse files Browse the repository at this point in the history
  • Loading branch information
agherasie authored Aug 2, 2024
2 parents 10e6843 + 56f8357 commit 854d61b
Show file tree
Hide file tree
Showing 61 changed files with 1,287 additions and 108 deletions.
10 changes: 5 additions & 5 deletions contribs/gnodev/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/charmbracelet/log v0.3.1
github.com/fsnotify/fsnotify v1.7.0
github.com/gnolang/gno v0.0.0-00010101000000-000000000000
github.com/gorilla/websocket v1.5.1
github.com/gorilla/websocket v1.5.3
github.com/muesli/termenv v0.15.2
github.com/stretchr/testify v1.9.0
go.uber.org/zap v1.27.0
Expand All @@ -21,7 +21,7 @@ require (
require (
dario.cat/mergo v1.0.0 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
Expand All @@ -43,7 +43,7 @@ require (
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/peterbourgon/ff/v3 v3.4.0 // indirect
Expand All @@ -56,7 +56,7 @@ require (
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/zondax/hid v0.9.2 // indirect
github.com/zondax/ledger-go v0.14.3 // indirect
go.etcd.io/bbolt v1.3.9 // indirect
go.etcd.io/bbolt v1.3.10 // indirect
go.opentelemetry.io/otel v1.28.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.28.0 // indirect
Expand All @@ -73,7 +73,7 @@ require (
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/tools v0.22.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.65.0 // indirect
Expand Down
20 changes: 10 additions & 10 deletions contribs/gnodev/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions contribs/gnokeykc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (

require (
github.com/alessio/shellescape v1.4.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
Expand All @@ -28,7 +28,7 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
Expand Down
12 changes: 6 additions & 6 deletions contribs/gnokeykc/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/gno.land/r/demo/profile/render.gno
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package profile

import (
"bytes"
"net/url"
"std"

"gno.land/p/demo/mux"
Expand Down Expand Up @@ -83,7 +84,7 @@ func fieldHandler(res *mux.ResponseWriter, req *mux.Request) {

if _, ok := stringFields[field]; ok {
value = ufmt.Sprintf("%s", GetStringField(address, field, "n/a"))
editLink = ufmt.Sprintf(SetStringFieldURL+"&addr=%s&value=%s", field, addr, value)
editLink = ufmt.Sprintf(SetStringFieldURL+"&addr=%s&value=%s", field, addr, url.QueryEscape(value))
} else if _, ok := intFields[field]; ok {
value = ufmt.Sprintf("%d", GetIntField(address, field, 0))
editLink = ufmt.Sprintf(SetIntFieldURL+"&addr=%s&value=%s", field, addr, value)
Expand Down
27 changes: 27 additions & 0 deletions gno.land/cmd/gnoland/testdata/panic.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# test panic

loadpkg gno.land/r/demo/panic $WORK

# start a new node
gnoland start


! gnokey maketx call -pkgpath gno.land/r/demo/panic --func Trigger --gas-fee 1000000ugnot --gas-wanted 2000000 --broadcast -chainid=tendermint_test test1

stderr 'p\<VPBlock\(3\,0\)\>\(\)'
stderr 'gno.land/r/demo/panic/panic.gno:5'
stderr 'pkg\<VPBlock\(1\,0\)\>\.Trigger\(\)'
stderr 'gno.land/r/demo/panic/panic.gno:9'

-- panic.gno --
package main

func p() {
i := "here"
panic(i)
}

func Trigger() {
p()
}

9 changes: 6 additions & 3 deletions gno.land/pkg/sdk/vm/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,15 @@ func (vm *VMKeeper) Call(ctx sdk.Context, msg MsgCall) (res string, err error) {
m.SetActivePackage(mpv)
defer func() {
if r := recover(); r != nil {
switch r.(type) {
switch r := r.(type) {
case store.OutOfGasException: // panic in consumeGas()
panic(r)
case gno.UnhandledPanicError:
err = errors.Wrap(fmt.Errorf("%v", r.Error()), "VM call panic: %s\nStacktrace: %s\n",
r.Error(), m.ExceptionsStacktrace())
default:
err = errors.Wrap(fmt.Errorf("%v", r), "VM call panic: %v\n%s\n",
r, m.String())
err = errors.Wrap(fmt.Errorf("%v", r), "VM call panic: %v\nMachine State:%s\nStacktrace: %s\n",
r, m.String(), m.Stacktrace().String())
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion gnovm/cmd/gno/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func fmtProcessSingleFile(cfg *fmtCfg, file string, processFile fmtProcessFileFu
}
if !cfg.write {
if !cfg.diff && !cfg.quiet {
io.Println(string(out))
io.Out().Write(out)
}
return true
}
Expand Down
10 changes: 8 additions & 2 deletions gnovm/cmd/gno/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,14 @@ func listNonTestFiles(dir string) ([]string, error) {
func runExpr(m *gno.Machine, expr string) {
defer func() {
if r := recover(); r != nil {
fmt.Printf("panic running expression %s: %v\n%s\n",
expr, r, m.String())
switch r := r.(type) {
case gno.UnhandledPanicError:
fmt.Printf("panic running expression %s: %v\nStacktrace: %s\n",
expr, r.Error(), m.ExceptionsStacktrace())
default:
fmt.Printf("panic running expression %s: %v\nMachine State:%s\nStacktrace: %s\n",
expr, r, m.String(), m.Stacktrace().String())
}
panic(r)
}
}()
Expand Down
1 change: 0 additions & 1 deletion gnovm/cmd/gno/testdata/gno_fmt/empty.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ cmp stderr stderr.golden
package hello
-- stdout.golden.gno --
package hello

-- stderr.golden --
1 change: 0 additions & 1 deletion gnovm/cmd/gno/testdata/gno_fmt/import_cleaning.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ var rand = &S{}
package testdata

var yes = rand.Val

-- stderr.golden --
1 change: 0 additions & 1 deletion gnovm/cmd/gno/testdata/gno_fmt/include.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ package testdata
import "gno.land/r/test/mypkg"

var myVar = mypkg.HelloFromMyPkg()

-- stderr.golden --
1 change: 0 additions & 1 deletion gnovm/cmd/gno/testdata/gno_fmt/multi_import.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,4 @@ func myBlog() *blog.Blog {

return &blog.Blog{}
}

-- stderr.golden --
1 change: 0 additions & 1 deletion gnovm/cmd/gno/testdata/gno_fmt/noimport_format.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ import (
)

var yes = rand.Val

-- stderr.golden --
1 change: 0 additions & 1 deletion gnovm/cmd/gno/testdata/gno_fmt/shadow_import.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ import (
func main() {
println("a", v1.Get("a"))
}

-- stderr.golden --
20 changes: 16 additions & 4 deletions gnovm/pkg/gnolang/debugger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type writeNopCloser struct{ io.Writer }
func (writeNopCloser) Close() error { return nil }

// TODO (Marc): move evalTest to gnovm/tests package and remove code duplicates
func evalTest(debugAddr, in, file string) (out, err string) {
func evalTest(debugAddr, in, file string) (out, err, stacktrace string) {
bout := bytes.NewBufferString("")
berr := bytes.NewBufferString("")
stdin := bytes.NewBufferString(in)
Expand Down Expand Up @@ -58,6 +58,18 @@ func evalTest(debugAddr, in, file string) (out, err string) {
})

defer m.Release()
defer func() {
if r := recover(); r != nil {
switch r.(type) {
case gnolang.UnhandledPanicError:
stacktrace = m.ExceptionsStacktrace()
default:
stacktrace = m.Stacktrace().String()
}
stacktrace = strings.TrimSpace(strings.ReplaceAll(stacktrace, "../../tests/files/", "files/"))
panic(r)
}
}()

if debugAddr != "" {
if e := m.Debugger.Serve(debugAddr); e != nil {
Expand All @@ -69,7 +81,7 @@ func evalTest(debugAddr, in, file string) (out, err string) {
m.RunFiles(f)
ex, _ := gnolang.ParseExpr("main()")
m.Eval(ex)
out, err = bout.String(), berr.String()
out, err, stacktrace = bout.String(), berr.String(), m.ExceptionsStacktrace()
return
}

Expand All @@ -78,7 +90,7 @@ func runDebugTest(t *testing.T, targetPath string, tests []dtest) {

for _, test := range tests {
t.Run("", func(t *testing.T) {
out, err := evalTest("", test.in, targetPath)
out, err, _ := evalTest("", test.in, targetPath)
t.Log("in:", test.in, "out:", out, "err:", err)
if !strings.Contains(out, test.out) {
t.Errorf("unexpected output\nwant\"%s\"\n got \"%s\"", test.out, out)
Expand Down Expand Up @@ -194,7 +206,7 @@ func TestRemoteDebug(t *testing.T) {
}

func TestRemoteError(t *testing.T) {
_, err := evalTest(":xxx", "", debugTarget)
_, err, _ := evalTest(":xxx", "", debugTarget)
t.Log("err:", err)
if !strings.Contains(err, "tcp/xxx: unknown port") &&
!strings.Contains(err, "tcp/xxx: nodename nor servname provided, or not known") {
Expand Down
Loading

0 comments on commit 854d61b

Please sign in to comment.