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

Function test_channel_spendable_large

tests/test_pay.py:2767–2800  ·  view source on GitHub ↗

Test that spendable_msat is accurate for large channels

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

2765
2766
2767def test_channel_spendable_large(node_factory, bitcoind):
2768 """Test that spendable_msat is accurate for large channels"""
2769 # This is almost the max allowable spend.
2770 sats = 4294967
2771 l1, l2 = node_factory.line_graph(
2772 2,
2773 fundamount=sats,
2774 wait_for_announce=True,
2775 opts={
2776 'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_invoice.py'),
2777 }
2778 )
2779
2780 inv = l2.rpc.invoice('any', 'inv', 'for testing')
2781 payment_hash = inv['payment_hash']
2782
2783 # We should be able to spend this much, and not one msat more!
2784 spendable = l1.rpc.listpeerchannels()['channels'][0]['spendable_msat']
2785
2786 # receivable from the other side should calculate to the exact same amount
2787 receivable = l2.rpc.listpeerchannels()['channels'][0]['receivable_msat']
2788 assert spendable == receivable
2789
2790 # route or waitsendpay fill fail.
2791 with pytest.raises(RpcError):
2792 route = l1.single_route(l2.info['id'], spendable + 1)
2793 l1.rpc.sendpay(route, payment_hash, payment_secret=inv['payment_secret'])
2794 l1.rpc.waitsendpay(payment_hash, TIMEOUT)
2795
2796 # Exact amount should succeed.
2797 route = l1.single_route(l2.info['id'], spendable)
2798 l1.rpc.sendpay(route, payment_hash, payment_secret=inv['payment_secret'])
2799 open(os.path.join(l2.daemon.lightning_dir, TEST_NETWORK, "unhold"), "w").close()
2800 l1.rpc.waitsendpay(payment_hash, TIMEOUT)
2801
2802
2803def test_channel_spendable_receivable_capped(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 8

line_graphMethod · 0.80
joinMethod · 0.80
listpeerchannelsMethod · 0.80
single_routeMethod · 0.80
sendpayMethod · 0.80
waitsendpayMethod · 0.80
invoiceMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected