Browse Source

Merge #10632: qa: Add stopatheight test

5555fa8 qa: Add stopatheight test (MarcoFalke)

Tree-SHA512: ea3f318c3dc73a885db5e258f5d6a25e0017e2360a72ac5f6914bce6f7798d36aca45d2626aafd57ead744bd28fd38b561207a7a547a1d417e594976c35bccee
0.15
MarcoFalke 8 years ago
parent
commit
c68a9a6927
No known key found for this signature in database
GPG Key ID: D2EA4850E7528B25
  1. 20
      test/functional/blockchain.py

20
test/functional/blockchain.py

@ -18,13 +18,16 @@ Tests correspond to code in rpc/blockchain.cpp.
""" """
from decimal import Decimal from decimal import Decimal
import subprocess
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import ( from test_framework.util import (
assert_equal, assert_equal,
assert_raises,
assert_raises_jsonrpc, assert_raises_jsonrpc,
assert_is_hex_string, assert_is_hex_string,
assert_is_hash_string, assert_is_hash_string,
bitcoind_processes,
) )
@ -34,6 +37,7 @@ class BlockchainTest(BitcoinTestFramework):
super().__init__() super().__init__()
self.setup_clean_chain = False self.setup_clean_chain = False
self.num_nodes = 1 self.num_nodes = 1
self.extra_args = [['-stopatheight=207']]
def run_test(self): def run_test(self):
self._test_getchaintxstats() self._test_getchaintxstats()
@ -41,7 +45,8 @@ class BlockchainTest(BitcoinTestFramework):
self._test_getblockheader() self._test_getblockheader()
self._test_getdifficulty() self._test_getdifficulty()
self._test_getnetworkhashps() self._test_getnetworkhashps()
self.nodes[0].verifychain(4, 0) self._test_stopatheight()
assert self.nodes[0].verifychain(4, 0)
def _test_getchaintxstats(self): def _test_getchaintxstats(self):
chaintxstats = self.nodes[0].getchaintxstats(1) chaintxstats = self.nodes[0].getchaintxstats(1)
@ -129,5 +134,18 @@ class BlockchainTest(BitcoinTestFramework):
# This should be 2 hashes every 10 minutes or 1/300 # This should be 2 hashes every 10 minutes or 1/300
assert abs(hashes_per_second * 300 - 1) < 0.0001 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__': if __name__ == '__main__':
BlockchainTest().main() BlockchainTest().main()

Loading…
Cancel
Save