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 test_framework.avatools import ( | from test_framework.avatools import ( | ||||
get_ava_p2p_interface, | get_ava_p2p_interface, | ||||
create_coinbase_stakes, | create_coinbase_stakes, | ||||
) | ) | ||||
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 assert_equal | from test_framework.util import assert_equal | ||||
from test_framework.wallet_util import bytes_to_wif | |||||
class GetAvalanchePeerInfoTest(BitcoinTestFramework): | class GetAvalanchePeerInfoTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.extra_args = [['-enableavalanche=1', '-avacooldown=0']] | self.extra_args = [['-enableavalanche=1', '-avacooldown=0']] | ||||
Show All 13 Lines | def run_test(self): | ||||
def getProof(stake): | def getProof(stake): | ||||
privkey = ECKey() | privkey = ECKey() | ||||
privkey.generate() | privkey.generate() | ||||
pubkey = privkey.get_pubkey() | 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()), | |||||
[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 n in range( | nodes = [[get_ava_p2p_interface(node) for n in range( | ||||
nodecount)] for p in range(peercount)] | nodecount)] for p in range(peercount)] | ||||
# Add peercount peers and bind all the nodes to each | # Add peercount peers and bind all the nodes to each | ||||
Show All 20 Lines |