Test that spendable_msat is accurate for large channels
(node_factory, bitcoind)
| 2765 | |
| 2766 | |
| 2767 | def 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 | |
| 2803 | def test_channel_spendable_receivable_capped(node_factory, bitcoind): |
nothing calls this directly
no test coverage detected