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

Function start_channels

tests/test_renepay.py:309–356  ·  view source on GitHub ↗
(connections)

Source from the content-addressed store, hash-verified

307
308
309def start_channels(connections):
310 nodes = list()
311 for src, dst, fundamount in connections:
312 nodes.append(src)
313 nodes.append(dst)
314 src.rpc.connect(dst.info["id"], "localhost", dst.port)
315
316 bitcoind = nodes[0].bitcoin
317 # If we got here, we want to fund channels
318 for src, dst, fundamount in connections:
319 addr = src.rpc.newaddr('bech32')["bech32"]
320 bitcoind.rpc.sendtoaddress(addr, (fundamount + 1000000) / 10**8)
321
322 bitcoind.generate_block(1)
323 sync_blockheight(bitcoind, nodes)
324 txids = []
325 channel_ids = []
326 for src, dst, fundamount in connections:
327 fc = src.rpc.fundchannel(dst.info["id"], fundamount, announce=True)
328 txids.append(fc["txid"])
329 channel_ids.append(fc['channel_id'])
330
331 # Confirm all channels
332 bitcoind.generate_block(1, wait_for_mempool=txids)
333 scids = []
334 for conn, channel_id in zip(connections, channel_ids):
335 src = conn[0]
336 wait_for(lambda: ['short_channel_id' in c for c in src.rpc.listpeerchannels()['channels'] if c['channel_id'] == channel_id] == [True])
337 scid = only_one([c['short_channel_id'] for c in src.rpc.listpeerchannels()['channels'] if c['channel_id'] == channel_id])
338 scids.append(scid)
339
340 # Make sure they have all seen block so they don't complain about
341 # the coming gossip messages
342 sync_blockheight(bitcoind, nodes)
343
344 bitcoind.generate_block(5)
345
346 # Make sure everyone sees all channels, all other nodes
347 for n in nodes:
348 for scid in scids:
349 n.wait_channel_active(scid)
350
351 # Make sure we have all node announcements, too
352 for n in nodes:
353 for n2 in nodes:
354 wait_for(
355 lambda: "alias" in only_one(n.rpc.listnodes(n2.info["id"])["nodes"])
356 )
357
358
359def test_hardmpp(node_factory):

Callers 5

test_hardmppFunction · 0.85
test_fee_allocationFunction · 0.85
test_htlc_maxFunction · 0.85
test_htlcmax0Function · 0.85
test_hardmpp2Function · 0.85

Calls 10

sync_blockheightFunction · 0.90
wait_forFunction · 0.90
only_oneFunction · 0.90
generate_blockMethod · 0.80
listpeerchannelsMethod · 0.80
wait_channel_activeMethod · 0.80
connectMethod · 0.45
newaddrMethod · 0.45
fundchannelMethod · 0.45
listnodesMethod · 0.45

Tested by

no test coverage detected