import pytest
import time

from storage.kv_store_rocksdb import KeyValueStorageRocksdb
from state.pruning_state import PruningState
from ledger.compact_merkle_tree import CompactMerkleTree
from plenum.common.ledger import Ledger
from plenum.server.batch_handlers.batch_request_handler import BatchRequestHandler
from plenum.server.batch_handlers.three_pc_batch import ThreePcBatch

from plenum.test.common.test_database_manager import database_manager as db
from state.test.conftest import tempdir

LEDGER_ID = 1
FIXED_HASH = 'CMEcrTyug8SYVkLtR8qgjqx7NVEQ4xXuAvaJDDPhDu8n'


@pytest.fixture(scope='function')
def database_manager(db, tdir_for_func, tempdir):
    db.register_new_database(LEDGER_ID, Ledger(CompactMerkleTree(), dataDir=tdir_for_func), PruningState(
        KeyValueStorageRocksdb(tempdir, 'kv1')))
    return db


@pytest.fixture(scope='function')
def batch_handler(database_manager):
    return BatchRequestHandler(database_manager, LEDGER_ID)


@pytest.fixture(scope='function')
def three_pc_batch(batch_handler):
    # Constant root hash is one which will be formed after applying txn
    return ThreePcBatch(LEDGER_ID, 0, 0, 1, time.time(),
                        batch_handler.state.headHash,
                        FIXED_HASH,
                        ['a', 'b', 'c'], ['d1', 'd2', 'd3'])


def test_batch_handler_commit(batch_handler: BatchRequestHandler, three_pc_batch):
    assert len(batch_handler.ledger) == 0

    batch_handler.ledger.appendTxns([{'txnMetadata': {'seqNo': 1}}])
    batch_handler.commit_batch(three_pc_batch)

    assert len(batch_handler.ledger) == 1

    batch_handler._check_consistency_after_commit(FIXED_HASH)

@@ -20,16 +20,75 @@
 t time%0A%0A
+from plenum.server.database_manager import DatabaseManager%0A
 from sto
@@ -438,84 +438,8 @@
 ch%0A%0A
-from plenum.test.common.test_database_manager import database_manager as db%0A
 from
@@ -610,12 +610,8 @@
 ger(
-db, 
 tdir
@@ -627,24 +627,51 @@
 , tempdir):%0A
+    db = DatabaseManager()%0A
     db.regis

Test fix