@@ -24,7 +24,7 @@ def test_pay_fakenet(node_factory):
2424 hash2 = sha256 (bytes .fromhex ('01' + '00' * 31 )).hexdigest ()
2525 failhash = '00' * 32
2626
27- # Create gossip map of channels from l2 (aka nodemap[0])
27+ # Create gossip map of channels from l2 (aka nodemap[0])
2828 gsfile , nodemap = generate_gossip_store ([GenChannel (0 , 1 , capacity_sats = 100_000 ),
2929 GenChannel (1 , 2 , capacity_sats = 100_000 ),
3030 GenChannel (2 , 3 , capacity_sats = 200_000 )],
@@ -1018,3 +1018,37 @@ def test_xpay_bip353(node_factory):
10181018
10191019 node_factory .join_nodes ([l2 , l1 ])
10201020 l2 .rpc .xpay ('fake@fake.com' , 100 )
1021+
1022+
1023+ def test_blockheight_mismatch (node_factory , bitcoind ):
1024+ """Test that we can send a payment even if not caught up with the chain.
1025+
1026+ Since CLTV computations are based on headers and not our own sync height, the
1027+ recipient should still be happy with the parameters we chose.
1028+
1029+ Stolen from pay
1030+ """
1031+
1032+ send , direct , recv = node_factory .line_graph (3 , wait_for_announce = True )
1033+ sync_blockheight (bitcoind , [send , recv ])
1034+
1035+ # Pin `send` at the current height. by not returning the next
1036+ # block. This error is special-cased not to count as the
1037+ # backend failing since it is used to poll for the next block.
1038+ def mock_getblock (req ):
1039+ return {
1040+ "id" : req ["id" ],
1041+ "error" : {"code" : - 8 , "message" : "Block height out of range" },
1042+ }
1043+
1044+ send .daemon .rpcproxy .mock_rpc ("getblock" , mock_getblock )
1045+ bitcoind .generate_block (100 )
1046+
1047+ sync_blockheight (bitcoind , [recv ])
1048+
1049+ inv = recv .rpc .invoice (42 , "lbl" , "desc" )["bolt11" ]
1050+ send .rpc .xpay (inv )
1051+
1052+ # Test a direct payment as well.
1053+ inv = direct .rpc .invoice (13 , "lbl" , "desc" )["bolt11" ]
1054+ send .rpc .xpay (inv )
0 commit comments