Test that matches found during rescan also trigger watch_found
(node_factory, bitcoind)
| 5401 | |
| 5402 | @pytest.mark.slow_test |
| 5403 | def test_bwatch_rescan_notifies_lightningd(node_factory, bitcoind): |
| 5404 | """Test that matches found during rescan also trigger watch_found""" |
| 5405 | l1 = node_factory.get_node(options=BWATCH_OPTS) |
| 5406 | |
| 5407 | # Get an address |
| 5408 | addr = l1.rpc.newaddr('bech32')['bech32'] |
| 5409 | addr_info = bitcoind.rpc.getaddressinfo(addr) |
| 5410 | scriptpubkey = addr_info['scriptPubKey'] |
| 5411 | |
| 5412 | # Send coins FIRST (before adding the watch) |
| 5413 | bitcoind.rpc.sendtoaddress(addr, 0.01) |
| 5414 | bitcoind.generate_block(1) |
| 5415 | |
| 5416 | # Wait for bwatch to fully sync to the new block |
| 5417 | import time |
| 5418 | time.sleep(2) |
| 5419 | l1.daemon.wait_for_log(r'No block change') |
| 5420 | |
| 5421 | # Now get current height and add watch with start_block in the past |
| 5422 | info = l1.rpc.getinfo() |
| 5423 | start_block = info['blockheight'] - 1 # The block we just mined |
| 5424 | |
| 5425 | # Add watch - should trigger rescan and find the tx |
| 5426 | l1.rpc.addscriptpubkeywatch(owner='wallet/p2wpkh/0', scriptpubkey=scriptpubkey, |
| 5427 | start_block=start_block) |
| 5428 | |
| 5429 | # Should trigger rescan |
| 5430 | l1.daemon.wait_for_log(r'Starting rescan') |
| 5431 | |
| 5432 | # Rescan should find the match and notify lightningd |
| 5433 | l1.daemon.wait_for_log(r'watch_found at block', timeout=60) |
| 5434 | |
| 5435 | |
| 5436 | def test_bwatch_watches_persist_across_restart(node_factory, bitcoind): |
nothing calls this directly
no test coverage detected