コード例 #1
0
ファイル: test_bitcoin.py プロジェクト: itsN1X/node-launcher
 def test_set_rpcuser(bitcoin: Bitcoin):
     bitcoin.file['rpcuser'] = '******'
     changed = ConfigurationFile(bitcoin.file.path)
     assert changed['rpcuser'] == 'test_user'
     bitcoin.file['rpcuser'] = '******'
     changed_again = ConfigurationFile(bitcoin.file.path)
     assert changed_again['rpcuser'] == 'test_user_2'
コード例 #2
0
 def test_launch(self, bitcoin: Bitcoin):
     if IS_WINDOWS:
         command = ['set', 'path']
     else:
         command = ['echo', 'hello']
     bitcoin.bitcoin_qt = MagicMock(return_value=command)
     result = bitcoin.launch()
     assert result.pid
コード例 #3
0
 def test_set_prune(bitcoin: Bitcoin):
     bitcoin.set_prune(True)
     pruned = ConfigurationFile(bitcoin.file.path)
     assert pruned.prune
     assert not pruned.txindex
     bitcoin.set_prune(False)
     unpruned = ConfigurationFile(bitcoin.file.path)
     assert not unpruned.prune
     assert unpruned.txindex
コード例 #4
0
 def test_configuration_path_no_directory():
     with TemporaryDirectory() as tmpdirname:
         os.rmdir(tmpdirname)
         configuration_path = os.path.join(tmpdirname, 'bitcoin.conf')
         bitcoin = Bitcoin(network='testnet',
                           configuration_file_path=configuration_path)
         assert os.path.isfile(bitcoin.file.path)
コード例 #5
0
    def __init__(self):
        file_name = 'bitcoin.conf'
        bitcoin_data_path = BITCOIN_DATA_PATH[OPERATING_SYSTEM]
        self.bitcoin_configuration_file_path = os.path.join(
            bitcoin_data_path, file_name)
        log.info('bitcoin_configuration_file_path',
                 bitcoin_configuration_file_path=self.
                 bitcoin_configuration_file_path)
        self.bitcoin = Bitcoin(
            configuration_file_path=self.bitcoin_configuration_file_path)

        file_name = 'lnd.conf'
        lnd_dir_path = LND_DIR_PATH[OPERATING_SYSTEM]
        self.lnd_configuration_file_path = os.path.join(
            lnd_dir_path, file_name)
        log.info('lnd_configuration_file_path',
                 lnd_configuration_file_path=self.lnd_configuration_file_path)
        self.lnd = Lnd(
            configuration_file_path=self.lnd_configuration_file_path,
            bitcoin=self.bitcoin)
        self.lnd_client = LndClient(self.lnd)

        file_name = 'torrc'
        tor_dir_path = TOR_DIR_PATH[OPERATING_SYSTEM]
        self.tor_configuration_file_path = os.path.join(
            tor_dir_path, file_name)
        log.info('tor_configuration_file_path',
                 tor_configuration_file_path=self.tor_configuration_file_path)
        self.tor = Tor(
            configuration_file_path=self.tor_configuration_file_path,
            lnd=self.lnd)
コード例 #6
0
 def test_file_changed(self, bitcoin: Bitcoin):
     bitcoin.file['rpcport'] = 8338
     bitcoin.config_file_changed()
     new_config = bitcoin.file.snapshot
     bitcoin.running = False
     assert bitcoin.rpc_port == new_config['rpcport'] == new_config[
         'main.rpcport'] == 8338
     assert bitcoin.restart_required == False
     bitcoin.running = True
     assert bitcoin.restart_required == True
     bitcoin.file['port'] = 8336
     bitcoin.config_file_changed()
     new_config = bitcoin.file.snapshot
     bitcoin.running = False
     assert bitcoin.node_port == new_config['port'] == new_config[
         'main.port'] == 8336
     assert bitcoin.restart_required == False
     bitcoin.running = True
     assert bitcoin.restart_required == True
コード例 #7
0
ファイル: node_set.py プロジェクト: itsN1X/node-launcher
    def __init__(self, network: Network):
        self.network = network

        self.bitcoin = Bitcoin(
            network=self.network,
            configuration_file_path=self.bitcoin_configuration_file_path)
        self.lnd = Lnd(
            network=self.network,
            configuration_file_path=self.lnd_configuration_file_path,
            bitcoin=self.bitcoin)
        self.lnd_client = LndClient(self.lnd)
コード例 #8
0
    def __init__(self, network: str):
        self.network = network
        self.lnd_configuration_file_path = os.path.join(
            LND_DIR_PATH[OPERATING_SYSTEM], 'lnd.conf')

        self.bitcoin_configuration_file_path = os.path.join(
            BITCOIN_DATA_PATH[OPERATING_SYSTEM], 'bitcoin.conf')

        self.bitcoin = Bitcoin(
            network=self.network,
            configuration_file_path=self.bitcoin_configuration_file_path)
        self.lnd = Lnd(
            network=self.network,
            configuration_file_path=self.lnd_configuration_file_path,
            bitcoin=self.bitcoin)
        self.lnd_client = LndClient(self.lnd)
コード例 #9
0
 def test_detect_zmq_ports(self, bitcoin: Bitcoin):
     result = bitcoin.detect_zmq_ports()
     assert bitcoin.zmq_block_port < bitcoin.zmq_tx_port
     assert isinstance(result, bool)
コード例 #10
0
def bitcoin(network: str) -> Bitcoin:
    with NamedTemporaryFile(suffix='-bitcoin.conf', delete=False) as f:
        bitcoin = Bitcoin(network=network, configuration_file_path=f.name)
    return bitcoin