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

Method get_node

contrib/pyln-testing/pyln/testing/utils.py:1454–1504  ·  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, **kwargs)

Source from the content-addressed store, hash-verified

1452 return [j.result() for j in jobs]
1453
1454 def get_node(self, node_id=None, options=None, dbfile=None,
1455 bkpr_dbfile=None, feerates=(15000, 11000, 7500, 3750),
1456 start=True, wait_for_bitcoind_sync=True, may_fail=False,
1457 expect_fail=False, cleandir=True, **kwargs):
1458 self.throttler.wait()
1459 node_id = self.get_node_id() if not node_id else node_id
1460 port = reserve_unused_port()
1461
1462 lightning_dir = os.path.join(
1463 self.directory, "lightning-{}/".format(node_id))
1464
1465 if cleandir and os.path.exists(lightning_dir):
1466 shutil.rmtree(lightning_dir)
1467
1468 # Get the DB backend DSN we should be using for this test and this
1469 # node.
1470 db = self.db_provider.get_db(os.path.join(lightning_dir, TEST_NETWORK), self.testname, node_id)
1471 db.provider = self.db_provider
1472 node = self.node_cls(
1473 node_id, lightning_dir, self.bitcoind, self.executor, self.valgrind, db=db,
1474 port=port, options=options, may_fail=may_fail or expect_fail,
1475 jsonschemas=self.jsonschemas,
1476 **kwargs
1477 )
1478
1479 # Regtest estimatefee are unusable, so override.
1480 node.set_feerates(feerates, False)
1481
1482 self.nodes.append(node)
1483 self.reserved_ports.append(port)
1484 if dbfile:
1485 out = open(os.path.join(node.daemon.lightning_dir, TEST_NETWORK,
1486 'lightningd.sqlite3'), 'xb')
1487 with lzma.open(os.path.join('tests/data', dbfile), 'rb') as f:
1488 out.write(f.read())
1489
1490 if bkpr_dbfile:
1491 out = open(os.path.join(node.daemon.lightning_dir, TEST_NETWORK,
1492 'accounts.sqlite3'), 'xb')
1493 with lzma.open(os.path.join('tests/data', bkpr_dbfile), 'rb') as f:
1494 out.write(f.read())
1495
1496 if start:
1497 try:
1498 node.start(wait_for_bitcoind_sync)
1499 except Exception:
1500 if expect_fail:
1501 return node
1502 node.daemon.stop()
1503 raise
1504 return node
1505
1506 def join_nodes(self, nodes, fundchannel=True, fundamount=FUNDAMOUNT, wait_for_announce=False, announce_channels=True) -> None:
1507 """Given nodes, connect them in a line, optionally funding a channel, wait_for_announce waits for channel and node announcements"""

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected