mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 01:41:48 +00:00
core: remove System.Json.[Serialize, Deserialize] interops
And move their tests to native StdLib.
This commit is contained in:
parent
f65485b735
commit
4d2ad4b9e2
7 changed files with 44 additions and 130 deletions
|
@ -94,3 +94,47 @@ func TestStdLibItoaAtoi(t *testing.T) {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestStdLibJSON(t *testing.T) {
|
||||
s := newStd()
|
||||
ic := &interop.Context{VM: vm.New()}
|
||||
var actual stackitem.Item
|
||||
|
||||
t.Run("JSONSerialize", func(t *testing.T) {
|
||||
t.Run("Good", func(t *testing.T) {
|
||||
require.NotPanics(t, func() {
|
||||
actual = s.jsonSerialize(ic, []stackitem.Item{stackitem.Make(42)})
|
||||
})
|
||||
|
||||
require.Equal(t, stackitem.Make([]byte("42")), actual)
|
||||
})
|
||||
|
||||
t.Run("Bad", func(t *testing.T) {
|
||||
arr := stackitem.NewArray([]stackitem.Item{
|
||||
stackitem.NewByteArray(make([]byte, stackitem.MaxSize/2)),
|
||||
stackitem.NewByteArray(make([]byte, stackitem.MaxSize/2)),
|
||||
})
|
||||
require.Panics(t, func() {
|
||||
_ = s.jsonSerialize(ic, []stackitem.Item{arr})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("JSONDeserialize", func(t *testing.T) {
|
||||
t.Run("Good", func(t *testing.T) {
|
||||
require.NotPanics(t, func() {
|
||||
actual = s.jsonDeserialize(ic, []stackitem.Item{stackitem.Make("42")})
|
||||
})
|
||||
|
||||
require.Equal(t, stackitem.Make(42), actual)
|
||||
})
|
||||
t.Run("Bad", func(t *testing.T) {
|
||||
require.Panics(t, func() {
|
||||
_ = s.jsonDeserialize(ic, []stackitem.Item{stackitem.Make("{]")})
|
||||
})
|
||||
require.Panics(t, func() {
|
||||
_ = s.jsonDeserialize(ic, []stackitem.Item{stackitem.NewInterop(nil)})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue