mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Fix chain cover update to handle events with duplicate auth events (#9210)
This commit is contained in:
parent
28f255d5f3
commit
056327457f
1
changelog.d/9210.bugfix
Normal file
1
changelog.d/9210.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix chain cover update to handle events with duplicate auth events. Introduced in v1.26.0rc1.
|
@ -78,7 +78,7 @@ def sorted_topologically(
|
|||||||
if node not in degree_map:
|
if node not in degree_map:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for edge in edges:
|
for edge in set(edges):
|
||||||
if edge in degree_map:
|
if edge in degree_map:
|
||||||
degree_map[node] += 1
|
degree_map[node] += 1
|
||||||
|
|
||||||
|
@ -92,3 +92,15 @@ class SortTopologically(TestCase):
|
|||||||
# Valid orderings are `[1, 3, 2, 4]` or `[1, 2, 3, 4]`, but we should
|
# Valid orderings are `[1, 3, 2, 4]` or `[1, 2, 3, 4]`, but we should
|
||||||
# always get the same one.
|
# always get the same one.
|
||||||
self.assertEqual(list(sorted_topologically([4, 3, 2, 1], graph)), [1, 2, 3, 4])
|
self.assertEqual(list(sorted_topologically([4, 3, 2, 1], graph)), [1, 2, 3, 4])
|
||||||
|
|
||||||
|
def test_duplicates(self):
|
||||||
|
"Test that a graph with duplicate edges work"
|
||||||
|
graph = {1: [], 2: [1, 1], 3: [2, 2], 4: [3]} # type: Dict[int, List[int]]
|
||||||
|
|
||||||
|
self.assertEqual(list(sorted_topologically([4, 3, 2, 1], graph)), [1, 2, 3, 4])
|
||||||
|
|
||||||
|
def test_multiple_paths(self):
|
||||||
|
"Test that a graph with multiple paths between two nodes work"
|
||||||
|
graph = {1: [], 2: [1], 3: [2], 4: [3, 2, 1]} # type: Dict[int, List[int]]
|
||||||
|
|
||||||
|
self.assertEqual(list(sorted_topologically([4, 3, 2, 1], graph)), [1, 2, 3, 4])
|
||||||
|
Loading…
Reference in New Issue
Block a user