test 'sendpay_success' and 'sendpay_failure' notifications
(node_factory, bitcoind)
| 1714 | |
| 1715 | |
| 1716 | def test_sendpay_notifications(node_factory, bitcoind): |
| 1717 | """ test 'sendpay_success' and 'sendpay_failure' notifications |
| 1718 | """ |
| 1719 | amount = 10**8 |
| 1720 | opts = [{'plugin': os.path.join(os.getcwd(), 'tests/plugins/sendpay_notifications.py')}, |
| 1721 | {}, |
| 1722 | {'may_reconnect': False}] |
| 1723 | l1, l2, l3 = node_factory.line_graph(3, opts=opts, wait_for_announce=True) |
| 1724 | chanid23 = l2.get_channel_scid(l3) |
| 1725 | |
| 1726 | inv1 = l3.rpc.invoice(amount, "first", "desc") |
| 1727 | payment_hash1 = inv1['payment_hash'] |
| 1728 | inv2 = l3.rpc.invoice(amount, "second", "desc") |
| 1729 | payment_hash2 = inv2['payment_hash'] |
| 1730 | route = l1.single_route(l3.info['id'], amount) |
| 1731 | |
| 1732 | l1.rpc.sendpay(route, payment_hash1, payment_secret=inv1['payment_secret']) |
| 1733 | response1 = l1.rpc.waitsendpay(payment_hash1) |
| 1734 | |
| 1735 | l2.rpc.close(chanid23, 1) |
| 1736 | |
| 1737 | l1.rpc.sendpay(route, payment_hash2, payment_secret=inv2['payment_secret']) |
| 1738 | with pytest.raises(RpcError) as err: |
| 1739 | l1.rpc.waitsendpay(payment_hash2) |
| 1740 | |
| 1741 | results = l1.rpc.call('listsendpays_plugin') |
| 1742 | assert len(results['sendpay_success']) == 1 |
| 1743 | assert len(results['sendpay_failure']) == 1 |
| 1744 | |
| 1745 | assert results['sendpay_success'][0] == response1 |
| 1746 | assert results['sendpay_failure'][0] == err.value.error |
| 1747 | |
| 1748 | |
| 1749 | def test_sendpay_notifications_nowaiter(node_factory): |
nothing calls this directly
no test coverage detected