@@ -4511,14 +4511,14 @@ def test_fetchinvoice(node_factory, bitcoind):
4511
4511
assert l1 .rpc .call ('decode' , [inv1 ['invoice' ]])['invoice_amount_msat' ] == 3
4512
4512
l1 .rpc .pay (inv1 ['invoice' ])
4513
4513
4514
+ # We've done 4 onion calls: sleep now to avoid hitting ratelimit!
4515
+ time .sleep (1 )
4516
+
4514
4517
# More than ~5x expected is rejected as absurd (it's actually a divide test,
4515
4518
# which means we need 15 here, not 11).
4516
4519
with pytest .raises (RpcError , match = "Remote node sent failure message.*Amount vastly exceeds 2msat" ):
4517
4520
l1 .rpc .call ('fetchinvoice' , {'offer' : offer1 ['bolt12' ], 'amount_msat' : 15 })
4518
4521
4519
- # We've done 4 onion calls: sleep now to avoid hitting ratelimit!
4520
- time .sleep (1 )
4521
-
4522
4522
# Underpay is rejected.
4523
4523
with pytest .raises (RpcError , match = "Remote node sent failure message.*Amount must be at least 2msat" ):
4524
4524
l1 .rpc .call ('fetchinvoice' , {'offer' : offer1 ['bolt12' ], 'amount_msat' : 1 })
@@ -4537,15 +4537,15 @@ def test_fetchinvoice(node_factory, bitcoind):
4537
4537
'description' : 'single-use test' ,
4538
4538
'single_use' : True })['bolt12' ]
4539
4539
4540
+ # We've done 3 onion calls: sleep now to avoid hitting ratelimit!
4541
+ time .sleep (1 )
4542
+
4540
4543
inv1 = l1 .rpc .call ('fetchinvoice' , {'offer' : offer2 })
4541
4544
inv2 = l1 .rpc .call ('fetchinvoice' , {'offer' : offer2 })
4542
4545
assert inv1 != inv2
4543
4546
assert 'next_period' not in inv1
4544
4547
assert 'next_period' not in inv2
4545
4548
4546
- # We've done 4 onion calls: sleep now to avoid hitting ratelimit!
4547
- time .sleep (1 )
4548
-
4549
4549
l1 .rpc .pay (inv1 ['invoice' ])
4550
4550
4551
4551
# We can't pay the other one now.
@@ -4564,6 +4564,9 @@ def test_fetchinvoice(node_factory, bitcoind):
4564
4564
offerusd = l3 .rpc .call ('offer' , {'amount' : '10.05USD' ,
4565
4565
'description' : 'USD test' })['bolt12' ]
4566
4566
4567
+ # We've done 3 onion calls: sleep now to avoid hitting ratelimit!
4568
+ time .sleep (1 )
4569
+
4567
4570
inv = l1 .rpc .call ('fetchinvoice' , {'offer' : offerusd })
4568
4571
assert inv ['changes' ]['amount_msat' ] == Millisatoshi (int (10.05 * 5000 ))
4569
4572
@@ -4579,7 +4582,7 @@ def test_fetchinvoice(node_factory, bitcoind):
4579
4582
l4 .rpc .connect (l3 .info ['id' ], 'localhost' , l3 .port )
4580
4583
l4 .rpc .call ('fetchinvoice' , {'offer' : offer1 ['bolt12' ]})
4581
4584
4582
- # We've done 4 onion calls: sleep now to avoid hitting ratelimit!
4585
+ # We've done 3 onion calls: sleep now to avoid hitting ratelimit!
4583
4586
time .sleep (1 )
4584
4587
4585
4588
# If we remove plugin, it can no longer give us an invoice.
0 commit comments