Skip to content

Commit

Permalink
stackitem: extend ToJSON test
Browse files Browse the repository at this point in the history
Inspired by neo-project/neo#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>
  • Loading branch information
AnnaShaleva committed Oct 29, 2024
1 parent b8a65d3 commit a0d2f95
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/vm/stackitem/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ func TestToJSONCornerCases(t *testing.T) {
m.Add(Make([]byte{0xe9}), Make(true))
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.
Expand Down

0 comments on commit a0d2f95

Please sign in to comment.