accept yielded lists, encode per item

This commit is contained in:
protolambda 2019-06-30 15:27:31 +02:00
parent c1317640c4
commit b38802ced0
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
1 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,6 @@
from typing import Dict, Any, Callable, Iterable
from eth2spec.debug.encode import encode
from eth2spec.utils.ssz.ssz_typing import Container
from eth2spec.utils.ssz.ssz_typing import SSZValue
def spectest(description: str = None):
@ -31,8 +31,10 @@ def spectest(description: str = None):
else:
# Otherwise, try to infer the type, but keep it as-is if it's not a SSZ container.
(key, value) = data
if isinstance(value, Container):
if isinstance(value, SSZValue):
out[key] = encode(value, value.__class__)
elif isinstance(value, list) and all([isinstance(el, SSZValue) for el in value]):
out[key] = [encode(el, el.__class__) for el in value]
else:
# not a ssz value.
# It could be vector or bytes still, but it is a rare case,