From a401b372a64e5ef23e5467c51521d4ed951abd6c Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Wed, 30 Oct 2019 20:25:47 +0900 Subject: [PATCH] Fix JsonSerializer (#1197) --- neo.UnitTests/SmartContract/UT_JsonSerializer.cs | 4 ++-- neo.UnitTests/SmartContract/UT_Syscalls.cs | 4 ++-- neo/SmartContract/JsonSerializer.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/neo.UnitTests/SmartContract/UT_JsonSerializer.cs b/neo.UnitTests/SmartContract/UT_JsonSerializer.cs index e7fdf30667..9863d72b0d 100644 --- a/neo.UnitTests/SmartContract/UT_JsonSerializer.cs +++ b/neo.UnitTests/SmartContract/UT_JsonSerializer.cs @@ -268,7 +268,7 @@ public void Serialize_Array_Bool_Str_Num() var json = JsonSerializer.Serialize(entry).ToString(); - Assert.AreEqual(json, "[true,\"test\",123]"); + Assert.AreEqual(json, "[true,\"74657374\",123]"); } [TestMethod] @@ -297,7 +297,7 @@ public void Serialize_Array_OfArray() var json = JsonSerializer.Serialize(entry).ToString(); - Assert.AreEqual(json, "[[true,\"test1\",123],[true,\"test2\",321]]"); + Assert.AreEqual(json, "[[true,\"7465737431\",123],[true,\"7465737432\",321]]"); } [TestMethod] diff --git a/neo.UnitTests/SmartContract/UT_Syscalls.cs b/neo.UnitTests/SmartContract/UT_Syscalls.cs index 658d125e7f..d24850de40 100644 --- a/neo.UnitTests/SmartContract/UT_Syscalls.cs +++ b/neo.UnitTests/SmartContract/UT_Syscalls.cs @@ -76,7 +76,7 @@ public void System_Blockchain_GetBlock() Assert.AreEqual(1, engine.ResultStack.Count); Assert.IsInstanceOfType(engine.ResultStack.Peek(), typeof(ByteArray)); Assert.AreEqual(engine.ResultStack.Pop().GetByteArray().ToHexString(), - "5b22515c7546464644795c75464646445c75464646445c75303030335c75464646445c75464646445c754646464475465c7530303046715c75303132415c625b595c75303434335c75464646445c75464646447d5d767b385c7546464644785c75303032375c75464646445c7546464644222c332c225c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c7530303030222c225c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c7530303030222c322c312c225c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c75303030305c7530303030222c315d"); + "5b2235316138373966636161303339626461663437353436306637316334616130383562353964313833616239313764356437363762333865613738323766356266222c332c2230303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030222c2230303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030222c322c312c2230303030303030303030303030303030303030303030303030303030303030303030303030303030222c315d"); Assert.AreEqual(0, engine.ResultStack.Count); // Clean @@ -127,7 +127,7 @@ public void System_ExecutionEngine_GetScriptContainer() Assert.AreEqual(1, engine.ResultStack.Count); Assert.IsInstanceOfType(engine.ResultStack.Peek(), typeof(ByteArray)); Assert.AreEqual(engine.ResultStack.Pop().GetByteArray().ToHexString(), - @"5b225c7546464644445c7546464644615c7546464644732c5c75464646445c7546464644665c75303030375d5c75303030305c75464646445c75303632325c7546464644545c7546464644375c7530303133335c75303031385c7530303033655c75464646445c75464646445c75303032375a5c75464646445c2f5c7546464644222c362c342c225c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c75464646445c7546464644222c332c322c352c225c7530303031225d"); + @"5b2266613434383036313834373332636138613136363037356430306133643861326531353462333337313333333138303336356561643732373561663132666264222c362c342c2266666666666666666666666666666666666666666666666666666666666666666666666666666666222c332c322c352c223031225d"); Assert.AreEqual(0, engine.ResultStack.Count); } } diff --git a/neo/SmartContract/JsonSerializer.cs b/neo/SmartContract/JsonSerializer.cs index 1c674540f0..030585420e 100644 --- a/neo/SmartContract/JsonSerializer.cs +++ b/neo/SmartContract/JsonSerializer.cs @@ -26,7 +26,7 @@ public static JObject Serialize(StackItem item) } case ByteArray buffer: { - return buffer.GetString(); + return buffer.GetByteArray().ToHexString(); } case Integer num: {