MCPcopy Create free account
hub / github.com/ElementsProject/lightning / get_node

Method get_node

contrib/pyln-testing/pyln/testing/utils.py:1793–1854  ·  view source on GitHub ↗
(self, node_id=None, options=None, dbfile=None,
                 bkpr_dbfile=None, feerates=(15000, 11000, 7500, 3750),
                 start=True, wait_for_bitcoind_sync=True, may_fail=False,
                 expect_fail=False, cleandir=True, gossip_store_file=None, unused_grpc_port=True,
                 inline_plugin=None, **kwargs)

Source from the content-addressed store, hash-verified

1791 return [j.result() for j in jobs]
1792
1793 def get_node(self, node_id=None, options=None, dbfile=None,
1794 bkpr_dbfile=None, feerates=(15000, 11000, 7500, 3750),
1795 start=True, wait_for_bitcoind_sync=True, may_fail=False,
1796 expect_fail=False, cleandir=True, gossip_store_file=None, unused_grpc_port=True,
1797 inline_plugin=None, **kwargs):
1798 node_id = self.get_node_id() if not node_id else node_id
1799 port = reserve_unused_port()
1800 grpc_port = self.get_unused_port() if unused_grpc_port else None
1801
1802 lightning_dir = os.path.join(
1803 self.directory, "lightning-{}/".format(node_id))
1804
1805 if cleandir and os.path.exists(lightning_dir):
1806 shutil.rmtree(lightning_dir)
1807
1808 # Get the DB backend DSN we should be using for this test and this
1809 # node.
1810 db = self.db_provider.get_db(os.path.join(lightning_dir, TEST_NETWORK), self.testname, node_id)
1811 db.provider = self.db_provider
1812 node = self.node_cls(
1813 node_id, lightning_dir, self.bitcoind, self.executor, db=db,
1814 port=port, grpc_port=grpc_port, options=options, may_fail=may_fail or expect_fail,
1815 jsonschemas=self.jsonschemas,
1816 **kwargs
1817 )
1818
1819 # Regtest estimatefee are unusable, so override.
1820 if feerates is not None:
1821 node.set_feerates(feerates, False)
1822
1823 self.nodes.append(node)
1824 self.reserved_ports.append(port)
1825 if dbfile:
1826 with open(os.path.join(node.daemon.lightning_dir, TEST_NETWORK,
1827 'lightningd.sqlite3'), 'xb') as out:
1828 with lzma.open(os.path.join('tests/data', dbfile), 'rb') as f:
1829 out.write(f.read())
1830
1831 if bkpr_dbfile:
1832 with open(os.path.join(node.daemon.lightning_dir, TEST_NETWORK,
1833 'accounts.sqlite3'), 'xb') as out:
1834 with lzma.open(os.path.join('tests/data', bkpr_dbfile), 'rb') as f:
1835 out.write(f.read())
1836
1837 if gossip_store_file:
1838 shutil.copy(gossip_store_file, os.path.join(node.daemon.lightning_dir, TEST_NETWORK,
1839 'gossip_store'))
1840
1841 if inline_plugin is not None:
1842 if 'plugin' not in node.daemon.opts:
1843 node.daemon.opts['plugin'] = INLINE_PLUGIN_PATH
1844 _inline_plugin(node, inline_plugin)
1845
1846 if start:
1847 try:
1848 node.start(wait_for_bitcoind_sync)
1849 except Exception:
1850 if expect_fail:

Callers

nothing calls this directly

Calls 12

get_node_idMethod · 0.95
get_unused_portMethod · 0.95
reserve_unused_portFunction · 0.85
_inline_pluginFunction · 0.85
joinMethod · 0.80
set_feeratesMethod · 0.80
openMethod · 0.80
get_dbMethod · 0.45
writeMethod · 0.45
readMethod · 0.45
startMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected