Channeld should disallow you spending into your reserve
(node_factory, executor)
| 1739 | @pytest.mark.openchannel('v1') |
| 1740 | @pytest.mark.openchannel('v2') |
| 1741 | def test_reserve_enforcement(node_factory, executor): |
| 1742 | """Channeld should disallow you spending into your reserve""" |
| 1743 | l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True, |
| 1744 | 'dev-no-reconnect': None, |
| 1745 | 'allow_warning': True}) |
| 1746 | |
| 1747 | # Pay 1000 satoshi to l2. |
| 1748 | l1.pay(l2, 1000000) |
| 1749 | l2.stop() |
| 1750 | |
| 1751 | # They should both aim for 1%. |
| 1752 | reserves = l2.db.query('SELECT channel_reserve_satoshis FROM channel_configs') |
| 1753 | assert reserves == [{'channel_reserve_satoshis': 10**6 // 100}] * 2 |
| 1754 | |
| 1755 | # Edit db to reduce reserve to 0 so it will try to violate it. |
| 1756 | l2.db.execute('UPDATE channel_configs SET channel_reserve_satoshis=0') |
| 1757 | |
| 1758 | l2.start() |
| 1759 | l2.rpc.connect(l1.info['id'], 'localhost', l1.port) |
| 1760 | |
| 1761 | # This should be impossible to pay entire thing back: l1 should warn and |
| 1762 | # close connection for trying to violate reserve. |
| 1763 | executor.submit(l2.pay, l1, 1000000) |
| 1764 | l1.daemon.wait_for_log( |
| 1765 | 'Peer transient failure in CHANNELD_NORMAL: channeld.*' |
| 1766 | ' CHANNEL_ERR_CHANNEL_CAPACITY_EXCEEDED' |
| 1767 | ) |
| 1768 | wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['connected'] is False) |
| 1769 | |
| 1770 | |
| 1771 | def test_ipv4_and_ipv6(node_factory): |
nothing calls this directly
no test coverage detected