mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-02-02 18:24:25 +00:00
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.
This commit is contained in:
parent
a8b2ce557d
commit
daf03e7c92
@ -103,12 +103,17 @@ def initialize_chain(test_dir):
|
|||||||
|
|
||||||
# Create a 200-block-long chain; each of the 4 nodes
|
# Create a 200-block-long chain; each of the 4 nodes
|
||||||
# gets 25 mature blocks and 25 immature.
|
# gets 25 mature blocks and 25 immature.
|
||||||
for i in range(4):
|
# blocks are created with timestamps 10 minutes apart, starting
|
||||||
rpcs[i].setgenerate(True, 25)
|
# at 1 Jan 2014
|
||||||
sync_blocks(rpcs)
|
block_time = 1388534400
|
||||||
for i in range(4):
|
for i in range(2):
|
||||||
rpcs[i].setgenerate(True, 25)
|
for peer in range(4):
|
||||||
sync_blocks(rpcs)
|
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:
|
# Shut them down, and clean up cache directories:
|
||||||
stop_nodes(rpcs)
|
stop_nodes(rpcs)
|
||||||
@ -179,10 +184,14 @@ def stop_node(node, i):
|
|||||||
del bitcoind_processes[i]
|
del bitcoind_processes[i]
|
||||||
|
|
||||||
def stop_nodes(nodes):
|
def stop_nodes(nodes):
|
||||||
for i in range(len(nodes)):
|
for node in nodes:
|
||||||
nodes[i].stop()
|
node.stop()
|
||||||
del nodes[:] # Emptying array closes connections as a side effect
|
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():
|
def wait_bitcoinds():
|
||||||
# Wait for all bitcoinds to cleanly exit
|
# Wait for all bitcoinds to cleanly exit
|
||||||
for bitcoind in bitcoind_processes.values():
|
for bitcoind in bitcoind_processes.values():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user