|
|
|
@ -7,7 +7,8 @@
|
|
|
|
|
# Test pruning code
|
|
|
|
|
# ********
|
|
|
|
|
# WARNING:
|
|
|
|
|
# This test uses 4GB of disk space and takes in excess of 30 mins to run
|
|
|
|
|
# This test uses 4GB of disk space.
|
|
|
|
|
# This test takes 30 mins or more (up to 2 hours)
|
|
|
|
|
# ********
|
|
|
|
|
|
|
|
|
|
from test_framework import BitcoinTestFramework
|
|
|
|
@ -51,11 +52,11 @@ class PruneTest(BitcoinTestFramework):
|
|
|
|
|
self.is_network_split = False
|
|
|
|
|
|
|
|
|
|
# Create nodes 0 and 1 to mine
|
|
|
|
|
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=300))
|
|
|
|
|
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=300))
|
|
|
|
|
self.nodes.append(start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900))
|
|
|
|
|
self.nodes.append(start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900))
|
|
|
|
|
|
|
|
|
|
# Create node 2 to test pruning
|
|
|
|
|
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-prune=550"], timewait=300))
|
|
|
|
|
self.nodes.append(start_node(2, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-prune=550"], timewait=900))
|
|
|
|
|
self.prunedir = self.options.tmpdir+"/node2/regtest/blocks/"
|
|
|
|
|
|
|
|
|
|
self.address[0] = self.nodes[0].getnewaddress()
|
|
|
|
@ -108,7 +109,7 @@ class PruneTest(BitcoinTestFramework):
|
|
|
|
|
# Node 2 stays connected, so it hears about the stale blocks and then reorg's when node0 reconnects
|
|
|
|
|
# Stopping node 0 also clears its mempool, so it doesn't have node1's transactions to accidentally mine
|
|
|
|
|
stop_node(self.nodes[0],0)
|
|
|
|
|
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=300)
|
|
|
|
|
self.nodes[0]=start_node(0, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=999000", "-checkblocks=5"], timewait=900)
|
|
|
|
|
# Mine 24 blocks in node 1
|
|
|
|
|
self.utxo = self.nodes[1].listunspent()
|
|
|
|
|
for i in xrange(24):
|
|
|
|
@ -135,7 +136,7 @@ class PruneTest(BitcoinTestFramework):
|
|
|
|
|
# Reboot node 1 to clear its mempool (hopefully make the invalidate faster)
|
|
|
|
|
# Lower the block max size so we don't keep mining all our big mempool transactions (from disconnected blocks)
|
|
|
|
|
stop_node(self.nodes[1],1)
|
|
|
|
|
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=300)
|
|
|
|
|
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
|
|
|
|
|
|
|
|
|
|
height = self.nodes[1].getblockcount()
|
|
|
|
|
print "Current block height:", height
|
|
|
|
@ -158,7 +159,7 @@ class PruneTest(BitcoinTestFramework):
|
|
|
|
|
|
|
|
|
|
# Reboot node1 to clear those giant tx's from mempool
|
|
|
|
|
stop_node(self.nodes[1],1)
|
|
|
|
|
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=300)
|
|
|
|
|
self.nodes[1]=start_node(1, self.options.tmpdir, ["-debug","-maxreceivebuffer=20000","-blockmaxsize=5000", "-checkblocks=5", "-disablesafemode"], timewait=900)
|
|
|
|
|
|
|
|
|
|
print "Generating new longer chain of 300 more blocks"
|
|
|
|
|
self.nodes[1].generate(300)
|
|
|
|
@ -223,7 +224,7 @@ class PruneTest(BitcoinTestFramework):
|
|
|
|
|
waitstart = time.time()
|
|
|
|
|
while self.nodes[2].getblockcount() < goalbestheight:
|
|
|
|
|
time.sleep(0.1)
|
|
|
|
|
if time.time() - waitstart > 300:
|
|
|
|
|
if time.time() - waitstart > 900:
|
|
|
|
|
raise AssertionError("Node 2 didn't reorg to proper height")
|
|
|
|
|
assert(self.nodes[2].getbestblockhash() == goalbesthash)
|
|
|
|
|
# Verify we can now have the data for a block previously pruned
|
|
|
|
@ -256,7 +257,7 @@ class PruneTest(BitcoinTestFramework):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_test(self):
|
|
|
|
|
print "Warning! This test requires 4GB of disk space and takes over 30 mins"
|
|
|
|
|
print "Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours)"
|
|
|
|
|
print "Mining a big blockchain of 995 blocks"
|
|
|
|
|
self.create_big_chain()
|
|
|
|
|
# Chain diagram key:
|
|
|
|
|