From 7b0ffc1ace8eefb61d459cddff94969a9601df52 Mon Sep 17 00:00:00 2001 From: protolambda Date: Fri, 14 Jun 2019 19:09:49 +0200 Subject: [PATCH] move decoder for fuzzing, minor fixes, update dependency to support SOS style offsets --- test_libs/fuzzing/requirements.txt | 3 --- test_libs/pyspec/eth2spec/fuzzing/__init__.py | 0 test_libs/{ => pyspec/eth2spec}/fuzzing/decoder.py | 8 ++++---- test_libs/pyspec/requirements.txt | 1 + test_libs/pyspec/setup.py | 3 ++- 5 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 test_libs/fuzzing/requirements.txt create mode 100644 test_libs/pyspec/eth2spec/fuzzing/__init__.py rename test_libs/{ => pyspec/eth2spec}/fuzzing/decoder.py (89%) diff --git a/test_libs/fuzzing/requirements.txt b/test_libs/fuzzing/requirements.txt deleted file mode 100644 index 98dcd9564..000000000 --- a/test_libs/fuzzing/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -../../test_libs/pyspec -../../test_libs/config_helpers -ssz==0.1.0a8 diff --git a/test_libs/pyspec/eth2spec/fuzzing/__init__.py b/test_libs/pyspec/eth2spec/fuzzing/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/test_libs/fuzzing/decoder.py b/test_libs/pyspec/eth2spec/fuzzing/decoder.py similarity index 89% rename from test_libs/fuzzing/decoder.py rename to test_libs/pyspec/eth2spec/fuzzing/decoder.py index 16d798f6f..bb8aceb61 100644 --- a/test_libs/fuzzing/decoder.py +++ b/test_libs/pyspec/eth2spec/fuzzing/decoder.py @@ -10,7 +10,7 @@ def translate_typ(typ) -> ssz.BaseSedes: """ if spec_ssz.is_container_type(typ): return ssz.Container( - [(field_name, translate_typ(field_typ)) for (field_name, field_typ) in typ.get_fields()]) + [translate_typ(field_typ) for (field_name, field_typ) in typ.get_fields()]) elif spec_ssz.is_bytesn_type(typ): return ssz.ByteVector(typ.length) elif spec_ssz.is_bytes_type(typ): @@ -38,7 +38,7 @@ def translate_typ(typ) -> ssz.BaseSedes: else: raise TypeError("invalid uint size") else: - raise Exception("Type not supported: {}".format(typ)) + raise TypeError("Type not supported: {}".format(typ)) def translate_value(value, typ): @@ -79,6 +79,6 @@ def translate_value(value, typ): return value elif spec_ssz.is_container_type(typ): return typ(**{f_name: translate_value(f_val, f_typ) for (f_name, f_val, f_typ) - in zip(typ.get_field_names(), value.values(), typ.get_field_types())}) + in zip(typ.get_field_names(), value, typ.get_field_types())}) else: - raise Exception("Type not supported: {}".format(typ)) + raise TypeError("Type not supported: {}".format(typ)) diff --git a/test_libs/pyspec/requirements.txt b/test_libs/pyspec/requirements.txt index 3b38930bd..eed0d5a7d 100644 --- a/test_libs/pyspec/requirements.txt +++ b/test_libs/pyspec/requirements.txt @@ -3,3 +3,4 @@ eth-typing>=2.1.0,<3.0.0 pycryptodome==3.7.3 py_ecc>=1.6.0 typing_inspect==0.4.0 +ssz==0.1.0a9 diff --git a/test_libs/pyspec/setup.py b/test_libs/pyspec/setup.py index e99b911ee..49f3c84a1 100644 --- a/test_libs/pyspec/setup.py +++ b/test_libs/pyspec/setup.py @@ -9,6 +9,7 @@ setup( "eth-typing>=2.1.0,<3.0.0", "pycryptodome==3.7.3", "py_ecc>=1.6.0", - "typing_inspect==0.4.0" + "typing_inspect==0.4.0", + "ssz==0.1.0a9" ] )