From e90bfd83d9aa13947c61845a30e36a6a6a1c7955 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Thu, 10 Aug 2023 17:56:05 +0200 Subject: [PATCH] test: add minimal test to demo amino.MustMarshalJSON panic --- gnovm/pkg/gnolang/values_test.go | 22 ++++++++++++++++++++++ gnovm/stdlibs/std/crypto.gno | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gnovm/pkg/gnolang/values_test.go diff --git a/gnovm/pkg/gnolang/values_test.go b/gnovm/pkg/gnolang/values_test.go new file mode 100644 index 00000000000..199117b1426 --- /dev/null +++ b/gnovm/pkg/gnolang/values_test.go @@ -0,0 +1,22 @@ +package gnolang + +import ( + "math/big" + "testing" + + "github.com/gnolang/gno/tm2/pkg/amino" +) + +// This test exposes a panics that occurs when BigintValue is embedded +// in an other struct. +func TestAminoMustMarshalJSONPanics(t *testing.T) { + bi := BigintValue{V: big.NewInt(20)} + b := amino.MustMarshalJSON(bi) // works well + println(string(b)) + + pv := PackageValue{ + Block: bi, + } + b = amino.MustMarshalJSON(pv) // panics + println(string(b)) +} diff --git a/gnovm/stdlibs/std/crypto.gno b/gnovm/stdlibs/std/crypto.gno index 18402c0824d..3ebd802dc3f 100644 --- a/gnovm/stdlibs/std/crypto.gno +++ b/gnovm/stdlibs/std/crypto.gno @@ -6,6 +6,6 @@ func (a Address) String() string { return string(a) } -const RawAddressSize = int(20) +const RawAddressSize = 20 type RawAddress [RawAddressSize]byte