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

Function test_pay_multichannel_use_zeroconf

tests/test_pay.py:5508–5537  ·  view source on GitHub ↗

Check that we use the zeroconf direct channel to pay when we need to

(bitcoind, node_factory)

Source from the content-addressed store, hash-verified

5506
5507
5508def test_pay_multichannel_use_zeroconf(bitcoind, node_factory):
5509 """Check that we use the zeroconf direct channel to pay when we need to"""
5510 # 0. Setup normal channel, 200k sats.
5511 zeroconf_plugin = Path(__file__).parent / "plugins" / "zeroconf-selective.py"
5512 l1, l2 = node_factory.line_graph(2, wait_for_announce=False,
5513 fundamount=200_000,
5514 opts=[{},
5515 {'plugin': zeroconf_plugin,
5516 'zeroconf_allow': 'any'}])
5517
5518 # 1. Open a zeoconf channel l1 -> l2
5519 zeroconf_sats = 1_000_000
5520
5521 # 1.1 Add funds to l1's wallet for the channel open
5522 l1.fundwallet(zeroconf_sats * 2) # This will mine a block!
5523 sync_blockheight(bitcoind, [l1, l2])
5524
5525 # 1.2 Open the zeroconf channel
5526 l1.rpc.fundchannel(l2.info['id'], zeroconf_sats, announce=False, mindepth=0)
5527
5528 # 1.3 Wait until all channels active.
5529 wait_for(lambda: all([c['state'] == 'CHANNELD_NORMAL' for c in l1.rpc.listpeerchannels()['channels'] + l2.rpc.listpeerchannels()['channels']]))
5530
5531 # 2. Have l2 generate an invoice to be paid
5532 invoice_sats = "500000sat"
5533 inv = l2.rpc.invoice(invoice_sats, "test", "test")
5534
5535 # 3. Send a payment over the zeroconf channel
5536 riskfactor = 0
5537 l1.rpc.pay(inv['bolt11'], riskfactor=riskfactor)
5538
5539
5540def test_delpay_works(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 8

sync_blockheightFunction · 0.90
wait_forFunction · 0.90
line_graphMethod · 0.80
fundwalletMethod · 0.80
listpeerchannelsMethod · 0.80
fundchannelMethod · 0.45
invoiceMethod · 0.45
payMethod · 0.45

Tested by

no test coverage detected