Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add diff script and results #3037

Merged
merged 11 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions src/other/trace_tests/curl_tests/compare_expected_produced.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# Define directories
if [ $# -lt 1 ]; then
comparison_dir="produced/" # folder containing test results to compare
else
comparison_dir=$1
[[ "${comparison_dir: -1}" != "/" ]] && comparison_dir="$comparison_dir/" # add a trailing slash if it does not exist
fi
if [ $# -lt 2 ]; then
expected_dir="expected/" # folder containing expected results
else
expected_dir=$2
[[ "${expected_dir: -1}" != "/" ]] && expected_dir="$expected_dir/" # add a trailing slash if it does not exist
fi
if [ $# -lt 3 ]; then
diffs_dir="diffs/" # folder to save the diffs of the comparison
else
diffs_dir=$3
[[ "${diffs_dir: -1}" != "/" ]] && diffs_dir="$diffs_dir/" # add a trailing slash if it does not exist
fi
echo "Comparing $comparison_dir to $expected_dir, placing results into $diffs_dir"

# hit enter to continue
echo "Press enter to continue..."
read

# Ensure that diffs_dir exists and is empty
mkdir -p "$diffs_dir"
rm -f "$diffs_dir"*.diff

for file in "$expected_dir"*; do # Loop over all files in expected_dir
basefile=$(basename "$file") # Get the base name of the file (removing directory path)
if [[ -f "$comparison_dir$basefile" ]]; then # If the file exists, run the git diff
# save command to run in a command_list
command_to_run="git diff --no-index $expected_dir$basefile $comparison_dir$basefile"
command_list+=("$command_to_run")
diff_output=$(eval "$command_to_run")
if [[ -n "$diff_output" ]]; then # if we have non-empty diffs
echo "$diff_output" > "$diffs_dir$basefile.diff" # save to a diff file
difference_list+=("$basefile") # add the file to the list of differences
else
identical_list+=("$basefile") # add the file to the list of identical files
fi
else
not_found_list+=("$basefile") # add the file to the list of not found files
fi
done

# Save a file to the diffs directory to tell people the command used and time of execution
echo """Comparing $comparison_dir to $expected_dir, placing results into $diffs_dir
Command executed on $(date)
=== Commands executed ===
$(printf "%s\n" "${command_list[@]}")
=== Not found ===
$(printf "%s\n" "${not_found_list[@]}")
=== Identical ===
$(printf "%s\n" "${identical_list[@]}")
=== Difference found ===
$(printf "%s\n" "${difference_list[@]}")""" > "$diffs_dir"log.txt

# print the log file
cat "$diffs_dir"log.txt
22 changes: 22 additions & 0 deletions src/other/trace_tests/curl_tests/diffs/trace_block.json.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/expected/trace_block.json b/produced/trace_block.json
tjayrush marked this conversation as resolved.
Show resolved Hide resolved
index 9e95a22..4dd9f31 100644
--- a/expected/trace_block.json
+++ b/produced/trace_block.json
@@ -14,7 +14,7 @@
"blockHash": "0xcaaa13ce099342d5e1342b04d588d7733093591666af8ef756ce20cf13d16475",
"blockNumber": 1718497,
"result": {
- "gasUsed": "0x3ee428",
+ "gasUsed": "0x3c5fa0",
"output": "0x0000000000000000000000000000000000000000000000000000000000000001"
},
"subtraces": 2,
@@ -2963,7 +2963,7 @@
"blockHash": "0xcaaa13ce099342d5e1342b04d588d7733093591666af8ef756ce20cf13d16475",
"blockNumber": 1718497,
"result": {
- "gasUsed": "0x68eb",
+ "gasUsed": "0x3476",
"output": "0x"
},
"subtraces": 1,
118 changes: 118 additions & 0 deletions src/other/trace_tests/curl_tests/diffs/trace_callMany_all.json.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
diff --git a/expected/trace_callMany_all.json b/produced/trace_callMany_all.json
index cbd5739..7696794 100644
--- a/expected/trace_callMany_all.json
+++ b/produced/trace_callMany_all.json
@@ -1,108 +1,8 @@
{
+ "error": {
+ "code": -32003,
+ "message": "insufficient funds for gas * price + value"
+ },
"id": "1",
- "jsonrpc": "2.0",
- "result": [
- {
- "output": "0x",
- "stateDiff": {
- "0x407d73d8a49eeb85d32cf465507dd71d507100c1": {
- "balance": {
- "+": "0x0"
- },
- "code": {
- "+": "0x"
- },
- "nonce": {
- "+": "0x1"
- },
- "storage": {}
- },
- "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
- "balance": {
- "+": "0x186a0"
- },
- "code": {
- "+": "0x"
- },
- "nonce": {
- "+": "0x0"
- },
- "storage": {}
- }
- },
- "trace": [
- {
- "action": {
- "callType": "call",
- "from": "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
- "gas": "0x1dcd12f8",
- "input": "0x",
- "to": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
- "value": "0x186a0"
- },
- "result": {
- "gasUsed": "0x0",
- "output": "0x"
- },
- "subtraces": 0,
- "traceAddress": [],
- "type": "call"
- }
- ],
- "vmTrace": {
- "code": "0x",
- "ops": []
- }
- },
- {
- "output": "0x",
- "stateDiff": {
- "0x407d73d8a49eeb85d32cf465507dd71d507100c1": {
- "balance": "=",
- "code": "=",
- "nonce": {
- "*": {
- "from": "0x1",
- "to": "0x2"
- }
- },
- "storage": {}
- },
- "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
- "balance": {
- "*": {
- "from": "0x186a0",
- "to": "0x30d40"
- }
- },
- "code": "=",
- "nonce": "=",
- "storage": {}
- }
- },
- "trace": [
- {
- "action": {
- "callType": "call",
- "from": "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
- "gas": "0x1dcd12f8",
- "input": "0x",
- "to": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
- "value": "0x186a0"
- },
- "result": {
- "gasUsed": "0x0",
- "output": "0x"
- },
- "subtraces": 0,
- "traceAddress": [],
- "type": "call"
- }
- ],
- "vmTrace": {
- "code": "0x",
- "ops": []
- }
- }
- ]
+ "jsonrpc": "2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/expected/trace_callMany_none.json b/produced/trace_callMany_none.json
index 0f88a2b..7696794 100644
--- a/expected/trace_callMany_none.json
+++ b/produced/trace_callMany_none.json
@@ -1,18 +1,8 @@
{
+ "error": {
+ "code": -32003,
+ "message": "insufficient funds for gas * price + value"
+ },
"id": "1",
- "jsonrpc": "2.0",
- "result": [
- {
- "output": "0x",
- "stateDiff": null,
- "trace": [],
- "vmTrace": null
- },
- {
- "output": "0x",
- "stateDiff": null,
- "trace": [],
- "vmTrace": null
- }
- ]
+ "jsonrpc": "2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
diff --git a/expected/trace_callMany_stateDiff.json b/produced/trace_callMany_stateDiff.json
index 0c3d94f..7696794 100644
--- a/expected/trace_callMany_stateDiff.json
+++ b/produced/trace_callMany_stateDiff.json
@@ -1,66 +1,8 @@
{
+ "error": {
+ "code": -32003,
+ "message": "insufficient funds for gas * price + value"
+ },
"id": "1",
- "jsonrpc": "2.0",
- "result": [
- {
- "output": "0x",
- "stateDiff": {
- "0x407d73d8a49eeb85d32cf465507dd71d507100c1": {
- "balance": {
- "+": "0x0"
- },
- "code": {
- "+": "0x"
- },
- "nonce": {
- "+": "0x1"
- },
- "storage": {}
- },
- "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
- "balance": {
- "+": "0x186a0"
- },
- "code": {
- "+": "0x"
- },
- "nonce": {
- "+": "0x0"
- },
- "storage": {}
- }
- },
- "trace": [],
- "vmTrace": null
- },
- {
- "output": "0x",
- "stateDiff": {
- "0x407d73d8a49eeb85d32cf465507dd71d507100c1": {
- "balance": "=",
- "code": "=",
- "nonce": {
- "*": {
- "from": "0x1",
- "to": "0x2"
- }
- },
- "storage": {}
- },
- "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": {
- "balance": {
- "*": {
- "from": "0x186a0",
- "to": "0x30d40"
- }
- },
- "code": "=",
- "nonce": "=",
- "storage": {}
- }
- },
- "trace": [],
- "vmTrace": null
- }
- ]
+ "jsonrpc": "2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
diff --git a/expected/trace_callMany_trace.json b/produced/trace_callMany_trace.json
index eae9182..7696794 100644
--- a/expected/trace_callMany_trace.json
+++ b/produced/trace_callMany_trace.json
@@ -1,54 +1,8 @@
{
+ "error": {
+ "code": -32003,
+ "message": "insufficient funds for gas * price + value"
+ },
"id": "1",
- "jsonrpc": "2.0",
- "result": [
- {
- "output": "0x",
- "stateDiff": null,
- "trace": [
- {
- "action": {
- "callType": "call",
- "from": "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
- "gas": "0x1dcd12f8",
- "input": "0x",
- "to": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
- "value": "0x186a0"
- },
- "result": {
- "gasUsed": "0x0",
- "output": "0x"
- },
- "subtraces": 0,
- "traceAddress": [],
- "type": "call"
- }
- ],
- "vmTrace": null
- },
- {
- "output": "0x",
- "stateDiff": null,
- "trace": [
- {
- "action": {
- "callType": "call",
- "from": "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
- "gas": "0x1dcd12f8",
- "input": "0x",
- "to": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
- "value": "0x186a0"
- },
- "result": {
- "gasUsed": "0x0",
- "output": "0x"
- },
- "subtraces": 0,
- "traceAddress": [],
- "type": "call"
- }
- ],
- "vmTrace": null
- }
- ]
+ "jsonrpc": "2.0"
}
Loading