test 'forward_event' notifications
(node_factory, bitcoind, executor)
| 1581 | |
| 1582 | |
| 1583 | def test_forward_event_notification(node_factory, bitcoind, executor): |
| 1584 | """ test 'forward_event' notifications |
| 1585 | """ |
| 1586 | amount = 10**8 |
| 1587 | disconnects = ['-WIRE_UPDATE_FAIL_HTLC', 'permfail'] |
| 1588 | plugin = os.path.join( |
| 1589 | os.path.dirname(__file__), |
| 1590 | 'plugins', |
| 1591 | 'forward_payment_status.py' |
| 1592 | ) |
| 1593 | l1, l2, l3, l4, l5 = node_factory.get_nodes(5, opts=[ |
| 1594 | {}, |
| 1595 | {'plugin': plugin}, |
| 1596 | {}, |
| 1597 | {}, |
| 1598 | {'disconnect': disconnects}]) |
| 1599 | |
| 1600 | l1.openchannel(l2, confirm=False, wait_for_announce=False) |
| 1601 | l2.openchannel(l3, confirm=False, wait_for_announce=False) |
| 1602 | l2.openchannel(l4, confirm=False, wait_for_announce=False) |
| 1603 | l2.openchannel(l5, confirm=False, wait_for_announce=False) |
| 1604 | |
| 1605 | # Generate 5, then make sure everyone is up to date before |
| 1606 | # last one, otherwise they might think it's in the future! |
| 1607 | bitcoind.generate_block(5) |
| 1608 | sync_blockheight(bitcoind, [l1, l2, l3, l4, l5]) |
| 1609 | bitcoind.generate_block(1) |
| 1610 | |
| 1611 | wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 8) |
| 1612 | |
| 1613 | inv = l3.rpc.invoice(amount, "first", "desc") |
| 1614 | payment_hash13 = inv['payment_hash'] |
| 1615 | route = l1.single_route(l3.info['id'], amount) |
| 1616 | |
| 1617 | # status: offered -> settled |
| 1618 | l1.rpc.sendpay(route, payment_hash13, payment_secret=inv['payment_secret']) |
| 1619 | l1.rpc.waitsendpay(payment_hash13) |
| 1620 | |
| 1621 | # status: offered -> failed |
| 1622 | route = l1.single_route(l4.info['id'], amount) |
| 1623 | payment_hash14 = "f" * 64 |
| 1624 | with pytest.raises(RpcError): |
| 1625 | l1.rpc.sendpay(route, payment_hash14, payment_secret="f" * 64) |
| 1626 | l1.rpc.waitsendpay(payment_hash14) |
| 1627 | |
| 1628 | # status: offered -> local_failed |
| 1629 | inv = l5.rpc.invoice(amount, 'onchain_timeout', 'desc') |
| 1630 | payment_hash15 = inv['payment_hash'] |
| 1631 | fee = amount * 10 // 1000000 + 1 |
| 1632 | c12 = l1.get_channel_scid(l2) |
| 1633 | c25 = l2.get_channel_scid(l5) |
| 1634 | route = [{'amount_msat': amount + fee - 1, |
| 1635 | 'id': l2.info['id'], |
| 1636 | 'delay': 12, |
| 1637 | 'channel': c12}, |
| 1638 | {'amount_msat': amount - 1, |
| 1639 | 'id': l5.info['id'], |
| 1640 | 'delay': 5, |
nothing calls this directly
no test coverage detected