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'
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
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
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)
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)
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
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)
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)
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)
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