Merge pull request #1289 from ethereum/update_ssz_fuzzing
Bump `py-ssz` to `0.1.3` and update the fuzzing tests
This commit is contained in:
commit
f1db318acb
|
@ -1,4 +1,4 @@
|
||||||
eth-utils==1.6.0
|
eth-utils==1.6.0
|
||||||
../../test_libs/gen_helpers
|
../../test_libs/gen_helpers
|
||||||
../../test_libs/config_helpers
|
../../test_libs/config_helpers
|
||||||
ssz==0.1.0a2
|
ssz==0.1.3
|
||||||
|
|
|
@ -18,14 +18,11 @@ def translate_typ(typ) -> ssz.BaseSedes:
|
||||||
elif issubclass(typ, spec_ssz.Vector):
|
elif issubclass(typ, spec_ssz.Vector):
|
||||||
return ssz.Vector(translate_typ(typ.elem_type), typ.length)
|
return ssz.Vector(translate_typ(typ.elem_type), typ.length)
|
||||||
elif issubclass(typ, spec_ssz.List):
|
elif issubclass(typ, spec_ssz.List):
|
||||||
# TODO: Make py-ssz List support the new fixed length list
|
return ssz.List(translate_typ(typ.elem_type), typ.length)
|
||||||
return ssz.List(translate_typ(typ.elem_type))
|
|
||||||
elif issubclass(typ, spec_ssz.Bitlist):
|
elif issubclass(typ, spec_ssz.Bitlist):
|
||||||
# TODO: Once Bitlist implemented in py-ssz, use appropriate type
|
return ssz.Bitlist(typ.length)
|
||||||
return ssz.List(translate_typ(typ.elem_type))
|
|
||||||
elif issubclass(typ, spec_ssz.Bitvector):
|
elif issubclass(typ, spec_ssz.Bitvector):
|
||||||
# TODO: Once Bitvector implemented in py-ssz, use appropriate type
|
return ssz.Bitvector(typ.length)
|
||||||
return ssz.Vector(translate_typ(typ.elem_type), typ.length)
|
|
||||||
elif issubclass(typ, spec_ssz.boolean):
|
elif issubclass(typ, spec_ssz.boolean):
|
||||||
return ssz.boolean
|
return ssz.boolean
|
||||||
elif issubclass(typ, spec_ssz.uint):
|
elif issubclass(typ, spec_ssz.uint):
|
||||||
|
|
|
@ -9,9 +9,7 @@ def test_decoder():
|
||||||
rng = Random(123)
|
rng = Random(123)
|
||||||
|
|
||||||
# check these types only, Block covers a lot of operation types already.
|
# check these types only, Block covers a lot of operation types already.
|
||||||
# TODO: Once has Bitlists and Bitvectors, add back
|
for typ in [spec.AttestationDataAndCustodyBit, spec.BeaconState, spec.BeaconBlock]:
|
||||||
# spec.BeaconState and spec.BeaconBlock
|
|
||||||
for typ in [spec.IndexedAttestation, spec.AttestationDataAndCustodyBit]:
|
|
||||||
# create a random pyspec value
|
# create a random pyspec value
|
||||||
original = random_value.get_random_ssz_object(rng, typ, 100, 10,
|
original = random_value.get_random_ssz_object(rng, typ, 100, 10,
|
||||||
mode=random_value.RandomizationMode.mode_random,
|
mode=random_value.RandomizationMode.mode_random,
|
||||||
|
@ -32,4 +30,6 @@ def test_decoder():
|
||||||
block = translate_value(raw_value, typ)
|
block = translate_value(raw_value, typ)
|
||||||
|
|
||||||
# and see if the hash-tree-root of the original matches the hash-tree-root of the decoded & translated value.
|
# and see if the hash-tree-root of the original matches the hash-tree-root of the decoded & translated value.
|
||||||
assert spec_ssz_impl.hash_tree_root(original) == spec_ssz_impl.hash_tree_root(block)
|
original_hash_tree_root = spec_ssz_impl.hash_tree_root(original)
|
||||||
|
assert original_hash_tree_root == spec_ssz_impl.hash_tree_root(block)
|
||||||
|
assert original_hash_tree_root == block_sedes.get_hash_tree_root(raw_value)
|
||||||
|
|
|
@ -3,4 +3,4 @@ eth-typing>=2.1.0,<3.0.0
|
||||||
pycryptodome==3.7.3
|
pycryptodome==3.7.3
|
||||||
py_ecc==1.7.1
|
py_ecc==1.7.1
|
||||||
dataclasses==0.6
|
dataclasses==0.6
|
||||||
ssz==0.1.0a10
|
ssz==0.1.3
|
||||||
|
|
|
@ -9,7 +9,7 @@ setup(
|
||||||
"eth-typing>=2.1.0,<3.0.0",
|
"eth-typing>=2.1.0,<3.0.0",
|
||||||
"pycryptodome==3.7.3",
|
"pycryptodome==3.7.3",
|
||||||
"py_ecc==1.7.1",
|
"py_ecc==1.7.1",
|
||||||
"ssz==0.1.0a10",
|
"ssz==0.1.3",
|
||||||
"dataclasses==0.6",
|
"dataclasses==0.6",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue