Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc_rpc_getavalanchepeerinfo.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2020-2021 The Bitcoin developers | # Copyright (c) 2020-2021 The Bitcoin developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test the getavalanchepeerinfo RPC.""" | """Test the getavalanchepeerinfo RPC.""" | ||||
from random import choice | from random import choice | ||||
from test_framework.avatools import ( | from test_framework.avatools import ( | ||||
avalanche_proof_from_hex, | avalanche_proof_from_hex, | ||||
create_coinbase_stakes, | create_coinbase_stakes, | ||||
get_ava_p2p_interface, | get_ava_p2p_interface_no_handshake, | ||||
) | ) | ||||
from test_framework.key import ECKey | from test_framework.key import ECKey | ||||
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, | ||||
assert_raises_rpc_error, | assert_raises_rpc_error, | ||||
uint256_hex, | uint256_hex, | ||||
) | ) | ||||
Show All 31 Lines | def run_test(self): | ||||
proof_expiration = 0 | proof_expiration = 0 | ||||
proof = node.buildavalancheproof( | proof = node.buildavalancheproof( | ||||
proof_sequence, proof_expiration, bytes_to_wif( | proof_sequence, proof_expiration, bytes_to_wif( | ||||
privkey.get_bytes()), | privkey.get_bytes()), | ||||
[stake]) | [stake]) | ||||
return (pubkey.get_bytes().hex(), proof) | return (pubkey.get_bytes().hex(), proof) | ||||
# Create peercount * nodecount node array | # Create peercount * nodecount node array | ||||
nodes = [[get_ava_p2p_interface(node) for _ in range( | nodes = [[get_ava_p2p_interface_no_handshake(node) for _ in range( | ||||
nodecount)] for _ in range(peercount)] | nodecount)] for _ in range(peercount)] | ||||
# Add peercount peers and bind all the nodes to each | # Add peercount peers and bind all the nodes to each | ||||
proofs = [] | proofs = [] | ||||
for i in range(peercount): | for i in range(peercount): | ||||
pubkey_hex, proof = getProof(stakes[i]) | pubkey_hex, proof = getProof(stakes[i]) | ||||
proofs.append(proof) | proofs.append(proof) | ||||
[node.addavalanchenode(n.nodeid, pubkey_hex, proof) | [node.addavalanchenode(n.nodeid, pubkey_hex, proof) | ||||
Show All 32 Lines |