Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_avalanche.py
Show All 9 Lines | |||||
from test_framework.key import ( | from test_framework.key import ( | ||||
bytes_to_wif, | bytes_to_wif, | ||||
ECKey, | ECKey, | ||||
ECPubKey, | ECPubKey, | ||||
) | ) | ||||
from test_framework.p2p import P2PInterface, p2p_lock | from test_framework.p2p import P2PInterface, p2p_lock | ||||
from test_framework.messages import ( | from test_framework.messages import ( | ||||
AvalancheDelegation, | AvalancheDelegation, | ||||
AvalancheProof, | |||||
AvalancheResponse, | AvalancheResponse, | ||||
AvalancheVote, | AvalancheVote, | ||||
CInv, | CInv, | ||||
FromHex, | FromHex, | ||||
hash256, | hash256, | ||||
msg_avahello, | msg_avahello, | ||||
msg_avapoll, | msg_avapoll, | ||||
msg_tcpavaresponse, | msg_tcpavaresponse, | ||||
▲ Show 20 Lines • Show All 354 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
assert avakey.verify_schnorr( | assert avakey.verify_schnorr( | ||||
avahello.sig, avahello.get_sighash(good_interface)) | avahello.sig, avahello.get_sighash(good_interface)) | ||||
self.log.info("Test the avahello signature (P2PInterface -> node)") | self.log.info("Test the avahello signature (P2PInterface -> node)") | ||||
stakes = create_coinbase_stakes(node, [blockhashes[1]], addrkey0.key) | stakes = create_coinbase_stakes(node, [blockhashes[1]], addrkey0.key) | ||||
interface_proof_hex = node.buildavalancheproof( | interface_proof_hex = node.buildavalancheproof( | ||||
proof_sequence, proof_expiration, pubkey.get_bytes().hex(), | proof_sequence, proof_expiration, pubkey.get_bytes().hex(), | ||||
stakes) | stakes) | ||||
limited_id = FromHex( | |||||
AvalancheProof(), | |||||
interface_proof_hex).limited_proofid | |||||
# delegate | # delegate | ||||
delegated_key = ECKey() | delegated_key = ECKey() | ||||
delegated_key.generate() | delegated_key.generate() | ||||
interface_delegation_hex = node.delegateavalancheproof( | interface_delegation_hex = node.delegateavalancheproof( | ||||
interface_proof_hex, | f"{limited_id:0{64}x}", | ||||
bytes_to_wif(privkey.get_bytes()), | bytes_to_wif(privkey.get_bytes()), | ||||
delegated_key.get_pubkey().get_bytes().hex(), | delegated_key.get_pubkey().get_bytes().hex(), | ||||
None) | None) | ||||
good_interface.send_avahello(interface_delegation_hex, delegated_key) | good_interface.send_avahello(interface_delegation_hex, delegated_key) | ||||
# Quick check that the good interface is still connected | # Quick check that the good interface is still connected | ||||
# FIXME: when proof relaying is implemented, replace this with a check | # FIXME: when proof relaying is implemented, replace this with a check | ||||
# that the interface is added as a peer. | # that the interface is added as a peer. | ||||
good_interface.sync_with_ping() | good_interface.sync_with_ping() | ||||
Show All 14 Lines |