@@ -4511,14 +4511,14 @@ def test_fetchinvoice(node_factory, bitcoind):
45114511 assert l1 .rpc .call ('decode' , [inv1 ['invoice' ]])['invoice_amount_msat' ] == 3
45124512 l1 .rpc .pay (inv1 ['invoice' ])
45134513
4514+ # We've done 4 onion calls: sleep now to avoid hitting ratelimit!
4515+ time .sleep (1 )
4516+
45144517 # More than ~5x expected is rejected as absurd (it's actually a divide test,
45154518 # which means we need 15 here, not 11).
45164519 with pytest .raises (RpcError , match = "Remote node sent failure message.*Amount vastly exceeds 2msat" ):
45174520 l1 .rpc .call ('fetchinvoice' , {'offer' : offer1 ['bolt12' ], 'amount_msat' : 15 })
45184521
4519- # We've done 4 onion calls: sleep now to avoid hitting ratelimit!
4520- time .sleep (1 )
4521-
45224522 # Underpay is rejected.
45234523 with pytest .raises (RpcError , match = "Remote node sent failure message.*Amount must be at least 2msat" ):
45244524 l1 .rpc .call ('fetchinvoice' , {'offer' : offer1 ['bolt12' ], 'amount_msat' : 1 })
@@ -4537,15 +4537,15 @@ def test_fetchinvoice(node_factory, bitcoind):
45374537 'description' : 'single-use test' ,
45384538 'single_use' : True })['bolt12' ]
45394539
4540+ # We've done 3 onion calls: sleep now to avoid hitting ratelimit!
4541+ time .sleep (1 )
4542+
45404543 inv1 = l1 .rpc .call ('fetchinvoice' , {'offer' : offer2 })
45414544 inv2 = l1 .rpc .call ('fetchinvoice' , {'offer' : offer2 })
45424545 assert inv1 != inv2
45434546 assert 'next_period' not in inv1
45444547 assert 'next_period' not in inv2
45454548
4546- # We've done 4 onion calls: sleep now to avoid hitting ratelimit!
4547- time .sleep (1 )
4548-
45494549 l1 .rpc .pay (inv1 ['invoice' ])
45504550
45514551 # We can't pay the other one now.
@@ -4564,6 +4564,9 @@ def test_fetchinvoice(node_factory, bitcoind):
45644564 offerusd = l3 .rpc .call ('offer' , {'amount' : '10.05USD' ,
45654565 'description' : 'USD test' })['bolt12' ]
45664566
4567+ # We've done 3 onion calls: sleep now to avoid hitting ratelimit!
4568+ time .sleep (1 )
4569+
45674570 inv = l1 .rpc .call ('fetchinvoice' , {'offer' : offerusd })
45684571 assert inv ['changes' ]['amount_msat' ] == Millisatoshi (int (10.05 * 5000 ))
45694572
@@ -4579,7 +4582,7 @@ def test_fetchinvoice(node_factory, bitcoind):
45794582 l4 .rpc .connect (l3 .info ['id' ], 'localhost' , l3 .port )
45804583 l4 .rpc .call ('fetchinvoice' , {'offer' : offer1 ['bolt12' ]})
45814584
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!
45834586 time .sleep (1 )
45844587
45854588 # If we remove plugin, it can no longer give us an invoice.
0 commit comments