def test_old_ic_discard(instance_changes, tconf): frm = "Node1" view_no = 1 quorum = 2 time_provider = MockTimestamp(0) instance_changes = InstanceChanges(tconf, time_provider) msg = InstanceChange(view_no, Suspicions.PRIMARY_DEGRADED.code) time_provider.value = 0 instance_changes.add_vote(msg, frm) time_provider.value += tconf.OUTDATED_INSTANCE_CHANGES_CHECK_INTERVAL + 1 assert not instance_changes.has_view(view_no) instance_changes.add_vote(msg, frm) time_provider.value += tconf.OUTDATED_INSTANCE_CHANGES_CHECK_INTERVAL + 1 assert not instance_changes.has_inst_chng_from(view_no, frm) instance_changes.add_vote(msg, frm) time_provider.value += tconf.OUTDATED_INSTANCE_CHANGES_CHECK_INTERVAL + 1 assert not instance_changes.has_quorum(view_no, quorum)
def test_too_old_messages_dont_count_towards_quorum(instance_changes, tconf): frm1 = "Node1" frm2 = "Node2" view_no = 1 quorum = 2 time_provider = MockTimestamp(0) instance_changes = InstanceChanges(tconf, time_provider) msg = InstanceChange(view_no, Suspicions.PRIMARY_DEGRADED.code) instance_changes.add_vote(msg, frm1) time_provider.value += (tconf.OUTDATED_INSTANCE_CHANGES_CHECK_INTERVAL/2) instance_changes.add_vote(msg, frm2) time_provider.value += (tconf.OUTDATED_INSTANCE_CHANGES_CHECK_INTERVAL/2) + 1 assert not instance_changes.has_quorum(view_no, quorum) assert instance_changes.has_view(view_no) assert instance_changes[view_no].msg == msg assert not instance_changes.has_inst_chng_from(view_no, frm1) assert instance_changes.has_inst_chng_from(view_no, frm2)