Test that we can send a payment even if not caught up with the chain. We removed the requirement for the node to be fully synced up with the blockchain in v24.05, allowing us to send a payment while still processing blocks. This test pins the sender at a lower height, but `getnetwor
(node_factory, bitcoind)
| 4962 | |
| 4963 | |
| 4964 | def test_pay_blockheight_mismatch(node_factory, bitcoind): |
| 4965 | """Test that we can send a payment even if not caught up with the chain. |
| 4966 | |
| 4967 | We removed the requirement for the node to be fully synced up with |
| 4968 | the blockchain in v24.05, allowing us to send a payment while still |
| 4969 | processing blocks. This test pins the sender at a lower height, |
| 4970 | but `getnetworkinfo` still reports the correct height. Since CLTV |
| 4971 | computations are based on headers and not our own sync height, the |
| 4972 | recipient should still be happy with the parameters we chose. |
| 4973 | |
| 4974 | """ |
| 4975 | |
| 4976 | send, direct, recv = node_factory.line_graph(3, |
| 4977 | wait_for_announce=True, |
| 4978 | opts={'may_reconnect': True}) |
| 4979 | sync_blockheight(bitcoind, [send, recv]) |
| 4980 | |
| 4981 | height = bitcoind.rpc.getblockchaininfo()['blocks'] |
| 4982 | |
| 4983 | # Pin `send` at the current height. by not returning the next |
| 4984 | # blockhash. This error is special-cased not to count as the |
| 4985 | # backend failing since it is used to poll for the next block. |
| 4986 | def mock_getblockhash(req): |
| 4987 | # Allow old blocks, for restart. |
| 4988 | if int(req['params'][0]) <= height: |
| 4989 | return None |
| 4990 | return { |
| 4991 | "id": req['id'], |
| 4992 | "error": { |
| 4993 | "code": -8, |
| 4994 | "message": "Block height out of range" |
| 4995 | } |
| 4996 | } |
| 4997 | |
| 4998 | send.daemon.rpcproxy.mock_rpc('getblockhash', mock_getblockhash) |
| 4999 | bitcoind.generate_block(100) |
| 5000 | |
| 5001 | sync_blockheight(bitcoind, [recv]) |
| 5002 | # For xpay, it doesn't poll the blockheight, only handles case where |
| 5003 | # it's behind at the start. |
| 5004 | send.restart() |
| 5005 | send.rpc.connect(direct.info['id'], 'localhost', direct.port) |
| 5006 | |
| 5007 | inv = recv.rpc.invoice(42, 'lbl', 'desc')['bolt11'] |
| 5008 | send.rpc.pay(inv) |
| 5009 | |
| 5010 | # The direct_override payment modifier does some trickery on the |
| 5011 | # route calculation, so we better ensure direct payments still |
| 5012 | # work correctly. |
| 5013 | inv = direct.rpc.invoice(13, 'lbl', 'desc')['bolt11'] |
| 5014 | send.rpc.pay(inv) |
| 5015 | |
| 5016 | |
| 5017 | def test_pay_waitblockheight_timeout(node_factory, bitcoind): |
nothing calls this directly
no test coverage detected