mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-09 11:19:06 +00:00
stackitem: extend ToJSON test
Inspired by https://github.com/neo-project/neo/pull/3558, although this PR fixes different implementation of stackitem serializatior that is used outside of VM. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
b8a65d3c37
commit
a0d2f95e42
1 changed files with 12 additions and 0 deletions
|
@ -203,6 +203,18 @@ func TestToJSONCornerCases(t *testing.T) {
|
||||||
m.Add(Make([]byte{0xe9}), Make(true))
|
m.Add(Make([]byte{0xe9}), Make(true))
|
||||||
testToJSON(t, ErrInvalidValue, m)
|
testToJSON(t, ErrInvalidValue, m)
|
||||||
})
|
})
|
||||||
|
t.Run("circular reference", func(t *testing.T) {
|
||||||
|
m := NewMap()
|
||||||
|
m.Add(Make("one"), Make(true))
|
||||||
|
|
||||||
|
// No circular reference, ensure it can be properly serialized.
|
||||||
|
arr := NewArray([]Item{m, m})
|
||||||
|
testToJSON(t, nil, arr)
|
||||||
|
|
||||||
|
// With circular reference, error expected.
|
||||||
|
m.Add(Make("two"), arr)
|
||||||
|
testToJSON(t, ErrTooBig, arr)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// getBigArray returns array takes up a lot of storage when serialized.
|
// getBigArray returns array takes up a lot of storage when serialized.
|
||||||
|
|
Loading…
Reference in a new issue