Skip to content

Commit

Permalink
picked changes from linting + class-typing updates in 1180, for partials
Browse files Browse the repository at this point in the history
  • Loading branch information
protolambda committed Jun 20, 2019
1 parent 5c2c5e6 commit 58ffa41
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 74 deletions.
20 changes: 14 additions & 6 deletions test_libs/pyspec/eth2spec/test_ssz_partials.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
from utils.ssz.ssz_typing import *
from utils.ssz.ssz_impl import *
from utils.ssz.ssz_partials import *
import os, random
from eth2spec.utils.ssz.ssz_impl import serialize, hash_tree_root
from eth2spec.utils.ssz.ssz_typing import (
Bit, Bytes, uint64, Container, Vector, List
)

from eth2spec.utils.ssz.ssz_partials import (
ssz_full, ssz_partial, extract_value_at_path, merge
)


class Person(Container):
is_male: bool
is_male: Bit
age: uint64
name: Bytes[32]


class City(Container):
coords: Vector[uint64, 2]
people: List[Person, 20]


people = List[Person, 20](
Person(is_male=True, age=uint64(45), name=Bytes[32](b"Alex")),
Person(is_male=True, age=uint64(47), name=Bytes[32](b"Bob")),
Expand Down Expand Up @@ -59,7 +66,8 @@ class City(Container):
assert p.people[1].name.hash_tree_root() == hash_tree_root(city.people[1].name)
assert p.people[1].hash_tree_root() == hash_tree_root(city.people[1])
assert p.coords.hash_tree_root() == hash_tree_root(city.coords)
assert p.people.hash_tree_root() == hash_tree_root(city.people), (p.people.hash_tree_root(), hash_tree_root(city.people))
assert p.people.hash_tree_root() == hash_tree_root(city.people), (
p.people.hash_tree_root(), hash_tree_root(city.people))
assert p.hash_tree_root() == hash_tree_root(city)
print(hash_tree_root(city))
print("Reading tests passed")
Expand Down
Loading

0 comments on commit 58ffa41

Please sign in to comment.