Check that we track forwarded payments correctly. We wire up the network to have l1 and l6 as payment initiator, l2 as forwarded (the one we check) and l3-l5 as payment recipients. There 5 cases for FORWARD_LOCAL_FAILED status: 1. When Msater resolves the reply about the next peer
(node_factory, bitcoind, executor)
| 1494 | |
| 1495 | @pytest.mark.slow_test |
| 1496 | def test_forward_local_failed_stats(node_factory, bitcoind, executor): |
| 1497 | """Check that we track forwarded payments correctly. |
| 1498 | |
| 1499 | We wire up the network to have l1 and l6 as payment initiator, l2 as |
| 1500 | forwarded (the one we check) and l3-l5 as payment recipients. |
| 1501 | |
| 1502 | There 5 cases for FORWARD_LOCAL_FAILED status: |
| 1503 | 1. When Msater resolves the reply about the next peer infor(sent |
| 1504 | by Gossipd), and need handle unknown next peer failure in |
| 1505 | channel_resolve_reply(). For this case, we ask l1 pay to l3 |
| 1506 | through l2 but close the channel between l2 and l3 after |
| 1507 | getroute(), the payment will fail in l2 because of |
| 1508 | WIRE_UNKNOWN_NEXT_PEER; |
| 1509 | 2. When Master handle the forward process with the htlc_in and |
| 1510 | the id of next hop, it tries to drive a new htlc_out but fails |
| 1511 | in forward_htlc(). For this case, we ask l1 pay to 14 through |
| 1512 | with no fee, so the payment will fail in l2 becase of |
| 1513 | WIRE_FEE_INSUFFICIENT; |
| 1514 | 3. When we send htlc_out, Master asks Channeld to add a new htlc |
| 1515 | into the outgoing channel but Channeld fails. Master need |
| 1516 | handle and store this failure in rcvd_htlc_reply(). For this |
| 1517 | case, we ask l1 pay to l5 with 10**8 sat though the channel |
| 1518 | (l2-->l5) with the max capacity of 10**4 msat , the payment |
| 1519 | will fail in l2 because of CHANNEL_ERR_MAX_HTLC_VALUE_EXCEEDED; |
| 1520 | 4. When Channeld receives a new revoke message, if the state of |
| 1521 | corresponding htlc is RCVD_ADD_ACK_REVOCATION, Master will tries |
| 1522 | to resolve onionpacket and handle the failure before resolving |
| 1523 | the next hop in peer_got_revoke(). For this case, we ask l6 pay |
| 1524 | to l4 though l1 and l2, but we replace the second node_id in route |
| 1525 | with the wrong one, so the payment will fail in l2 because of |
| 1526 | WIRE_INVALID_ONION_KEY; |
| 1527 | 5. When Onchaind finds the htlc time out or missing htlc, Master |
| 1528 | need handle these failure as FORWARD_LOCAL_FAILED in if it's forward |
| 1529 | payment case. For this case, we ask l1 pay to l4 though l2 with the |
| 1530 | amount less than the invoice(the payment must fail in l4), and we |
| 1531 | also ask l5 disconnected before sending update_fail_htlc, so the |
| 1532 | htlc will be holding until l2 meets timeout and handle it as local_fail. |
| 1533 | """ |
| 1534 | |
| 1535 | amount = 10**8 |
| 1536 | |
| 1537 | disconnects = ['-WIRE_UPDATE_FAIL_HTLC', 'permfail'] |
| 1538 | |
| 1539 | l1, l2, l3, l4, l5, l6 = node_factory.get_nodes(6, opts=[{}, |
| 1540 | {}, |
| 1541 | {}, |
| 1542 | {'disconnect': disconnects}, |
| 1543 | {}, |
| 1544 | {}]) |
| 1545 | |
| 1546 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 1547 | l2.rpc.connect(l3.info['id'], 'localhost', l3.port) |
| 1548 | l2.rpc.connect(l4.info['id'], 'localhost', l4.port) |
| 1549 | l2.rpc.connect(l5.info['id'], 'localhost', l5.port) |
| 1550 | l6.rpc.connect(l1.info['id'], 'localhost', l1.port) |
| 1551 | c12, _ = l1.fundchannel(l2, 10**6) |
| 1552 | c23, _ = l2.fundchannel(l3, 10**6) |
| 1553 | c24, _ = l2.fundchannel(l4, 10**6) |
nothing calls this directly
no test coverage detected