diff --git a/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py b/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py index ea4d85e82..51a790853 100644 --- a/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py +++ b/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py @@ -154,11 +154,11 @@ class Container(Series, metaclass=SSZType): super().__setattr__(name, value) def __repr__(self): - return repr({field: getattr(self, field) for field in self.get_fields()}) + return repr({field: getattr(self, field) for field in self.get_fields().keys()}) def __str__(self): output = [f'{self.__class__.__name__}'] - for field in self.get_fields(): + for field in self.get_fields().keys(): output.append(f' {field}: {getattr(self, field)}') return "\n".join(output) @@ -176,7 +176,7 @@ class Container(Series, metaclass=SSZType): @classmethod def default(cls): - return cls(**{f: t.default() for f, t in cls.get_fields()}) + return cls(**{f: t.default() for f, t in cls.get_fields().items()}) @classmethod def is_fixed_size(cls): diff --git a/test_libs/pyspec/eth2spec/utils/ssz/test_ssz_typing.py b/test_libs/pyspec/eth2spec/utils/ssz/test_ssz_typing.py index f604b6468..6bb56f4e5 100644 --- a/test_libs/pyspec/eth2spec/utils/ssz/test_ssz_typing.py +++ b/test_libs/pyspec/eth2spec/utils/ssz/test_ssz_typing.py @@ -76,6 +76,10 @@ def test_container(): a: uint8 b: uint32 + empty = Foo() + assert empty.a == uint8(0) + assert empty.b == uint32(0) + assert issubclass(Foo, Container) assert issubclass(Foo, SSZValue) assert issubclass(Foo, Series)