Skip to content

Commit

Permalink
test: add minimal test to demo amino.MustMarshalJSON panic
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Sep 1, 2023
1 parent eb495d2 commit e90bfd8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions gnovm/pkg/gnolang/values_test.go
Original file line number Diff line number Diff line change
@@ -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))
}
2 changes: 1 addition & 1 deletion gnovm/stdlibs/std/crypto.gno
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ func (a Address) String() string {
return string(a)
}

const RawAddressSize = int(20)
const RawAddressSize = 20

type RawAddress [RawAddressSize]byte

0 comments on commit e90bfd8

Please sign in to comment.