fix int encoding, fix list randomization size limit.

This commit is contained in:
protolambda 2019-06-22 21:49:42 +02:00
parent 9befe09f82
commit da858f1aae
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
2 changed files with 5 additions and 2 deletions

View File

@ -8,8 +8,8 @@ def encode(value: SSZValue, include_hash_tree_roots=False):
if isinstance(value, uint):
# Larger uints are boxed and the class declares their byte length
if value.type().byte_len > 8:
return str(value)
return value
return str(int(value))
return int(value)
elif isinstance(value, Bit):
return value == 1
elif isinstance(value, list): # normal python lists, ssz-List, Vector

View File

@ -95,6 +95,9 @@ def get_random_ssz_object(rng: Random,
elif mode == RandomizationMode.mode_max_count:
length = max_list_length
if typ.length < length: # SSZ imposes a hard limit on lists, we can't put in more than that
length = typ.length
return typ(
get_random_ssz_object(rng, typ.elem_type, max_bytes_length, max_list_length, mode, chaos)
for _ in range(length)