@@ -578,7 +578,9 @@ def check_balances():
578
578
579
579
@unittest .skipIf (TEST_NETWORK != 'regtest' , "The reserve computation is bitcoin specific" )
580
580
def test_sendpay_cant_afford (node_factory ):
581
- l1 , l2 = node_factory .line_graph (2 , fundamount = 10 ** 6 )
581
+ # Set feerates the same so we don't have to wait for update.
582
+ l1 , l2 = node_factory .line_graph (2 , fundamount = 10 ** 6 ,
583
+ opts = {'feerates' : (15000 , 15000 , 15000 )})
582
584
583
585
# Can't pay more than channel capacity.
584
586
def pay (lsrc , ldst , amt , label = None ):
@@ -593,7 +595,7 @@ def pay(lsrc, ldst, amt, label=None):
593
595
pay (l1 , l2 , 10 ** 9 + 1 )
594
596
595
597
# This is the fee, which needs to be taken into account for l1.
596
- available = 10 ** 9 - 13440000
598
+ available = 10 ** 9 - 24030000
597
599
# Reserve is 1%.
598
600
reserve = 10 ** 7
599
601
@@ -2275,65 +2277,6 @@ def test_channel_spendable_capped(node_factory, bitcoind):
2275
2277
assert l1 .rpc .listpeers ()['peers' ][0 ]['channels' ][0 ]['spendable_msat' ] == Millisatoshi (0xFFFFFFFF )
2276
2278
2277
2279
2278
- @unittest .skipIf (TEST_NETWORK != 'regtest' , 'The numbers below are bitcoin specific' )
2279
- def test_channel_drainage (node_factory , bitcoind ):
2280
- """Test channel drainage.
2281
-
2282
- Test to drains a channels as much as possible,
2283
- especially in regards to commitment fee:
2284
-
2285
- [l1] <=> [l2]
2286
- """
2287
- sats = 10 ** 6
2288
- l1 , l2 = node_factory .line_graph (2 , fundamount = sats , wait_for_announce = True )
2289
-
2290
- # wait for everyone to see every channel as active
2291
- for n in [l1 , l2 ]:
2292
- wait_for (lambda : [c ['active' ] for c in n .rpc .listchannels ()['channels' ]] == [True ] * 2 * 1 )
2293
-
2294
- # This first HTLC drains the channel.
2295
- amount = Millisatoshi ("976559200msat" )
2296
- payment_hash = l2 .rpc .invoice ('any' , 'inv' , 'for testing' )['payment_hash' ]
2297
- route = l1 .rpc .getroute (l2 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2298
- l1 .rpc .sendpay (route , payment_hash )
2299
- l1 .rpc .waitsendpay (payment_hash , 10 )
2300
-
2301
- # wait until totally settled
2302
- l1 .wait_for_htlcs ()
2303
- l2 .wait_for_htlcs ()
2304
-
2305
- # But we can get more! By using a trimmed htlc output; this doesn't cause
2306
- # an increase in tx fee, so it's allowed.
2307
- amount = Millisatoshi ("2580800msat" )
2308
- payment_hash = l2 .rpc .invoice ('any' , 'inv2' , 'for testing' )['payment_hash' ]
2309
- route = l1 .rpc .getroute (l2 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2310
- l1 .rpc .sendpay (route , payment_hash )
2311
- l1 .rpc .waitsendpay (payment_hash , TIMEOUT )
2312
-
2313
- # wait until totally settled
2314
- l1 .wait_for_htlcs ()
2315
- l2 .wait_for_htlcs ()
2316
-
2317
- # Now, l1 is paying fees, but it can't afford a larger tx, so any
2318
- # attempt to add an HTLC which is not trimmed will fail.
2319
- payment_hash = l1 .rpc .invoice ('any' , 'inv' , 'for testing' )['payment_hash' ]
2320
-
2321
- # feerate_per_kw = 15000, so htlc_timeout_fee = 663 * 15000 / 1000 = 9945.
2322
- # dust_limit is 546. So it's trimmed if < 9945 + 546.
2323
- amount = Millisatoshi ("10491sat" )
2324
- route = l2 .rpc .getroute (l1 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2325
- l2 .rpc .sendpay (route , payment_hash )
2326
- with pytest .raises (RpcError , match = r"Capacity exceeded.*'erring_index': 0" ):
2327
- l2 .rpc .waitsendpay (payment_hash , TIMEOUT )
2328
-
2329
- # But if it's trimmed, we're ok.
2330
- amount -= 1
2331
- route = l2 .rpc .getroute (l1 .info ['id' ], amount , riskfactor = 1 , fuzzpercent = 0 )['route' ]
2332
- l2 .rpc .sendpay (route , payment_hash )
2333
- l2 .rpc .waitsendpay (payment_hash , TIMEOUT )
2334
-
2335
-
2336
- @pytest .mark .xfail (strict = True )
2337
2280
def test_lockup_drain (node_factory , bitcoind ):
2338
2281
"""Try to get channel into a state where funder can't afford fees on additional HTLC, so fundee can't add HTLC"""
2339
2282
l1 , l2 = node_factory .line_graph (2 , opts = {'may_reconnect' : True })
0 commit comments