def manual_test(self, node_number, use_timestamp):
    self.start_node(node_number)
    node = self.nodes[node_number]
    assert_equal(node.getblockcount(), 995)
    assert_raises_rpc_error((- 1), 'not in prune mode', node.pruneblockchain, 500)
    self.restart_node(node_number, extra_args=['-prune=1'])
    node = self.nodes[node_number]
    assert_equal(node.getblockcount(), 995)

    def height(index):
        if use_timestamp:
            return (node.getblockheader(node.getblockhash(index))['time'] + TIMESTAMP_WINDOW)
        else:
            return index

    def prune(index):
        ret = node.pruneblockchain(height=height(index))
        assert_equal(ret, node.getblockchaininfo()['pruneheight'])

    def has_block(index):
        return os.path.isfile(os.path.join(self.nodes[node_number].datadir, self.chain, 'blocks', f'blk{index:05}.dat'))
    assert_raises_rpc_error((- 1), 'Blockchain is too short for pruning', node.pruneblockchain, height(500))
    block1_details = node.getblock(node.getblockhash(1))
    assert_equal(block1_details['nTx'], len(block1_details['tx']))
    self.generate(node, 6)
    assert_equal(node.getblockchaininfo()['blocks'], 1001)
    assert_equal(node.getblockheader(node.getblockhash(1))['nTx'], block1_details['nTx'])
    assert_raises_rpc_error((- 8), 'Negative', node.pruneblockchain, (- 10))
    prune(100)
    assert has_block(0), 'blk00000.dat is missing when should still be there'
    node.pruneblockchain(height(0))
    assert has_block(0), 'blk00000.dat is missing when should still be there'
    prune(500)
    assert (not has_block(0)), 'blk00000.dat is still there, should be pruned by now'
    assert has_block(1), 'blk00001.dat is missing when should still be there'
    prune(650)
    assert (not has_block(1)), 'blk00001.dat is still there, should be pruned by now'
    prune(1000)
    assert has_block(2), 'blk00002.dat is still there, should be pruned by now'
    self.generate(node, 288)
    prune(1000)
    assert (not has_block(2)), 'blk00002.dat is still there, should be pruned by now'
    assert (not has_block(3)), 'blk00003.dat is still there, should be pruned by now'
    self.restart_node(node_number, extra_args=['-prune=550'])
    self.log.info('Success')
def manual_test(self, node_number, use_timestamp):
    self.start_node(node_number)
    node = self.nodes[node_number]
    assert_equal(node.getblockcount(), 995)
    assert_raises_rpc_error((- 1), 'not in prune mode', node.pruneblockchain, 500)
    self.restart_node(node_number, extra_args=['-prune=1'])
    node = self.nodes[node_number]
    assert_equal(node.getblockcount(), 995)

    def height(index):
        if use_timestamp:
            return (node.getblockheader(node.getblockhash(index))['time'] + TIMESTAMP_WINDOW)
        else:
            return index

    def prune(index):
        ret = node.pruneblockchain(height=height(index))
        assert_equal(ret, node.getblockchaininfo()['pruneheight'])

    def has_block(index):
        return os.path.isfile(os.path.join(self.nodes[node_number].datadir, self.chain, 'blocks', f'blk{index:05}.dat'))
    assert_raises_rpc_error((- 1), 'Blockchain is too short for pruning', node.pruneblockchain, height(500))
    block1_details = node.getblock(node.getblockhash(1))
    assert_equal(block1_details['nTx'], len(block1_details['tx']))
    self.generate(node, 6)
    assert_equal(node.getblockchaininfo()['blocks'], 1001)
    assert_equal(node.getblockheader(node.getblockhash(1))['nTx'], block1_details['nTx'])
    assert_raises_rpc_error((- 8), 'Negative', node.pruneblockchain, (- 10))
    prune(100)
    assert has_block(0), 'blk00000.dat is missing when should still be there'
    node.pruneblockchain(height(0))
    assert has_block(0), 'blk00000.dat is missing when should still be there'
    prune(500)
    assert (not has_block(0)), 'blk00000.dat is still there, should be pruned by now'
    assert has_block(1), 'blk00001.dat is missing when should still be there'
    prune(650)
    assert (not has_block(1)), 'blk00001.dat is still there, should be pruned by now'
    prune(1000)
    assert has_block(2), 'blk00002.dat is still there, should be pruned by now'
    self.generate(node, 288)
    prune(1000)
    assert (not has_block(2)), 'blk00002.dat is still there, should be pruned by now'
    assert (not has_block(3)), 'blk00003.dat is still there, should be pruned by now'
    self.restart_node(node_number, extra_args=['-prune=550'])
    self.log.info('Success')