diff options
author | MarcoFalke <falke.marco@gmail.com> | 2017-06-22 10:50:24 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2017-06-22 10:50:44 +0200 |
commit | c68a9a69278aa194fed96bd9733d32af3690a11e (patch) | |
tree | 65526ec5761869192f4e56cc50b5c88466dc0326 /test/functional/blockchain.py | |
parent | d083bd9b9c5249f21b8b7e4abd7aee48a25806b1 (diff) | |
parent | 5555fa8b74bc3c8e68232acbf4c54b9a8fadb8f2 (diff) |
Merge #10632: qa: Add stopatheight test
5555fa8 qa: Add stopatheight test (MarcoFalke)
Tree-SHA512: ea3f318c3dc73a885db5e258f5d6a25e0017e2360a72ac5f6914bce6f7798d36aca45d2626aafd57ead744bd28fd38b561207a7a547a1d417e594976c35bccee
Diffstat (limited to 'test/functional/blockchain.py')
-rwxr-xr-x | test/functional/blockchain.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/test/functional/blockchain.py b/test/functional/blockchain.py index 6aef6d4489..e205c6400c 100755 --- a/test/functional/blockchain.py +++ b/test/functional/blockchain.py @@ -18,13 +18,16 @@ Tests correspond to code in rpc/blockchain.cpp. """ from decimal import Decimal +import subprocess from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, + assert_raises, assert_raises_jsonrpc, assert_is_hex_string, assert_is_hash_string, + bitcoind_processes, ) @@ -34,6 +37,7 @@ class BlockchainTest(BitcoinTestFramework): super().__init__() self.setup_clean_chain = False self.num_nodes = 1 + self.extra_args = [['-stopatheight=207']] def run_test(self): self._test_getchaintxstats() @@ -41,7 +45,8 @@ class BlockchainTest(BitcoinTestFramework): self._test_getblockheader() self._test_getdifficulty() self._test_getnetworkhashps() - self.nodes[0].verifychain(4, 0) + self._test_stopatheight() + assert self.nodes[0].verifychain(4, 0) def _test_getchaintxstats(self): chaintxstats = self.nodes[0].getchaintxstats(1) @@ -129,5 +134,18 @@ class BlockchainTest(BitcoinTestFramework): # This should be 2 hashes every 10 minutes or 1/300 assert abs(hashes_per_second * 300 - 1) < 0.0001 + def _test_stopatheight(self): + assert_equal(self.nodes[0].getblockcount(), 200) + self.nodes[0].generate(6) + assert_equal(self.nodes[0].getblockcount(), 206) + self.log.debug('Node should not stop at this height') + assert_raises(subprocess.TimeoutExpired, lambda: bitcoind_processes[0].wait(timeout=3)) + self.nodes[0].generate(1) + self.log.debug('Node should stop at this height...') + bitcoind_processes[0].wait(timeout=3) + self.nodes[0] = self.start_node(0, self.options.tmpdir) + assert_equal(self.nodes[0].getblockcount(), 207) + + if __name__ == '__main__': BlockchainTest().main() |