Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_avalanche_proof_voting.py
Show All 14 Lines | |||||
) | ) | ||||
from test_framework.key import ECPubKey | from test_framework.key import ECPubKey | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
MSG_AVA_PROOF, | MSG_AVA_PROOF, | ||||
AvalancheProofVoteResponse, | AvalancheProofVoteResponse, | ||||
AvalancheVote, | AvalancheVote, | ||||
) | ) | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import ( | from test_framework.util import assert_equal, assert_raises_rpc_error, try_rpc | ||||
assert_equal, | |||||
assert_greater_than, | |||||
assert_raises_rpc_error, | |||||
try_rpc, | |||||
) | |||||
from test_framework.wallet_util import bytes_to_wif | from test_framework.wallet_util import bytes_to_wif | ||||
QUORUM_NODE_COUNT = 16 | QUORUM_NODE_COUNT = 16 | ||||
class AvalancheProofVotingTest(BitcoinTestFramework): | class AvalancheProofVotingTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
▲ Show 20 Lines • Show All 202 Lines • ▼ Show 20 Lines | def update_tests(self, node): | ||||
self.send_and_check_for_polling(peer, proof_seq30) | self.send_and_check_for_polling(peer, proof_seq30) | ||||
# Let the quorum vote for it | # Let the quorum vote for it | ||||
self.wait_until(lambda: accept_proof(proofid_seq30)) | self.wait_until(lambda: accept_proof(proofid_seq30)) | ||||
assert proofid_seq40 not in get_proof_ids(node) | assert proofid_seq40 not in get_proof_ids(node) | ||||
self.log.info("Test the peer replacement rate limit") | self.log.info("Test the peer replacement rate limit") | ||||
# Wait until proof_seq30 is finalized | def vote_until_finalized(proofid): | ||||
retry = 5 | self.can_find_proof_in_poll( | ||||
while retry > 0: | proofid, response=AvalancheProofVoteResponse.ACTIVE) | ||||
try: | return node.getrawavalancheproof( | ||||
with node.assert_debug_log([f"Avalanche finalized proof {proofid_seq30:0{64}x}"]): | f"{proofid:0{64}x}").get("finalized", False) | ||||
self.wait_until(lambda: not self.can_find_proof_in_poll( | |||||
proofid_seq30, response=AvalancheProofVoteResponse.ACTIVE)) | |||||
break | |||||
except AssertionError: | |||||
retry -= 1 | |||||
assert_greater_than(retry, 0) | # Wait until proof_seq30 is finalized | ||||
self.wait_until(lambda: vote_until_finalized(proofid_seq30)) | |||||
# Not enough | # Not enough | ||||
assert self.conflicting_proof_cooldown < self.peer_replacement_cooldown | assert self.conflicting_proof_cooldown < self.peer_replacement_cooldown | ||||
mock_time += self.conflicting_proof_cooldown | mock_time += self.conflicting_proof_cooldown | ||||
node.setmocktime(mock_time) | node.setmocktime(mock_time) | ||||
peer = get_ava_p2p_interface(node) | peer = get_ava_p2p_interface(node) | ||||
▲ Show 20 Lines • Show All 286 Lines • Show Last 20 Lines |