Onchaind should not watch random spends
(node_factory, bitcoind)
| 1821 | |
| 1822 | @pytest.mark.developer("needs DEVELOPER=1") |
| 1823 | def test_onchain_unwatch(node_factory, bitcoind): |
| 1824 | """Onchaind should not watch random spends""" |
| 1825 | # We track channel balances, to verify that accounting is ok. |
| 1826 | coin_mvt_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py') |
| 1827 | l1, l2 = node_factory.line_graph(2, opts={'plugin': coin_mvt_plugin}) |
| 1828 | channel_id = first_channel_id(l1, l2) |
| 1829 | |
| 1830 | l1.pay(l2, 200000000) |
| 1831 | |
| 1832 | l1.rpc.dev_fail(l2.info['id']) |
| 1833 | l1.daemon.wait_for_log('Failing due to dev-fail command') |
| 1834 | l1.wait_for_channel_onchain(l2.info['id']) |
| 1835 | |
| 1836 | l1.bitcoin.generate_block(1) |
| 1837 | l1.daemon.wait_for_log(' to ONCHAIN') |
| 1838 | l2.daemon.wait_for_log(' to ONCHAIN') |
| 1839 | |
| 1840 | # 10 later, l1 should collect its to-self payment. |
| 1841 | bitcoind.generate_block(10) |
| 1842 | l1.wait_for_onchaind_broadcast('OUR_DELAYED_RETURN_TO_WALLET', |
| 1843 | 'OUR_UNILATERAL/DELAYED_OUTPUT_TO_US') |
| 1844 | |
| 1845 | # First time it sees it, onchaind cares. |
| 1846 | bitcoind.generate_block(1) |
| 1847 | l1.daemon.wait_for_log('Resolved OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by our proposal ' |
| 1848 | 'OUR_DELAYED_RETURN_TO_WALLET') |
| 1849 | |
| 1850 | # Now test unrelated onchain churn. |
| 1851 | # Daemon gets told about wallet; says it doesn't care. |
| 1852 | l1.rpc.withdraw(l1.rpc.newaddr()['bech32'], 'all') |
| 1853 | bitcoind.generate_block(1) |
| 1854 | l1.daemon.wait_for_log("but we don't care") |
| 1855 | |
| 1856 | # And lightningd should respect that! |
| 1857 | assert not l1.daemon.is_in_log("Can't unwatch txid") |
| 1858 | |
| 1859 | # So these should not generate further messages |
| 1860 | for i in range(5): |
| 1861 | l1.rpc.withdraw(l1.rpc.newaddr()['bech32'], 'all') |
| 1862 | bitcoind.generate_block(1) |
| 1863 | # Make sure it digests the block |
| 1864 | sync_blockheight(bitcoind, [l1]) |
| 1865 | |
| 1866 | # We won't see this again. |
| 1867 | assert not l1.daemon.is_in_log("but we don't care", |
| 1868 | start=l1.daemon.logsearch_start) |
| 1869 | |
| 1870 | assert account_balance(l1, channel_id) == 0 |
| 1871 | assert account_balance(l2, channel_id) == 0 |
| 1872 | # Note: for this test we leave onchaind running, so we can detect |
| 1873 | # any leaks! |
| 1874 | |
| 1875 | |
| 1876 | @pytest.mark.developer("needs DEVELOPER=1") |
nothing calls this directly
no test coverage detected