Skip to content

Commit

Permalink
fix ssz container recognition for generators
Browse files Browse the repository at this point in the history
  • Loading branch information
protolambda committed Jun 11, 2019
1 parent 94d4e3a commit 3a0b8e0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test_libs/pyspec/eth2spec/test/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Dict, Any, Callable, Iterable
from eth2spec.debug.encode import encode
from eth2spec.utils.ssz.ssz_typing import Container


def spectest(description: str = None):
Expand Down Expand Up @@ -30,9 +31,13 @@ def entry(*args, **kw):
else:
# Otherwise, try to infer the type, but keep it as-is if it's not a SSZ container.
(key, value) = data
if hasattr(value.__class__, 'fields'):
if isinstance(value, Container):
out[key] = encode(value, value.__class__)
else:
# not a ssz value.
# It could be vector or bytes still, but it is a rare case,
# and lists can't be inferred fully (generics loose element type).
# In such cases, explicitly state the type of the yielded value as a third yielded object.
out[key] = value
if has_contents:
return out
Expand Down

0 comments on commit 3a0b8e0

Please sign in to comment.