Add a check to make sure that during state conflict res we only request a PDU we don't have.
This commit is contained in:
parent
1a26905cc9
commit
c5f2da5875
|
@ -191,10 +191,18 @@ class StateHandler(object):
|
||||||
key=lambda x: x.depth
|
key=lambda x: x.depth
|
||||||
)
|
)
|
||||||
|
|
||||||
|
pdu_id = missing_prev.prev_state_id
|
||||||
|
origin = missing_prev.prev_state_origin
|
||||||
|
|
||||||
|
is_missing = yield self.store.get_pdu(pdu_id, origin) is None
|
||||||
|
|
||||||
|
if not is_missing:
|
||||||
|
raise Exception("Conflict resolution failed.")
|
||||||
|
|
||||||
yield self._replication.get_pdu(
|
yield self._replication.get_pdu(
|
||||||
destination=missing_prev.origin,
|
destination=missing_prev.origin,
|
||||||
pdu_origin=missing_prev.prev_state_origin,
|
pdu_origin=origin,
|
||||||
pdu_id=missing_prev.prev_state_id,
|
pdu_id=pdu_id,
|
||||||
outlier=True
|
outlier=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ class StateTestCase(unittest.TestCase):
|
||||||
"update_current_state",
|
"update_current_state",
|
||||||
"get_latest_pdus_in_context",
|
"get_latest_pdus_in_context",
|
||||||
"get_current_state",
|
"get_current_state",
|
||||||
|
"get_pdu",
|
||||||
])
|
])
|
||||||
self.replication = Mock(spec=["get_pdu"])
|
self.replication = Mock(spec=["get_pdu"])
|
||||||
|
|
||||||
|
@ -220,6 +221,8 @@ class StateTestCase(unittest.TestCase):
|
||||||
|
|
||||||
self.replication.get_pdu.side_effect = set_return_tree
|
self.replication.get_pdu.side_effect = set_return_tree
|
||||||
|
|
||||||
|
self.persistence.get_pdu.return_value = None
|
||||||
|
|
||||||
is_new = yield self.state.handle_new_state(new_pdu)
|
is_new = yield self.state.handle_new_state(new_pdu)
|
||||||
|
|
||||||
self.assertTrue(is_new)
|
self.assertTrue(is_new)
|
||||||
|
|
Loading…
Reference in New Issue