コード例 #1
0
def test_register_store(database_manager: DatabaseManager):
    store_label = 'aaa'
    store = FakeSomething()

    assert database_manager.get_store(store_label) == None

    database_manager.register_new_store(store_label, store)

    assert database_manager.get_store(store_label) == store
コード例 #2
0
ファイル: conftest.py プロジェクト: nwyee/indy-node
def db_manager(tconf, tdir, idr_cache):
    db_manager = DatabaseManager()

    db_manager.register_new_store(IDR_CACHE_LABEL, idr_cache)
    db_manager.register_new_database(DOMAIN_LEDGER_ID, get_fake_ledger(),
                                     PruningState(KeyValueStorageInMemory()))
    db_manager.register_new_database(CONFIG_LEDGER_ID, get_fake_ledger(),
                                     PruningState(KeyValueStorageInMemory()))
    db_manager.register_new_database(POOL_LEDGER_ID, get_fake_ledger(),
                                     PruningState(KeyValueStorageInMemory()))
    return db_manager
コード例 #3
0
def database_manager(tdir_for_func):
    db = DatabaseManager()
    db.register_new_database(
        LEDGER_ID, Ledger(CompactMerkleTree(), dataDir=tdir_for_func),
        PruningState(KeyValueStorageRocksdb(tdir_for_func, 'kv1')))

    db.register_new_store(
        TS_LABEL,
        StateTsDbStorage('test',
                         {1: KeyValueStorageRocksdb(tdir_for_func, 'kv2')}))
    return db
コード例 #4
0
ファイル: conftest.py プロジェクト: louijose/indy-Dev
def db_manager(tconf, tdir):
    db_manager = DatabaseManager()
    name = 'name'
    idr_cache = IdrCache(
        name,
        initKeyValueStorage(KeyValueStorageType.Rocksdb,
                            tdir,
                            tconf.idrCacheDbName,
                            db_config=tconf.db_idr_cache_db_config))
    db_manager.register_new_store('idr', idr_cache)
    db_manager.register_new_database(DOMAIN_LEDGER_ID, get_fake_ledger(),
                                     State())
    return db_manager
コード例 #5
0
def test_common_stores(database_manager: DatabaseManager):
    common_stores = [BLS_LABEL, TS_LABEL, IDR_CACHE_LABEL, ATTRIB_LABEL]

    assert database_manager.bls_store is None
    assert database_manager.ts_store is None
    assert database_manager.idr_cache is None
    assert database_manager.attribute_store is None

    for label in common_stores:
        database_manager.register_new_store(label, FakeSomething())

    assert database_manager.bls_store is not None
    assert database_manager.ts_store is not None
    assert database_manager.idr_cache is not None
    assert database_manager.attribute_store is not None
コード例 #6
0
def db_manager(tconf, tdir):
    db_manager = DatabaseManager()

    state = State()
    state.txn_list = {}
    state.get = lambda key, isCommitted=True: state.txn_list.get(key, None)
    state.set = lambda key, value: state.txn_list.update({key: value})

    name = 'name'
    idr_cache = IdrCache(name,
                         initKeyValueStorage(KeyValueStorageType.Rocksdb,
                                             tdir,
                                             tconf.idrCacheDbName,
                                             db_config=tconf.db_idr_cache_db_config))
    db_manager.register_new_store(IDR_CACHE_LABEL, idr_cache)
    db_manager.register_new_database(DOMAIN_LEDGER_ID, get_fake_ledger(), state)
    return db_manager
コード例 #7
0
def create_test_write_req_manager(name: str,
                                  genesis_txns: List) -> WriteRequestManager:
    db_manager = DatabaseManager()
    write_manager = WriteRequestManager(db_manager)
    read_manager = ReadRequestManager()

    register_test_handler(write_manager)
    db_manager.register_new_store(SEQ_NO_DB_LABEL,
                                  ReqIdrToTxn(KeyValueStorageInMemory()))

    bootstrap = TestLedgersBootstrap(write_req_manager=write_manager,
                                     read_req_manager=read_manager,
                                     action_req_manager=FakeSomething(),
                                     name=name,
                                     config=getConfig(),
                                     ledger_ids=Node.ledger_ids)
    bootstrap.set_genesis_transactions(
        [txn for txn in genesis_txns if get_type(txn) == NODE],
        [txn for txn in genesis_txns if get_type(txn) == NYM])
    bootstrap.init()

    return write_manager
コード例 #8
0
ファイル: conftest.py プロジェクト: ken-ebert/indy-node
def db_manager(pool_state, domain_state, config_state, pool_ledger,
               domain_ledger, config_ledger, idr_cache_store, attrib_store,
               bls_store):
    dbm = DatabaseManager()
    dbm.register_new_database(POOL_LEDGER_ID, pool_ledger, pool_state)
    dbm.register_new_database(DOMAIN_LEDGER_ID, domain_ledger, domain_state)
    dbm.register_new_database(CONFIG_LEDGER_ID, config_ledger, config_state)
    dbm.register_new_store(IDR_CACHE_LABEL, idr_cache_store)
    dbm.register_new_store(ATTRIB_LABEL, attrib_store)
    dbm.register_new_store(BLS_LABEL, bls_store)
    return dbm