Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/avatools.py
| Show First 20 Lines • Show All 445 Lines • ▼ Show 20 Lines | ) -> msg_avaproofs: | ||||
| msg.prefilled_proofs = prefilled_proofs or [] | msg.prefilled_proofs = prefilled_proofs or [] | ||||
| msg.shortids = [ | msg.shortids = [ | ||||
| calculate_shortid(msg.key0, msg.key1, proof.proofid) for proof in proofs | calculate_shortid(msg.key0, msg.key1, proof.proofid) for proof in proofs | ||||
| ] | ] | ||||
| return msg | return msg | ||||
| def can_find_inv_in_poll(quorum, inv_hash, response=AvalancheVoteError.ACCEPTED): | def can_find_inv_in_poll( | ||||
| quorum, | |||||
| inv_hash, | |||||
| response=AvalancheVoteError.ACCEPTED, | |||||
| other_response=AvalancheVoteError.ACCEPTED, | |||||
| ): | |||||
| found_hash = False | found_hash = False | ||||
| for n in quorum: | for n in quorum: | ||||
| poll = n.get_avapoll_if_available() | poll = n.get_avapoll_if_available() | ||||
| # That node has not received a poll | # That node has not received a poll | ||||
| if poll is None: | if poll is None: | ||||
| continue | continue | ||||
| # We got a poll, check for the hash and repond | # We got a poll, check for the hash and repond | ||||
| votes = [] | votes = [] | ||||
| for inv in poll.invs: | for inv in poll.invs: | ||||
| # Vote yes to everything | # Vote to everything but our searched inv | ||||
| r = AvalancheVoteError.ACCEPTED | r = other_response | ||||
| # Look for what we expect | # Look for what we expect | ||||
| if inv.hash == inv_hash: | if inv.hash == inv_hash: | ||||
| r = response | r = response | ||||
| found_hash = True | found_hash = True | ||||
| votes.append(AvalancheVote(r, inv.hash)) | votes.append(AvalancheVote(r, inv.hash)) | ||||
| n.send_avaresponse(poll.round, votes, n.delegated_privkey) | n.send_avaresponse(poll.round, votes, n.delegated_privkey) | ||||
| return found_hash | return found_hash | ||||