コード例 #1
0
ファイル: test_queries.py プロジェクト: workbgm/bigchaindb
def test_write_metadata():
    from bigchaindb.backend import connect, query
    conn = connect()

    metadata = [
        {'id': 1, 'data': '1'},
        {'id': 2, 'data': '2'},
        {'id': 3, 'data': '3'}
    ]

    # write the assets
    query.store_metadatas(conn, deepcopy(metadata))

    # check that 3 assets were written to the database
    cursor = conn.db.metadata.find({}, projection={'_id': False})\
                             .sort('id', pymongo.ASCENDING)

    assert cursor.count() == 3
    assert list(cursor) == metadata
コード例 #2
0
ファイル: test_queries.py プロジェクト: vrde/bigchaindb
def test_write_metadata():
    from bigchaindb.backend import connect, query
    conn = connect()

    metadata = [
        {'id': 1, 'data': '1'},
        {'id': 2, 'data': '2'},
        {'id': 3, 'data': '3'}
    ]

    # write the assets
    query.store_metadatas(conn, deepcopy(metadata))

    # check that 3 assets were written to the database
    cursor = conn.db.metadata.find({}, projection={'_id': False})\
                             .sort('id', pymongo.ASCENDING)

    assert cursor.count() == 3
    assert list(cursor) == metadata
コード例 #3
0
def test_delete_zombie_transactions(signed_create_tx, signed_transfer_tx):
    from bigchaindb.backend import connect, query
    from bigchaindb.tendermint.lib import Block
    conn = connect()

    conn.db.transactions.insert_one(signed_create_tx.to_dict())
    query.store_asset(conn, {'id': signed_create_tx.id})
    block = Block(app_hash='random_utxo',
                  height=3,
                  transactions=[signed_create_tx.id])
    query.store_block(conn, block._asdict())

    conn.db.transactions.insert_one(signed_transfer_tx.to_dict())
    query.store_metadatas(conn, [{'id': signed_transfer_tx.id}])

    query.delete_zombie_transactions(conn)
    assert query.get_transaction(conn, signed_transfer_tx.id) is None
    assert query.get_asset(conn, signed_transfer_tx.id) is None
    assert list(query.get_metadata(conn, [signed_transfer_tx.id])) == []

    assert query.get_transaction(conn, signed_create_tx.id) is not None
    assert query.get_asset(conn, signed_create_tx.id) is not None