Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_avalanche.py
Show First 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
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() | pubkey = privkey.get_pubkey() | ||||
privatekey = node.get_deterministic_priv_key().key | privatekey = node.get_deterministic_priv_key().key | ||||
proof = node.buildavalancheproof(11, 12, pubkey.get_bytes().hex(), [{ | proof_sequence = 11 | ||||
proof_expiration = 12 | |||||
proof = node.buildavalancheproof( | |||||
proof_sequence, proof_expiration, pubkey.get_bytes().hex(), | |||||
[{ | |||||
'txid': coinbases[0]['txid'], | 'txid': coinbases[0]['txid'], | ||||
'vout': coinbases[0]['n'], | 'vout': coinbases[0]['n'], | ||||
'amount': coinbases[0]['value'], | 'amount': coinbases[0]['value'], | ||||
'height': coinbases[0]['height'], | 'height': coinbases[0]['height'], | ||||
'iscoinbase': True, | 'iscoinbase': True, | ||||
'privatekey': privatekey, | 'privatekey': privatekey, | ||||
}]) | }]) | ||||
# 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, pubkey.get_bytes().hex(), proof) | ||||
assert success is True | assert success is True | ||||
self.log.info("Testing getavalanchepeerinfo...") | |||||
avapeerinfo = node.getavalanchepeerinfo() | |||||
# There is a single peer because all nodes share the same proof. | |||||
assert_equal(len(avapeerinfo), 1) | |||||
assert_equal(avapeerinfo[0]["peerid"], 0) | |||||
assert_equal(avapeerinfo[0]["nodecount"], len(quorum)) | |||||
# The first avalanche node index is 1, because 0 is self.nodes[1]. | |||||
assert_equal(avapeerinfo[0]["nodes"], list(range(1, 17))) | |||||
assert_equal(avapeerinfo[0]["sequence"], proof_sequence) | |||||
assert_equal(avapeerinfo[0]["expiration"], proof_expiration) | |||||
assert_equal(avapeerinfo[0]["master"], pubkey.get_bytes().hex()) | |||||
assert_equal(avapeerinfo[0]["proof"], proof) | |||||
assert_equal(len(avapeerinfo[0]["stakes"]), 1) | |||||
assert_equal(avapeerinfo[0]["stakes"][0]["txid"], coinbases[0]['txid']) | |||||
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 | ||||
if poll is None: | if poll is None: | ||||
continue | continue | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |