diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2014-11-13 13:27:13 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2014-11-17 14:13:32 -0500 |
commit | daf03e7c92c155e3c9c010969192c60872af7bdb (patch) | |
tree | 00c17b16e260ce47ada1af6a3cca82fa9d7c7662 /qa | |
parent | a8b2ce557dbcee5e75001be0ec3aecf06165775f (diff) |
RPC tests: create initial chain with specific timestamps
Use setmocktime to create the initial block chain with
10-minute-apart-blocks starting 1 Jan 2014.
Diffstat (limited to 'qa')
-rw-r--r-- | qa/rpc-tests/util.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/qa/rpc-tests/util.py b/qa/rpc-tests/util.py index 0d5eeefa79..c6d918a81c 100644 --- a/qa/rpc-tests/util.py +++ b/qa/rpc-tests/util.py @@ -103,12 +103,17 @@ def initialize_chain(test_dir): # Create a 200-block-long chain; each of the 4 nodes # gets 25 mature blocks and 25 immature. - for i in range(4): - rpcs[i].setgenerate(True, 25) - sync_blocks(rpcs) - for i in range(4): - rpcs[i].setgenerate(True, 25) - sync_blocks(rpcs) + # blocks are created with timestamps 10 minutes apart, starting + # at 1 Jan 2014 + block_time = 1388534400 + for i in range(2): + for peer in range(4): + for j in range(25): + set_node_times(rpcs, block_time) + rpcs[peer].setgenerate(True, 1) + block_time += 10*60 + # Must sync before next peer starts generating blocks + sync_blocks(rpcs) # Shut them down, and clean up cache directories: stop_nodes(rpcs) @@ -179,10 +184,14 @@ def stop_node(node, i): del bitcoind_processes[i] def stop_nodes(nodes): - for i in range(len(nodes)): - nodes[i].stop() + for node in nodes: + node.stop() del nodes[:] # Emptying array closes connections as a side effect +def set_node_times(nodes, t): + for node in nodes: + node.setmocktime(t) + def wait_bitcoinds(): # Wait for all bitcoinds to cleanly exit for bitcoind in bitcoind_processes.values(): |