Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_avalanche_voting.py
Show All 13 Lines | from test_framework.key import ( | ||||
ECPubKey, | ECPubKey, | ||||
) | ) | ||||
from test_framework.messages import AvalancheVote | from test_framework.messages import 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_equal, | ||||
wait_until, | wait_until, | ||||
) | ) | ||||
from test_framework.wallet_util import bytes_to_wif | |||||
BLOCK_ACCEPTED = 0 | BLOCK_ACCEPTED = 0 | ||||
BLOCK_INVALID = 1 | BLOCK_INVALID = 1 | ||||
BLOCK_PARKED = 2 | BLOCK_PARKED = 2 | ||||
BLOCK_FORK = 3 | BLOCK_FORK = 3 | ||||
BLOCK_UNKNOWN = -1 | BLOCK_UNKNOWN = -1 | ||||
BLOCK_MISSING = -2 | BLOCK_MISSING = -2 | ||||
BLOCK_PENDING = -3 | BLOCK_PENDING = -3 | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
[AvalancheVote(BLOCK_FORK, h) for h in various_block_hashes[3:6]] + | [AvalancheVote(BLOCK_FORK, h) for h in various_block_hashes[3:6]] + | ||||
[AvalancheVote(BLOCK_UNKNOWN, h) for h in various_block_hashes[-3:]]) | [AvalancheVote(BLOCK_UNKNOWN, h) for h in various_block_hashes[-3:]]) | ||||
self.log.info("Trigger polling from the node...") | self.log.info("Trigger polling from the node...") | ||||
# duplicate the deterministic sig test from src/test/key_tests.cpp | # duplicate the deterministic sig test from src/test/key_tests.cpp | ||||
privkey = ECKey() | privkey = ECKey() | ||||
privkey.set(bytes.fromhex( | privkey.set(bytes.fromhex( | ||||
"12b004fff7f4b69ef8650e767f18f11ede158148b425660723b9f9a66e61f747"), True) | "12b004fff7f4b69ef8650e767f18f11ede158148b425660723b9f9a66e61f747"), True) | ||||
pubkey = privkey.get_pubkey() | |||||
proof_sequence = 11 | proof_sequence = 11 | ||||
proof_expiration = 12 | proof_expiration = 12 | ||||
proof = node.buildavalancheproof( | proof = node.buildavalancheproof( | ||||
proof_sequence, proof_expiration, pubkey.get_bytes().hex(), | proof_sequence, proof_expiration, bytes_to_wif( | ||||
privkey.get_bytes()), | |||||
stakes) | stakes) | ||||
# Activate the quorum. | # Activate the quorum. | ||||
for n in quorum: | for n in quorum: | ||||
success = node.addavalanchenode( | success = node.addavalanchenode( | ||||
n.nodeid, pubkey.get_bytes().hex(), proof) | n.nodeid, privkey.get_pubkey().get_bytes().hex(), proof) | ||||
assert success is True | assert success is True | ||||
def can_find_block_in_poll(hash, resp=BLOCK_ACCEPTED): | def can_find_block_in_poll(hash, resp=BLOCK_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 | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |