Skip to content

Commit

Permalink
Fix JsonSerializer (neo-project#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang authored and Tommo-L committed Jun 22, 2020
1 parent 24cd3df commit a401b37
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions neo.UnitTests/SmartContract/UT_JsonSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions neo.UnitTests/SmartContract/UT_Syscalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion neo/SmartContract/JsonSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static JObject Serialize(StackItem item)
}
case ByteArray buffer:
{
return buffer.GetString();
return buffer.GetByteArray().ToHexString();
}
case Integer num:
{
Expand Down

0 comments on commit a401b37

Please sign in to comment.