Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/avatools.py
Show All 12 Lines | |||||
from .messages import ( | from .messages import ( | ||||
MSG_AVA_PROOF, | MSG_AVA_PROOF, | ||||
MSG_BLOCK, | MSG_BLOCK, | ||||
NODE_AVALANCHE, | NODE_AVALANCHE, | ||||
NODE_NETWORK, | NODE_NETWORK, | ||||
AvalancheDelegation, | AvalancheDelegation, | ||||
AvalancheProof, | AvalancheProof, | ||||
AvalancheResponse, | AvalancheResponse, | ||||
AvalancheVote, | |||||
AvalancheVoteError, | |||||
CInv, | CInv, | ||||
CTransaction, | CTransaction, | ||||
FromHex, | FromHex, | ||||
TCPAvalancheResponse, | TCPAvalancheResponse, | ||||
ToHex, | ToHex, | ||||
calculate_shortid, | calculate_shortid, | ||||
hash256, | hash256, | ||||
msg_avahello, | msg_avahello, | ||||
▲ Show 20 Lines • Show All 394 Lines • ▼ Show 20 Lines | def build_msg_avaproofs(proofs: List[AvalancheProof], prefilled_proofs: Optional[List[AvalancheProof]] | ||||
msg.prefilled_proofs = prefilled_proofs or [] | msg.prefilled_proofs = prefilled_proofs or [] | ||||
msg.shortids = [ | msg.shortids = [ | ||||
calculate_shortid( | calculate_shortid( | ||||
msg.key0, | msg.key0, | ||||
msg.key1, | msg.key1, | ||||
proof.proofid) for proof in proofs] | proof.proofid) for proof in proofs] | ||||
return msg | return msg | ||||
def can_find_inv_in_poll(quorum, hash, response=AvalancheVoteError.ACCEPTED): | |||||
found_hash = False | |||||
for n in quorum: | |||||
poll = n.get_avapoll_if_available() | |||||
# That node has not received a poll | |||||
if poll is None: | |||||
continue | |||||
# We got a poll, check for the hash and repond | |||||
votes = [] | |||||
for inv in poll.invs: | |||||
# Vote yes to everything | |||||
r = AvalancheVoteError.ACCEPTED | |||||
# Look for what we expect | |||||
if inv.hash == hash: | |||||
r = response | |||||
found_hash = True | |||||
votes.append(AvalancheVote(r, inv.hash)) | |||||
n.send_avaresponse(poll.round, votes, n.delegated_privkey) | |||||
return found_hash |