Skip to content

Commit

Permalink
Update returnValue to be hex, rebase on master
Browse files Browse the repository at this point in the history
  • Loading branch information
wurdum committed Feb 21, 2025
1 parent c667eb4 commit 3433f96
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public void Write_with_traces_with_tx_hash(GethLikeTxTrace trace, string json)

Assert.That(JsonElement.DeepEquals(
JsonDocument.Parse(result).RootElement,
JsonDocument.Parse(expected).RootElement));
JsonDocument.Parse(expected).RootElement),
result);
}

[Test]
Expand Down Expand Up @@ -84,7 +85,7 @@ private static IEnumerable<object[]> TracesAndJsonsSource()
new GethLikeTxTrace { Gas = 1, ReturnValue = [0x01], TxHash = null },
"""
{
"result": { "gas": 1, "failed": false, "returnValue": "01", "structLogs": [] },
"result": { "gas": 1, "failed": false, "returnValue": "0x01", "structLogs": [] },
"txHash": null
}
"""
Expand All @@ -93,7 +94,7 @@ private static IEnumerable<object[]> TracesAndJsonsSource()
new GethLikeTxTrace { Gas = 2, ReturnValue = [0x02], TxHash = Hash256.Zero },
"""
{
"result": { "gas": 2, "failed": false, "returnValue": "02", "structLogs": [] },
"result": { "gas": 2, "failed": false, "returnValue": "0x02", "structLogs": [] },
"txHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
"""
Expand All @@ -102,7 +103,7 @@ private static IEnumerable<object[]> TracesAndJsonsSource()
new GethLikeTxTrace { Gas = 3, ReturnValue = [0x03], TxHash = Keccak.Compute("A") },
"""
{
"result": { "gas": 3, "failed": false, "returnValue": "03", "structLogs": [] },
"result": { "gas": 3, "failed": false, "returnValue": "0x03", "structLogs": [] },
"txHash": "0x03783fac2efed8fbc9ad443e592ee30e61d65f471140c10ca155e937b435b760"
}
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public void Write_traces(GethLikeTxTrace trace, string json)

Assert.That(JsonElement.DeepEquals(
JsonDocument.Parse(result).RootElement,
JsonDocument.Parse(json).RootElement));
JsonDocument.Parse(json).RootElement),
result);
}

[TestCaseSource(nameof(CustomValueTracerResults))]
Expand All @@ -45,7 +46,8 @@ public void Write_custom_tracer_result(object value, string expected)

Assert.That(JsonElement.DeepEquals(
JsonDocument.Parse(result).RootElement,
JsonDocument.Parse(expected).RootElement));
JsonDocument.Parse(expected).RootElement),
result);
}

[Test]
Expand Down Expand Up @@ -75,7 +77,7 @@ private static IEnumerable<object[]> TraceAndJsonSource()
{
yield return [
new GethLikeTxTrace { Gas = 1, ReturnValue = [0x01] },
"""{ "gas": 1, "failed": false, "returnValue": "01", "structLogs": [] }"""];
"""{ "gas": 1, "failed": false, "returnValue": "0x01", "structLogs": [] }"""];
yield return [
new GethLikeTxTrace
{
Expand Down Expand Up @@ -112,7 +114,7 @@ private static IEnumerable<object[]> TraceAndJsonSource()
{
"gas" : 100,
"failed" : false,
"returnValue" : "010203",
"returnValue" : "0x010203",
"structLogs" : [ {
"pc" : 0,
"op" : "STOP",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public override void Write(
JsonSerializer.Serialize(writer, value.Failed, options);

writer.WritePropertyName("returnValue"u8);
ByteArrayConverter.Convert(writer, value.ReturnValue, skipLeadingZeros: false, addHexPrefix: false);
JsonSerializer.Serialize(writer, value.ReturnValue, options);

writer.WritePropertyName("structLogs"u8);
JsonSerializer.Serialize(writer, value.Entries, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private static IEnumerable<TestCaseData> TraceBlockSource()
"result": {
"gas": 87700,
"failed": false,
"returnValue": "",
"returnValue": "0x",
"structLogs": [
{ "pc": 0, "op": "PUSH32", "gas": 46536, "gasCost": 3, "depth": 1, "error": null, "stack": [], "storage": {} },
{ "pc": 33, "op": "PUSH1", "gas": 46533, "gasCost": 3, "depth": 1, "error": null, "stack": ["0x6000602055000000000000000000000000000000000000000000000000000000"], "storage": {} },
Expand All @@ -159,7 +159,7 @@ private static IEnumerable<TestCaseData> TraceBlockSource()
"result": {
"gas": 56141,
"failed": false,
"returnValue": "",
"returnValue": "0x",
"structLogs": [
{ "pc": 0, "op": "PUSH1", "gas": 46480, "gasCost": 3, "depth": 1, "error": null, "stack": [], "storage": {} },
{ "pc": 2, "op": "PUSH1", "gas": 46477, "gasCost": 3, "depth": 1, "error": null, "stack": ["0x0"], "storage": {} },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private static IEnumerable<TestCaseData> TraceTransactionTransferSource()
yield return new TestCaseData(
transferTransaction,
new GethTraceOptions(),
"""{"jsonrpc":"2.0","result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]},"id":67}"""
"""{"jsonrpc":"2.0","result":{"gas":21000,"failed":false,"returnValue":"0x","structLogs":[]},"id":67}"""
)
{ TestName = "Transfer with blockMemoryTracer" };

Expand Down Expand Up @@ -208,7 +208,7 @@ private static IEnumerable<TestCaseData> TraceTransactionContractSource()
"result": {
"gas": 55278,
"failed": false,
"returnValue": "",
"returnValue": "0x",
"structLogs": [
{
"pc": 0,
Expand Down

0 comments on commit 3433f96

Please sign in to comment.