def test_3PC_key_comaparison(): assert compare_3PC_keys((1,2), (1,2)) == 0 assert compare_3PC_keys((1,3), (1,2)) < 0 assert compare_3PC_keys((1,2), (1,3)) > 0 assert compare_3PC_keys((1,2), (1,10)) > 0 assert compare_3PC_keys((1, 100), (2, 3)) > 0 assert compare_3PC_keys((1, 100), (4, 3)) > 0 assert compare_3PC_keys((2, 100), (1, 300)) < 0 assert min_3PC_key([(2, 100), (1, 300), (5, 600)]) == (1, 300) assert min_3PC_key([(2, 100), (2, 300), (2, 600)]) == (2, 100) assert min_3PC_key([(2, 100), (2, 300), (1, 600)]) == (1, 600) assert max_3PC_key([(2, 100), (1, 300), (5, 6)]) == (5, 6) assert max_3PC_key([(2, 100), (3, 20), (4, 1)]) == (4, 1) assert max_3PC_key([(2, 100), (2, 300), (2, 400)]) == (2, 400)
def test_3PC_key_comaparison(): assert compare_3PC_keys((1, 2), (1, 2)) == 0 assert compare_3PC_keys((1, 3), (1, 2)) < 0 assert compare_3PC_keys((1, 2), (1, 3)) > 0 assert compare_3PC_keys((1, 2), (1, 10)) > 0 assert compare_3PC_keys((1, 100), (2, 3)) > 0 assert compare_3PC_keys((1, 100), (4, 3)) > 0 assert compare_3PC_keys((2, 100), (1, 300)) < 0 assert min_3PC_key([(2, 100), (1, 300), (5, 600)]) == (1, 300) assert min_3PC_key([(2, 100), (2, 300), (2, 600)]) == (2, 100) assert min_3PC_key([(2, 100), (2, 300), (1, 600)]) == (1, 600) assert max_3PC_key([(2, 100), (1, 300), (5, 6)]) == (5, 6) assert max_3PC_key([(2, 100), (3, 20), (4, 1)]) == (4, 1) assert max_3PC_key([(2, 100), (2, 300), (2, 400)]) == (2, 400)
def test_3PC_key_comaparison(): # Because of INDY-1336 compare_3PC_keys, min_3PC_key, max_3PC_key # taking into account only ppSeqNo part assert compare_3PC_keys((1, 2), (1, 2)) == 0 assert compare_3PC_keys((1, 3), (1, 2)) < 0 assert compare_3PC_keys((1, 2), (1, 3)) > 0 assert compare_3PC_keys((1, 2), (1, 10)) > 0 assert compare_3PC_keys((1, 100), (2, 3)) < 0 assert compare_3PC_keys((1, 100), (4, 3)) < 0 assert compare_3PC_keys((2, 100), (1, 300)) > 0 assert min_3PC_key([(2, 100), (1, 300), (5, 600)]) == (2, 100) assert min_3PC_key([(2, 100), (2, 300), (2, 600)]) == (2, 100) assert min_3PC_key([(2, 100), (2, 300), (1, 600)]) == (2, 100) assert max_3PC_key([(2, 100), (1, 300), (5, 6)]) == (1, 300) assert max_3PC_key([(2, 100), (3, 20), (4, 1)]) == (2, 100) assert max_3PC_key([(2, 100), (2, 300), (2, 400)]) == (2, 400)
def last_prepared_certificate(nodes): """ Find last prepared certificate in pool. When we don't have any request ordered in new view last_prepared_certificate_in_view() returns None, but in order to ease maths (like being able to use max_3PC_key, or calculating next expected 3PC key) this value is replaced with (view_no, 0). """ def patched_last_prepared_certificate(n): result = n.master_replica.last_prepared_certificate_in_view() if result is None: result = (n.master_replica.viewNo, 0) return result return max_3PC_key(patched_last_prepared_certificate(n) for n in nodes)