fix wording and improve encoding logic

This commit is contained in:
protolambda 2019-05-06 15:40:18 +02:00
parent 8b24abde31
commit a8d8da25fd
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
1 changed files with 6 additions and 3 deletions

View File

@ -3,7 +3,7 @@ from eth2spec.debug.encode import encode
def spectest(description: str = None): def spectest(description: str = None):
def runner(fn): def runner(fn):
# this wraps the function, to hide that the function actually yielding data. # this wraps the function, to hide that the function actually is yielding data, instead of returning once.
def entry(*args, **kw): def entry(*args, **kw):
# check generator mode, may be None/else. # check generator mode, may be None/else.
# "pop" removes it, so it is not passed to the inner function. # "pop" removes it, so it is not passed to the inner function.
@ -25,8 +25,11 @@ def spectest(description: str = None):
(key, value, typ) = data (key, value, typ) = data
out[key] = encode(value, typ) out[key] = encode(value, typ)
else: else:
# Otherwise, just put the raw value. # Otherwise, try to infer the type, but keep it as-is if it's not a SSZ container.
(key, value) = data (key, value) = data
if hasattr(value.__class__, 'fields'):
out[key] = encode(value, value.__class__)
else:
out[key] = value out[key] = value
return out return out
else: else: