my erl rlp implementation agrees with ethereum python implementation for 59,638 random cases

This commit is contained in:
2022-10-23 04:55:59 -06:00
parent 9701993e8b
commit 2254c82f77
4 changed files with 119291 additions and 6402 deletions
+1
View File
@@ -6,3 +6,4 @@ jex_include
*.swo *.swo
test/testgen/b58_cases_2.eterms test/testgen/b58_cases_2.eterms
test/testgen/b58_cases_3.eterms test/testgen/b58_cases_3.eterms
__pycache__
@@ -2,10 +2,11 @@
%-compile(export_all). %-compile(export_all).
-mode(compile). -mode(compile).
%-compile(nowarn_unused).
main([]) -> main([]) ->
% Decoded cases % Decoded cases
DecodedCases = rand_decode_datas(5000), DecodedCases = rand_decode_datas(100_000),
%io:format("~p~n", [DecodedCases]), %io:format("~p~n", [DecodedCases]),
io:format("~s~n", [format_cases_py(DecodedCases)]), io:format("~s~n", [format_cases_py(DecodedCases)]),
ok. ok.
@@ -15,7 +16,7 @@ format_cases_py(Cases) ->
% format a list of strings into a python list % format a list of strings into a python list
format_stringlist_py(List) -> format_stringlist_py(List) ->
[$[, slcommas(List, []), $]]. ["cases = [\n", slcommas(List, []), $]].
% similar to commas/2 below but for a list of the dictstrings % similar to commas/2 below but for a list of the dictstrings
% adding a comma, a newline, and a space % adding a comma, a newline, and a space
@@ -34,7 +35,7 @@ slcommas([Item], Acc) ->
[Acc, Item]; [Acc, Item];
% two or more items left, add comma % two or more items left, add comma
slcommas([Item | Rest], Acc) -> slcommas([Item | Rest], Acc) ->
slcommas(Rest, [Acc, Item, ",\n "]). slcommas(Rest, [Acc, Item, ",\n"]).
@@ -48,8 +49,7 @@ format_case_py(DecodedData_rlist) ->
EncodedData_bytes = rlp:encode(DecodedData_rlist), EncodedData_bytes = rlp:encode(DecodedData_rlist),
EncodedBytes_py = format_bytes_py(EncodedData_bytes), EncodedBytes_py = format_bytes_py(EncodedData_bytes),
DecodedData_py = format_data_py(DecodedData_rlist), DecodedData_py = format_data_py(DecodedData_rlist),
% the extra space is intentional because of how we will do list formatting [" {'decoded': ", DecodedData_py, ",\n",
["{'decoded': ", DecodedData_py, ",\n",
" 'encoded': ", EncodedBytes_py, "}"]. " 'encoded': ", EncodedBytes_py, "}"].
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff