@@ -1047,3 +1047,57 @@ def test_forward_stats(node_factory, bitcoind):
10471047 assert l2 .rpc .getinfo ()['msatoshi_fees_collected' ] == 1 + amount // 100000
10481048 assert l1 .rpc .getinfo ()['msatoshi_fees_collected' ] == 0
10491049 assert l3 .rpc .getinfo ()['msatoshi_fees_collected' ] == 0
1050+
1051+
1052+ @pytest .mark .xfail (strict = True )
1053+ @unittest .skipIf (not DEVELOPER , "needs DEVELOPER=1 for dev_ignore_htlcs" )
1054+ def test_htlcs_cltv_only_difference (node_factory , bitcoind ):
1055+ # l1 -> l2 -> l3 -> l4
1056+ # l4 ignores htlcs, so they stay.
1057+ # l3 will see a reconnect from l4 when l4 restarts.
1058+ l1 , l2 , l3 , l4 = node_factory .line_graph (4 , announce = True , opts = [{}] * 2 + [{'dev-no-reconnect' : None , 'may_reconnect' : True }] * 2 )
1059+
1060+ h = l4 .rpc .invoice (msatoshi = 10 ** 8 , label = 'x' , description = 'desc' )['payment_hash' ]
1061+ l4 .rpc .dev_ignore_htlcs (id = l3 .info ['id' ], ignore = True )
1062+
1063+ # L2 tries to pay
1064+ r = l2 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1065+ l2 .rpc .sendpay (r , h )
1066+
1067+ # Now increment CLTV
1068+ bitcoind .generate_block (1 )
1069+ sync_blockheight (bitcoind , [l1 , l2 , l3 , l4 ])
1070+
1071+ # L1 tries to pay
1072+ r = l1 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1073+ l1 .rpc .sendpay (r , h )
1074+
1075+ # Now increment CLTV
1076+ bitcoind .generate_block (1 )
1077+ sync_blockheight (bitcoind , [l1 , l2 , l3 , l4 ])
1078+
1079+ # L3 tries to pay
1080+ r = l3 .rpc .getroute (l4 .info ['id' ], 10 ** 8 , 1 )["route" ]
1081+ l3 .rpc .sendpay (r , h )
1082+
1083+ # Give them time to go through.
1084+ time .sleep (5 )
1085+
1086+ # Will all be connected OK.
1087+ assert only_one (l1 .rpc .listpeers (l2 .info ['id' ])['peers' ])['connected' ]
1088+ assert only_one (l2 .rpc .listpeers (l3 .info ['id' ])['peers' ])['connected' ]
1089+ assert only_one (l3 .rpc .listpeers (l4 .info ['id' ])['peers' ])['connected' ]
1090+
1091+ # Restarting tail node will stop it ignoring HTLCs (it will actually
1092+ # fail them immediately).
1093+ l4 .restart ()
1094+ l3 .rpc .connect (l4 .info ['id' ], 'localhost' , l4 .port )
1095+
1096+ wait_for (lambda : only_one (l1 .rpc .listpayments ()['payments' ])['status' ] == 'failed' )
1097+ wait_for (lambda : only_one (l2 .rpc .listpayments ()['payments' ])['status' ] == 'failed' )
1098+ wait_for (lambda : only_one (l3 .rpc .listpayments ()['payments' ])['status' ] == 'failed' )
1099+
1100+ # Should all still be connected.
1101+ assert only_one (l1 .rpc .listpeers (l2 .info ['id' ])['peers' ])['connected' ]
1102+ assert only_one (l2 .rpc .listpeers (l3 .info ['id' ])['peers' ])['connected' ]
1103+ assert only_one (l3 .rpc .listpeers (l4 .info ['id' ])['peers' ])['connected' ]
0 commit comments