Skip to content

Commit a47df13

Browse files
committed
[qa] Test disconnect block failure -> shutdown
1 parent 4433ed0 commit a47df13

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

test/functional/feature_abortnode.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2019 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test bitcoind aborts if can't disconnect a block.
6+
7+
- Start a single node and generate 3 blocks.
8+
- Delete the undo data.
9+
- Mine a fork that requires disconnecting the tip.
10+
- Verify that bitcoind AbortNode's.
11+
"""
12+
13+
from test_framework.test_framework import BitcoinTestFramework
14+
from test_framework.util import wait_until, get_datadir_path, connect_nodes
15+
import os
16+
17+
class AbortNodeTest(BitcoinTestFramework):
18+
19+
def set_test_params(self):
20+
self.setup_clean_chain = True
21+
self.num_nodes = 2
22+
23+
def setup_network(self):
24+
self.setup_nodes()
25+
# We'll connect the nodes later
26+
27+
def run_test(self):
28+
self.nodes[0].generate(3)
29+
datadir = get_datadir_path(self.options.tmpdir, 0)
30+
31+
# Deleting the undo file will result in reorg failure
32+
os.unlink(os.path.join(datadir, 'regtest', 'blocks', 'rev00000.dat'))
33+
34+
# Connecting to a node with a more work chain will trigger a reorg
35+
# attempt.
36+
self.nodes[1].generate(3)
37+
with self.nodes[0].assert_debug_log(["Failed to disconnect block"]):
38+
connect_nodes(self.nodes[0], 1)
39+
self.nodes[1].generate(1)
40+
41+
# Check that node0 aborted
42+
self.log.info("Waiting for crash")
43+
wait_until(lambda: self.nodes[0].is_node_stopped(), timeout=60)
44+
self.log.info("Node crashed - now verifying restart fails")
45+
self.nodes[0].assert_start_raises_init_error()
46+
47+
if __name__ == '__main__':
48+
AbortNodeTest().main()

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
'feature_bip68_sequence.py',
103103
'p2p_feefilter.py',
104104
'feature_reindex.py',
105+
'feature_abortnode.py',
105106
# vv Tests less than 30s vv
106107
'wallet_keypool_topup.py',
107108
'interface_zmq.py',

0 commit comments

Comments
 (0)