@@ -6750,6 +6750,50 @@ def test_injectpaymentonion_failures(node_factory, executor):
67506750 assert 'onionreply' in err .value .error ['data' ]
67516751
67526752
6753+ @pytest .mark .xfail (strict = True )
6754+ def test_injectpaymentonion_peerfail (node_factory , executor ):
6755+ l1 , l2 = node_factory .line_graph (2 ,
6756+ opts = [{'may_reconnect' : True ,
6757+ 'dev-no-reconnect' : None ,
6758+ 'disconnect' : ['=WIRE_UPDATE_ADD_HTLC' , '-WIRE_COMMITMENT_SIGNED' ]},
6759+ {'may_reconnect' : True ,
6760+ 'dev-no-reconnect' : None }])
6761+ blockheight = l1 .rpc .getinfo ()['blockheight' ]
6762+
6763+ inv1 = l2 .rpc .invoice (1000 , "test_injectpaymentonion_peerfail" , "test_injectpaymentonion_peerfail" )
6764+
6765+ # First hop for injectpaymentonion is self.
6766+ hops = [{'pubkey' : l1 .info ['id' ],
6767+ 'payload' : serialize_payload_tlv (1000 , 18 + 6 , first_scid (l1 , l2 ), blockheight ).hex ()},
6768+ {'pubkey' : l2 .info ['id' ],
6769+ 'payload' : serialize_payload_final_tlv (1000 , 18 , 1000 , blockheight , inv1 ['payment_secret' ]).hex ()}]
6770+ onion = l1 .rpc .createonion (hops = hops , assocdata = inv1 ['payment_hash' ])
6771+
6772+ l1 .rpc .disconnect (l2 .info ['id' ], force = True )
6773+ with pytest .raises (RpcError , match = 'WIRE_TEMPORARY_CHANNEL_FAILURE' ):
6774+ l1 .rpc .injectpaymentonion (onion = onion ['onion' ],
6775+ payment_hash = inv1 ['payment_hash' ],
6776+ amount_msat = 1000 ,
6777+ cltv_expiry = blockheight + 18 + 6 ,
6778+ partid = 1 ,
6779+ groupid = 0 )
6780+ # In fact, it won't create any sendpays entry, since it fails too early.
6781+ assert l1 .rpc .listsendpays () == {'payments' : []}
6782+
6783+ # This will hang, since we disconnect once committed. But provides another
6784+ # (legitimately) pending payment for our migration code to test.
6785+ l1 .rpc .connect (l2 .info ['id' ], 'localhost' , l2 .port )
6786+ executor .submit (l1 .rpc .injectpaymentonion ,
6787+ onion = onion ['onion' ],
6788+ payment_hash = inv1 ['payment_hash' ],
6789+ amount_msat = 1000 ,
6790+ cltv_expiry = blockheight + 18 + 6 ,
6791+ partid = 2 ,
6792+ groupid = 0 )
6793+ l1 .daemon .wait_for_log ("dev_disconnect: =WIRE_UPDATE_ADD_HTLC" )
6794+ assert [p ['status' ] for p in l1 .rpc .listsendpays ()['payments' ]] == ['pending' ]
6795+
6796+
67536797def test_parallel_channels_reserve (node_factory , bitcoind ):
67546798 """Tests wether we are able to pay through parallel channels concurrently.
67556799 To do that we need to enable strict-forwarding."""
0 commit comments