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 __init__(self): file_name = 'litecoin.conf' litecoin_data_path = LITECOIN_DATA_PATH[OPERATING_SYSTEM] self.litecoin_configuration_file_path = os.path.join(litecoin_data_path, file_name) log.info( 'litecoin_configuration_file_path', litecoin_configuration_file_path=self.litecoin_configuration_file_path ) self.litecoin = Litecoin( configuration_file_path=self.litecoin_configuration_file_path ) file_name = 'lnd-ltc.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, litecoin=self.litecoin ) self.lnd_client = LndClient(self.lnd)
def test_launch_terminal(self, lnd: Lnd): if IS_WINDOWS: command = ['set', 'path'] else: command = ['echo', 'hello'] lnd.lnd = MagicMock(return_value=command) result = lnd.launch() assert result
class NodeSet(object): lnd_client: LndClient bitcoin: Bitcoin lnd: Lnd tor: Tor 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) @property def is_testnet(self) -> bool: return self.bitcoin.file['testnet'] @property def is_mainnet(self) -> bool: return not self.bitcoin.file['testnet'] def reset_tls(self): was_running = self.lnd.running if was_running: self.lnd.stop() os.remove(self.lnd_client.tls_cert_path) os.remove(self.lnd_client.tls_key_path) if was_running: self.lnd.launch() self.lnd_client.reset()
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)
class NodeSet(object): lnd_client: LndClient bitcoin: Bitcoin lnd: Lnd network: Network 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) @property def is_testnet(self) -> bool: return self.network == TESTNET @property def is_mainnet(self) -> bool: return self.network == MAINNET @property def lnd_configuration_file_path(self) -> str: file_name = 'lnd.conf' if self.is_testnet: file_name = 'lnd-testnet.conf' lnd_dir_path = LND_DIR_PATH[OPERATING_SYSTEM] return os.path.join(lnd_dir_path, file_name) @property def bitcoin_configuration_file_path(self) -> str: file_name = 'bitcoin.conf' if self.is_testnet: file_name = 'bitcoin-testnet.conf' bitcoin_data_path = BITCOIN_DATA_PATH[OPERATING_SYSTEM] return os.path.join(bitcoin_data_path, file_name) def reset_tls(self): was_running = self.lnd.running if was_running: self.lnd.stop() os.remove(self.lnd_client.tls_cert_path) os.remove(self.lnd_client.tls_key_path) if was_running: self.lnd.launch() self.lnd_client.reset()
class NodeSet(object): lnd_client: LndClient litecoin: Litecoin lnd: Lnd def __init__(self): file_name = 'litecoin.conf' litecoin_data_path = LITECOIN_DATA_PATH[OPERATING_SYSTEM] self.litecoin_configuration_file_path = os.path.join(litecoin_data_path, file_name) log.info( 'litecoin_configuration_file_path', litecoin_configuration_file_path=self.litecoin_configuration_file_path ) self.litecoin = Litecoin( configuration_file_path=self.litecoin_configuration_file_path ) file_name = 'lnd-ltc.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, litecoin=self.litecoin ) self.lnd_client = LndClient(self.lnd) @property def is_testnet(self) -> bool: return self.litecoin.file['testnet'] @property def is_mainnet(self) -> bool: return not self.litecoin.file['testnet'] def reset_tls(self): was_running = self.lnd.running if was_running: self.lnd.stop() os.remove(self.lnd_client.tls_cert_path) os.remove(self.lnd_client.tls_key_path) if was_running: self.lnd.launch() self.lnd_client.reset()
def test_file_changed(self, lnd: Lnd): lnd.file['listen'] = '127.0.0.1:9739' lnd.config_file_changed() lnd.running = False new_config = lnd.file.snapshot assert lnd.node_port == new_config['listen'].split(':')[-1] == '9739' assert lnd.restart_required == False lnd.running = True lnd.file['listen'] = '127.0.0.1:9741' lnd.config_file_changed() new_config = lnd.file.snapshot assert lnd.node_port == new_config['listen'].split(':')[-1] == '9741'
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_bitcoin_file_changed(self, lnd: Lnd): lnd.bitcoin.file['rpcport'] = 8338 lnd.bitcoin.running = False lnd.bitcoin.config_file_changed() lnd.bitcoin_config_file_changed() new_config = lnd.file.snapshot lnd.running = False assert lnd.file['bitcoind.rpchost'] == new_config[ 'bitcoind.rpchost'] == '127.0.0.1:8338' assert lnd.restart_required == False lnd.bitcoin.running = True lnd.bitcoin.config_snapshot = lnd.bitcoin.file.snapshot assert lnd.bitcoin.config_snapshot['rpcport'] == 8338 lnd.bitcoin.file['rpcport'] = 8340 lnd.bitcoin.config_file_changed() lnd.bitcoin_config_file_changed() new_config = lnd.file.snapshot assert lnd.file['bitcoind.rpchost'] == new_config[ 'bitcoind.rpchost'] == '127.0.0.1:8340' assert lnd.restart_required == False lnd.running = True assert lnd.bitcoin.restart_required == True assert lnd.restart_required == True
def test_multi_listen(self, lnd: Lnd): lnd.file['listen'] = [ '127.0.0.1:9835', '192.168.1.1:9736', ] assert lnd.node_port == '9835'
def test_multi_property(self, lnd: Lnd): lnd.file['multi_property'] = ['test1', 'test2'] assert len(lnd.file['multi_property']) == 2
def lnd(network: str, litecoin: Litecoin) -> Lnd: with NamedTemporaryFile(suffix='-lnd-ltc.conf', delete=False) as f: lnd = Lnd(configuration_file_path=f.name, litecoin=litecoin) return lnd
def lnd(network: str, bitcoin: Bitcoin) -> Lnd: with NamedTemporaryFile(suffix='-lnd.conf', delete=False) as f: lnd = Lnd(network=network, configuration_file_path=f.name, bitcoin=bitcoin) return lnd