From 7c0cc7f801259edfad890122ae61e5859548e923 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Thu, 13 Jun 2019 14:32:45 -0600 Subject: [PATCH] fix #1169 bytes type error --- test_libs/pyspec/eth2spec/test/sanity/test_blocks.py | 2 ++ test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py b/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py index 2275161c8..1abda292a 100644 --- a/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py +++ b/test_libs/pyspec/eth2spec/test/sanity/test_blocks.py @@ -33,6 +33,7 @@ def test_empty_block_transition(spec, state): assert len(state.eth1_data_votes) == pre_eth1_votes + 1 assert spec.get_block_root_at_slot(state, pre_slot) == block.parent_root + assert spec.get_randao_mix(state, spec.get_current_epoch(state)) != spec.ZERO_HASH @with_all_phases @@ -51,6 +52,7 @@ def test_skipped_slots(spec, state): yield 'post', state assert state.slot == block.slot + assert spec.get_randao_mix(state, spec.get_current_epoch(state)) != spec.ZERO_HASH for slot in range(pre_slot, state.slot): assert spec.get_block_root_at_slot(state, slot) == block.parent_root diff --git a/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py b/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py index 55ced4ee2..bb98fb084 100644 --- a/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py +++ b/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py @@ -1,3 +1,4 @@ +from types import GeneratorType from typing import List, Iterable, TypeVar, Type, NewType from typing import Union from typing_inspect import get_origin @@ -356,6 +357,8 @@ def parse_bytes(val): return val elif isinstance(val, int): return bytes([val]) + elif isinstance(val, (list, GeneratorType)): + return bytes(val) else: return None