def get_node(self, legacy=True): node_id = self.next_id self.next_id += 1 lightning_dir = os.path.join(TEST_DIR, self.func._testMethodName, "lightning-{}/".format(node_id)) socket_path = os.path.join(lightning_dir, "lightning-rpc").format(node_id) port = 16330 + node_id if legacy: daemon = utils.LegacyLightningD(lightning_dir, bitcoind.bitcoin_dir, port=port) rpc = LegacyLightningRpc(socket_path, self.executor) else: daemon = utils.LightningD(lightning_dir, bitcoind.bitcoin_dir, port=port) rpc = LightningRpc(socket_path, self.executor) node = utils.LightningNode(daemon, rpc, bitcoind, self.executor) self.nodes.append(node) if VALGRIND: node.daemon.cmd_line = [ 'valgrind', '-q', '--error-exitcode=7', '--log-file={}/valgrind-errors'.format( node.daemon.lightning_dir) ] + node.daemon.cmd_line node.daemon.start() # Cache `getinfo`, we'll be using it a lot node.info = node.rpc.getinfo() return node
def get_node(self, disconnect=None): node_id = self.next_id self.next_id += 1 lightning_dir = os.path.join(TEST_DIR, self.func._testMethodName, "lightning-{}/".format(node_id)) socket_path = os.path.join(lightning_dir, "lightning-rpc").format(node_id) port = 16330 + node_id daemon = utils.LightningD(lightning_dir, bitcoind.bitcoin_dir, port=port) # If we have a disconnect string, dump it to a file for daemon. if disconnect: with open(os.path.join(lightning_dir, "dev_disconnect"), "w") as f: f.write("\n".join(disconnect)) daemon.cmd_line.append("--dev-disconnect=dev_disconnect") rpc = LightningRpc(socket_path, self.executor) node = utils.LightningNode(daemon, rpc, bitcoind, self.executor) self.nodes.append(node) if VALGRIND: node.daemon.cmd_line = [ 'valgrind', '-q', '--trace-children=yes', '--trace-children-skip=*bitcoin-cli*', '--error-exitcode=7', '--log-file={}/valgrind-errors.%p'.format( node.daemon.lightning_dir) ] + node.daemon.cmd_line node.daemon.start() # Cache `getinfo`, we'll be using it a lot node.info = node.rpc.getinfo() return node
def get_node(self, legacy=True): node_id = self.next_id self.next_id += 1 lightning_dir = os.path.join(TEST_DIR, self.func._testMethodName, "lightning-{}/".format(node_id)) socket_path = os.path.join(lightning_dir, "lightning-rpc").format(node_id) port = 16330 + node_id if legacy: daemon = utils.LegacyLightningD(lightning_dir, bitcoind.bitcoin_dir, port=port) rpc = LegacyLightningRpc(socket_path, self.executor) else: daemon = utils.LightningD(lightning_dir, bitcoind.bitcoin_dir, port=port) # TODO(cdecker) Move into LIGHTNINGD_CONFIG once legacy daemon was removed daemon.cmd_line.append("--dev-broadcast-interval=1000") rpc = LightningRpc(socket_path, self.executor) node = utils.LightningNode(daemon, rpc, bitcoind, self.executor) self.nodes.append(node) if VALGRIND: node.daemon.cmd_line = [ 'valgrind', '-q', '--trace-children=yes', '--trace-children-skip=*bitcoin-cli*', '--error-exitcode=7', '--log-file={}/valgrind-errors'.format( node.daemon.lightning_dir) ] + node.daemon.cmd_line node.daemon.start() # Cache `getinfo`, we'll be using it a lot node.info = node.rpc.getinfo() return node