Skip to content

Commit c68a9a6

Browse files
author
MarcoFalke
committed
Merge #10632: qa: Add stopatheight test
5555fa8 qa: Add stopatheight test (MarcoFalke) Tree-SHA512: ea3f318c3dc73a885db5e258f5d6a25e0017e2360a72ac5f6914bce6f7798d36aca45d2626aafd57ead744bd28fd38b561207a7a547a1d417e594976c35bccee
2 parents d083bd9 + 5555fa8 commit c68a9a6

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/functional/blockchain.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
"""
1919

2020
from decimal import Decimal
21+
import subprocess
2122

2223
from test_framework.test_framework import BitcoinTestFramework
2324
from test_framework.util import (
2425
assert_equal,
26+
assert_raises,
2527
assert_raises_jsonrpc,
2628
assert_is_hex_string,
2729
assert_is_hash_string,
30+
bitcoind_processes,
2831
)
2932

3033

@@ -34,14 +37,16 @@ def __init__(self):
3437
super().__init__()
3538
self.setup_clean_chain = False
3639
self.num_nodes = 1
40+
self.extra_args = [['-stopatheight=207']]
3741

3842
def run_test(self):
3943
self._test_getchaintxstats()
4044
self._test_gettxoutsetinfo()
4145
self._test_getblockheader()
4246
self._test_getdifficulty()
4347
self._test_getnetworkhashps()
44-
self.nodes[0].verifychain(4, 0)
48+
self._test_stopatheight()
49+
assert self.nodes[0].verifychain(4, 0)
4550

4651
def _test_getchaintxstats(self):
4752
chaintxstats = self.nodes[0].getchaintxstats(1)
@@ -129,5 +134,18 @@ def _test_getnetworkhashps(self):
129134
# This should be 2 hashes every 10 minutes or 1/300
130135
assert abs(hashes_per_second * 300 - 1) < 0.0001
131136

137+
def _test_stopatheight(self):
138+
assert_equal(self.nodes[0].getblockcount(), 200)
139+
self.nodes[0].generate(6)
140+
assert_equal(self.nodes[0].getblockcount(), 206)
141+
self.log.debug('Node should not stop at this height')
142+
assert_raises(subprocess.TimeoutExpired, lambda: bitcoind_processes[0].wait(timeout=3))
143+
self.nodes[0].generate(1)
144+
self.log.debug('Node should stop at this height...')
145+
bitcoind_processes[0].wait(timeout=3)
146+
self.nodes[0] = self.start_node(0, self.options.tmpdir)
147+
assert_equal(self.nodes[0].getblockcount(), 207)
148+
149+
132150
if __name__ == '__main__':
133151
BlockchainTest().main()

0 commit comments

Comments
 (0)