Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_p2p_avalanche.py
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# Get our own node id so we can use it later. | # Get our own node id so we can use it later. | ||||
n.nodeid = node.getpeerinfo()[-1]['id'] | n.nodeid = node.getpeerinfo()[-1]['id'] | ||||
# Pick on node from the quorum for polling. | # Pick on node from the quorum for polling. | ||||
poll_node = quorum[0] | poll_node = quorum[0] | ||||
# Generate many block and poll for them. | # Generate many block and poll for them. | ||||
address = node.get_deterministic_priv_key().address | address = node.get_deterministic_priv_key().address | ||||
node.generatetoaddress(100, address) | blocks = node.generatetoaddress(100, address) | ||||
def get_coinbase(h): | |||||
b = node.getblock(h, 2) | |||||
return { | |||||
'height': b['height'], | |||||
'txid': b['tx'][0]['txid'], | |||||
'n': 0, | |||||
'value': b['tx'][0]['vout'][0]['value'], | |||||
} | |||||
coinbases = [get_coinbase(h) for h in blocks] | |||||
fork_node = self.nodes[1] | fork_node = self.nodes[1] | ||||
# Make sure the fork node has synced the blocks | # Make sure the fork node has synced the blocks | ||||
self.sync_blocks([node, fork_node]) | self.sync_blocks([node, fork_node]) | ||||
# Get the key so we can verify signatures. | # Get the key so we can verify signatures. | ||||
avakey = ECPubKey() | avakey = ECPubKey() | ||||
avakey.set(bytes.fromhex(node.getavalanchekey())) | avakey.set(bytes.fromhex(node.getavalanchekey())) | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# 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 = node.buildavalancheproof(11, 12, pubkey.get_bytes().hex(), [{ | ||||
'txid': "12b004fff7f4b69ef8650e767f18f11ede158148b425660723b9f9a66e61f747", | 'txid': coinbases[0]['txid'], | ||||
'vout': 0, | 'vout': coinbases[0]['n'], | ||||
'amount': 10, | 'amount': coinbases[0]['value'], | ||||
'height': 100, | 'height': coinbases[0]['height'], | ||||
'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 | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |