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 _get_last_txn_3PC_key(self): quorumed_3PC_keys = \ [ most_common_element for most_common_element, freq in Counter(self._last_txn_3PC_key.values()).most_common() if self._quorum.ledger_status_last_3PC.is_reached( freq) and most_common_element[0] is not None and most_common_element[1] is not None ] if len(quorumed_3PC_keys) == 0: return None min_quorumed_3PC_key = min_3PC_key(quorumed_3PC_keys) return min_quorumed_3PC_key
def _get_last_txn_3PC_key(self, ledgerInfo): quorum = Quorums(self.owner.totalNodes) quorumed_3PC_keys = \ [ most_common_element for most_common_element, freq in Counter(ledgerInfo.last_txn_3PC_key.values()).most_common() if quorum.ledger_status_last_3PC.is_reached(freq) and most_common_element[0] is not None and most_common_element[1] is not None ] if len(quorumed_3PC_keys) == 0: return None min_quorumed_3PC_key = min_3PC_key(quorumed_3PC_keys) return min_quorumed_3PC_key