(node_factory, bitcoind)
| 1875 | |
| 1876 | @pytest.mark.developer("needs DEVELOPER=1") |
| 1877 | def test_onchaind_replay(node_factory, bitcoind): |
| 1878 | disconnects = ['+WIRE_REVOKE_AND_ACK', 'permfail'] |
| 1879 | # Feerates identical so we don't get gratuitous commit to update them |
| 1880 | l1, l2 = node_factory.line_graph(2, opts=[{'watchtime-blocks': 201, 'cltv-delta': 101, |
| 1881 | 'disconnect': disconnects, |
| 1882 | 'feerates': (7500, 7500, 7500, 7500)}, |
| 1883 | {'watchtime-blocks': 201, 'cltv-delta': 101}]) |
| 1884 | |
| 1885 | inv = l2.rpc.invoice(10**8, 'onchaind_replay', 'desc') |
| 1886 | rhash = inv['payment_hash'] |
| 1887 | routestep = { |
| 1888 | 'amount_msat': 10**8 - 1, |
| 1889 | 'id': l2.info['id'], |
| 1890 | 'delay': 101, |
| 1891 | 'channel': first_scid(l1, l2) |
| 1892 | } |
| 1893 | l1.rpc.sendpay([routestep], rhash, payment_secret=inv['payment_secret']) |
| 1894 | l1.daemon.wait_for_log('sendrawtx exit 0') |
| 1895 | bitcoind.generate_block(1, wait_for_mempool=1) |
| 1896 | |
| 1897 | # Wait for nodes to notice the failure, this seach needle is after the |
| 1898 | # DB commit so we're sure the tx entries in onchaindtxs have been added |
| 1899 | l1.daemon.wait_for_log("Deleting channel .* due to the funding outpoint being spent") |
| 1900 | l2.daemon.wait_for_log("Deleting channel .* due to the funding outpoint being spent") |
| 1901 | |
| 1902 | # We should at least have the init tx now |
| 1903 | assert len(l1.db_query("SELECT * FROM channeltxs;")) > 0 |
| 1904 | assert len(l2.db_query("SELECT * FROM channeltxs;")) > 0 |
| 1905 | |
| 1906 | # Generate some blocks so we restart the onchaind from DB (we rescan |
| 1907 | # last_height - 100) |
| 1908 | bitcoind.generate_block(100) |
| 1909 | sync_blockheight(bitcoind, [l1, l2]) |
| 1910 | |
| 1911 | # l1 should still have a running onchaind |
| 1912 | assert len(l1.db_query("SELECT * FROM channeltxs;")) > 0 |
| 1913 | |
| 1914 | l2.rpc.stop() |
| 1915 | l1.restart() |
| 1916 | |
| 1917 | # Can't wait for it, it's after the "Server started" wait in restart() |
| 1918 | assert l1.daemon.is_in_log(r'Restarting onchaind for channel') |
| 1919 | |
| 1920 | # l1 should still notice that the funding was spent and that we should react to it |
| 1921 | l1.daemon.wait_for_log("Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET") |
| 1922 | sync_blockheight(bitcoind, [l1]) |
| 1923 | bitcoind.generate_block(10) |
| 1924 | sync_blockheight(bitcoind, [l1]) |
| 1925 | |
| 1926 | |
| 1927 | @pytest.mark.developer("needs DEVELOPER=1") |
nothing calls this directly
no test coverage detected