mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-06 15:13:14 +00:00
Root parent is None
This commit is contained in:
parent
12ae3532b3
commit
55a780d295
@ -15,6 +15,10 @@ class TestCarnotTree(TestCase):
|
||||
self.assertIs(self.tree.parent_committee(one), root)
|
||||
self.assertIs(self.tree.parent_committee(two), root)
|
||||
|
||||
def test_root_parenting(self):
|
||||
root = self.tree.inner_committees[0]
|
||||
self.assertIsNone(self.tree.parent_committee(root))
|
||||
|
||||
def test_childs(self):
|
||||
root = self.tree.inner_committees[0]
|
||||
one = self.tree.inner_committees[1]
|
||||
|
||||
@ -46,6 +46,9 @@ class CarnotTree:
|
||||
return hashes, dict(enumerate(committees))
|
||||
|
||||
def parent_committee(self, committee_id: Id) -> Optional[Id]:
|
||||
# root committee doesnt have a parent
|
||||
if committee_id == self.inner_committees[0]:
|
||||
return None
|
||||
return self.inner_committees[max(self.committees[committee_id] // 2 - 1, 0)]
|
||||
|
||||
def child_committees(self, committee_id: Id) -> Tuple[Optional[Id], Optional[Id]]:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user