Bluesky MST: test_is_order_independent works

pull/482/head
Ryan Barrett 2023-04-14 21:30:58 -07:00
rodzic 86144ba50f
commit 4f21d190cb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 13 dodań i 14 usunięć

Wyświetl plik

@ -70,8 +70,8 @@ Data = namedtuple('Data', [
])
Leaf = namedtuple('Leaf', [
'key', # str, record key ??? or bytes?
'value', # CID ???
'key', # str, record key
'value', # CID
])
@ -143,7 +143,7 @@ class MST:
# -------------------
def get_pointer(self):
"""Returns this MST's root CID ??? pointer. Calculates it if needed.
"""Returns this MST's root CID pointer. Calculates it if necessary.
We don't hash the node on every mutation for performance reasons.
Instead we keep track of whether the pointer is outdated and only

Wyświetl plik

@ -124,20 +124,19 @@ class MstTest(testutil.TestCase):
for key, cid in the_rest:
self.assertEqual(cid, mst.get(key))
# def test_is_order_independent(self):
# mst = MST()
# self.shuffled = self.shuffled[:200]
# for key, cid in self.shuffled:
# mst = mst.add(key, cid)
def test_is_order_independent(self):
mst = MST()
for key, cid in self.shuffled:
mst = mst.add(key, cid)
# all_nodes = mst.all_nodes()
all_nodes = mst.all_nodes()
# recreated = MST()
# random.shuffle(self.shuffled)
# for key, cid in self.shuffled:
# recreated = recreated.add(key, cid)
recreated = MST()
random.shuffle(self.shuffled)
for key, cid in self.shuffled:
recreated = recreated.add(key, cid)
# self.assertEqual(all_nodes, recreated.all_nodes())
self.assertEqual(all_nodes, recreated.all_nodes())
# def test_diffs(self):
# to_diff = MST()