Send payments from l1 to l2, but l2 just declines everything. l2 is configured with a plugin that'll hook into htlc_accepted and always return failures. The same should also work for forwarded htlcs in the second half.
(node_factory)
| 1207 | |
| 1208 | |
| 1209 | def test_htlc_accepted_hook_fail(node_factory): |
| 1210 | """Send payments from l1 to l2, but l2 just declines everything. |
| 1211 | |
| 1212 | l2 is configured with a plugin that'll hook into htlc_accepted and |
| 1213 | always return failures. The same should also work for forwarded |
| 1214 | htlcs in the second half. |
| 1215 | |
| 1216 | """ |
| 1217 | l1, l2, l3 = node_factory.line_graph(3, opts=[ |
| 1218 | {}, |
| 1219 | {'dev-onion-reply-length': 1111, |
| 1220 | 'plugin': os.path.join(os.getcwd(), 'tests/plugins/fail_htlcs.py')}, |
| 1221 | {} |
| 1222 | ], wait_for_announce=True) |
| 1223 | |
| 1224 | # This must fail |
| 1225 | inv = l2.rpc.invoice(1000, "lbl", "desc") |
| 1226 | phash = inv['payment_hash'] |
| 1227 | route = l1.single_route(l2.info['id'], 1000) |
| 1228 | |
| 1229 | # Here shouldn't use `pay` command because l2 rejects with WIRE_TEMPORARY_NODE_FAILURE, |
| 1230 | # then it will be excluded when l1 try another pay attempt. |
| 1231 | # Note if the destination is excluded, the route result is undefined. |
| 1232 | l1.rpc.sendpay(route, phash, payment_secret=inv['payment_secret']) |
| 1233 | with pytest.raises(RpcError) as excinfo: |
| 1234 | l1.rpc.waitsendpay(phash) |
| 1235 | assert excinfo.value.error['data']['failcode'] == 0x2002 |
| 1236 | assert excinfo.value.error['data']['erring_index'] == 1 |
| 1237 | |
| 1238 | # And the invoice must still be unpaid |
| 1239 | inv = l2.rpc.listinvoices("lbl")['invoices'] |
| 1240 | assert len(inv) == 1 and inv[0]['status'] == 'unpaid' |
| 1241 | |
| 1242 | # Now try with forwarded HTLCs: l2 should still fail them |
| 1243 | # This must fail |
| 1244 | inv = l3.rpc.invoice(1000, "lbl", "desc")['bolt11'] |
| 1245 | with pytest.raises(RpcError, match=r"We got a weird error \(temporary_node_failure\) for the invoice's route hint"): |
| 1246 | l1.rpc.xpay(inv) |
| 1247 | |
| 1248 | # And the invoice must still be unpaid |
| 1249 | inv = l3.rpc.listinvoices("lbl")['invoices'] |
| 1250 | assert len(inv) == 1 and inv[0]['status'] == 'unpaid' |
| 1251 | |
| 1252 | |
| 1253 | def test_htlc_accepted_hook_resolve(node_factory): |
nothing calls this directly
no test coverage detected