Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_avalanche_quorum.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2020-2022 The Bitcoin developers | # Copyright (c) 2020-2022 The Bitcoin developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test the quorum detection of avalanche.""" | """Test the quorum detection of avalanche.""" | ||||
from test_framework.avatools import ( | from test_framework.avatools import ( | ||||
AvaP2PInterface, | AvaP2PInterface, | ||||
build_msg_avaproofs, | build_msg_avaproofs, | ||||
gen_proof, | gen_proof, | ||||
get_ava_p2p_interface, | get_ava_p2p_interface, | ||||
get_proof_ids, | |||||
wait_for_proof, | wait_for_proof, | ||||
) | ) | ||||
from test_framework.key import ECPubKey | from test_framework.key import ECPubKey | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
NODE_AVALANCHE, | NODE_AVALANCHE, | ||||
NODE_NETWORK, | NODE_NETWORK, | ||||
AvalancheVote, | AvalancheVote, | ||||
AvalancheVoteError, | AvalancheVoteError, | ||||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
add_avapeer_and_check_status( | add_avapeer_and_check_status( | ||||
peers[self.min_avaproofs_node_count - 1], [ | peers[self.min_avaproofs_node_count - 1], [ | ||||
AvalancheVoteError.ACCEPTED, | AvalancheVoteError.ACCEPTED, | ||||
AvalancheVoteError.ACCEPTED, | AvalancheVoteError.ACCEPTED, | ||||
AvalancheVoteError.UNKNOWN, | AvalancheVoteError.UNKNOWN, | ||||
]) | ]) | ||||
# The proofs are not requested during IBD, so node 2 has no proof yet. | |||||
assert_equal(len(get_proof_ids(self.nodes[2])), 0) | |||||
# And all the nodes are pending | |||||
assert_equal( | |||||
self.nodes[2].getavalancheinfo()['network']['pending_node_count'], | |||||
self.min_avaproofs_node_count) | |||||
self.nodes[2].generate(1) | self.nodes[2].generate(1) | ||||
assert not self.nodes[2].getblockchaininfo()['initialblockdownload'] | assert not self.nodes[2].getblockchaininfo()['initialblockdownload'] | ||||
# Connect the pending nodes so the next compact proofs requests can get | |||||
# accounted for | |||||
for i in range(self.min_avaproofs_node_count): | |||||
node.sendavalancheproof(peers[i]['proof'].serialize().hex()) | |||||
assert_equal(self.nodes[2].getavalancheinfo()[ | |||||
'network']['pending_node_count'], 0) | |||||
# The avaproofs message are not accounted during IBD, so this is not | # The avaproofs message are not accounted during IBD, so this is not | ||||
# enough. | # enough. | ||||
poll_and_assert_response(self.nodes[2], AvalancheVoteError.UNKNOWN) | poll_and_assert_response(self.nodes[2], AvalancheVoteError.UNKNOWN) | ||||
# Connect more peers to reach the message threshold while node 2 is out | # Connect more peers to reach the message threshold while node 2 is out | ||||
# of IBD. | # of IBD. | ||||
for i in range(self.min_avaproofs_node_count - 1): | for i in range(self.min_avaproofs_node_count - 1): | ||||
add_avapeer_and_check_status( | add_avapeer_and_check_status( | ||||
Show All 39 Lines |