(node_factory, bitcoind)
| 5217 | |
| 5218 | |
| 5219 | def test_setchannel_enforcement_delay(node_factory, bitcoind): |
| 5220 | # Fees start at 1msat + 1% |
| 5221 | l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True, |
| 5222 | opts={'fee-base': 1, |
| 5223 | 'fee-per-satoshi': 10000}) |
| 5224 | |
| 5225 | chanid1 = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['short_channel_id'] |
| 5226 | chanid2 = only_one(l2.rpc.listpeerchannels(l3.info['id'])['channels'])['short_channel_id'] |
| 5227 | |
| 5228 | route = [{'amount_msat': 1011, |
| 5229 | 'id': l2.info['id'], |
| 5230 | 'delay': 20, |
| 5231 | 'channel': chanid1}, |
| 5232 | {'amount_msat': 1000, |
| 5233 | 'id': l3.info['id'], |
| 5234 | 'delay': 10, |
| 5235 | 'channel': chanid2}] |
| 5236 | |
| 5237 | # This works. |
| 5238 | inv = l3.rpc.invoice(1000, "test1", "test1") |
| 5239 | l1.rpc.sendpay(route, |
| 5240 | payment_hash=inv['payment_hash'], |
| 5241 | payment_secret=inv['payment_secret']) |
| 5242 | l1.rpc.waitsendpay(inv['payment_hash']) |
| 5243 | |
| 5244 | # Increase fee immediately; l1 payment rejected. |
| 5245 | l2.rpc.setchannel("all", 2, 10000, enforcedelay=0) |
| 5246 | |
| 5247 | inv = l3.rpc.invoice(1000, "test2", "test2") |
| 5248 | l1.rpc.sendpay(route, |
| 5249 | payment_hash=inv['payment_hash'], |
| 5250 | payment_secret=inv['payment_secret']) |
| 5251 | with pytest.raises(RpcError, match=r'WIRE_FEE_INSUFFICIENT'): |
| 5252 | l1.rpc.waitsendpay(inv['payment_hash']) |
| 5253 | |
| 5254 | # Test increased amount. |
| 5255 | route[0]['amount_msat'] += 1 |
| 5256 | inv = l3.rpc.invoice(1000, "test3", "test3") |
| 5257 | l1.rpc.sendpay(route, |
| 5258 | payment_hash=inv['payment_hash'], |
| 5259 | payment_secret=inv['payment_secret']) |
| 5260 | l1.rpc.waitsendpay(inv['payment_hash']) |
| 5261 | |
| 5262 | # Now, give us 30 seconds please. |
| 5263 | l2.rpc.setchannel("all", 3, 10000, enforcedelay=30) |
| 5264 | inv = l3.rpc.invoice(1000, "test4", "test4") |
| 5265 | l1.rpc.sendpay(route, |
| 5266 | payment_hash=inv['payment_hash'], |
| 5267 | payment_secret=inv['payment_secret']) |
| 5268 | l1.rpc.waitsendpay(inv['payment_hash']) |
| 5269 | l2.daemon.wait_for_log("Allowing payment using older feerate") |
| 5270 | |
| 5271 | time.sleep(30) |
| 5272 | inv = l3.rpc.invoice(1000, "test5", "test5") |
| 5273 | l1.rpc.sendpay(route, |
| 5274 | payment_hash=inv['payment_hash'], |
| 5275 | payment_secret=inv['payment_secret']) |
| 5276 | with pytest.raises(RpcError, match=r'WIRE_FEE_INSUFFICIENT'): |
nothing calls this directly
no test coverage detected