mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-25 06:55:45 +00:00
test_store_bulk_transaction -> adopted for tarantool
This commit is contained in:
parent
0f6df2b393
commit
3b3639b914
@ -170,22 +170,28 @@ def test_update_utxoset(b, signed_create_tx, signed_transfer_tx, db_conn):
|
||||
@pytest.mark.bdb
|
||||
def test_store_transaction(mocker, b, signed_create_tx,
|
||||
signed_transfer_tx, db_context):
|
||||
from planetmint.backend.tarantool.connection import TarantoolDB
|
||||
mocked_store_asset = mocker.patch('planetmint.backend.query.store_assets')
|
||||
mocked_store_metadata = mocker.patch(
|
||||
'planetmint.backend.query.store_metadatas')
|
||||
mocked_store_transaction = mocker.patch(
|
||||
'planetmint.backend.query.store_transactions')
|
||||
b.store_bulk_transactions([signed_create_tx])
|
||||
# mongo_client = MongoClient(host=db_context.host, port=db_context.port)
|
||||
# utxoset = mongo_client[db_context.name]['utxos']
|
||||
# assert utxoset.count_documents({}) == 1
|
||||
# utxo = utxoset.find_one()
|
||||
# assert utxo['transaction_id'] == signed_create_tx.id
|
||||
# assert utxo['output_index'] == 0
|
||||
if not isinstance(b.connection, TarantoolDB):
|
||||
mongo_client = MongoClient(host=db_context.host, port=db_context.port)
|
||||
utxoset = mongo_client[db_context.name]['utxos']
|
||||
assert utxoset.count_documents({}) == 1
|
||||
utxo = utxoset.find_one()
|
||||
assert utxo['transaction_id'] == signed_create_tx.id
|
||||
assert utxo['output_index'] == 0
|
||||
mocked_store_asset.assert_called_once_with(
|
||||
b.connection,
|
||||
[{'data': signed_create_tx.asset['data'], 'tx_id': signed_create_tx.id, 'asset_id': signed_create_tx.id}]
|
||||
)
|
||||
|
||||
mocked_store_asset.assert_called_once_with(
|
||||
b.connection,
|
||||
[{'data': signed_create_tx.asset['data'], 'tx_id': signed_create_tx.id, 'asset_id': signed_create_tx.id}]
|
||||
[{'data': signed_create_tx.asset, 'tx_id': signed_create_tx.id, 'asset_id': signed_create_tx.id}]
|
||||
)
|
||||
mocked_store_metadata.assert_called_once_with(
|
||||
b.connection,
|
||||
@ -200,20 +206,22 @@ def test_store_transaction(mocker, b, signed_create_tx,
|
||||
mocked_store_metadata.reset_mock()
|
||||
mocked_store_transaction.reset_mock()
|
||||
b.store_bulk_transactions([signed_transfer_tx])
|
||||
# assert utxoset.count_documents({}) == 1
|
||||
# utxo = utxoset.find_one()
|
||||
# assert utxo['transaction_id'] == signed_transfer_tx.id
|
||||
# assert utxo['output_index'] == 0
|
||||
assert not mocked_store_asset.called
|
||||
if not isinstance(b.connection, TarantoolDB):
|
||||
assert utxoset.count_documents({}) == 1
|
||||
utxo = utxoset.find_one()
|
||||
assert utxo['transaction_id'] == signed_transfer_tx.id
|
||||
assert utxo['output_index'] == 0
|
||||
assert not mocked_store_asset.called
|
||||
mocked_store_metadata.asser_called_once_with(
|
||||
b.connection,
|
||||
[{'id': signed_transfer_tx.id, 'metadata': signed_transfer_tx.metadata}],
|
||||
)
|
||||
mocked_store_transaction.assert_called_once_with(
|
||||
b.connection,
|
||||
[{k: v for k, v in signed_transfer_tx.to_dict().items()
|
||||
if k != 'metadata'}],
|
||||
)
|
||||
if not isinstance(b.connection, TarantoolDB):
|
||||
mocked_store_transaction.assert_called_once_with(
|
||||
b.connection,
|
||||
[{k: v for k, v in signed_transfer_tx.to_dict().items()
|
||||
if k != 'metadata'}],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@ -227,12 +235,13 @@ def test_store_bulk_transaction(mocker, b, signed_create_tx,
|
||||
mocked_store_transactions = mocker.patch(
|
||||
'planetmint.backend.query.store_transactions')
|
||||
b.store_bulk_transactions((signed_create_tx,))
|
||||
# mongo_client = MongoClient(host=db_context.host, port=db_context.port)
|
||||
# utxoset = mongo_client[db_context.name]['utxos']
|
||||
# assert utxoset.count_documents({}) == 1
|
||||
# utxo = utxoset.find_one()
|
||||
# assert utxo['transaction_id'] == signed_create_tx.id
|
||||
# assert utxo['output_index'] == 0
|
||||
if not isinstance(b.connection, TarantoolDB):
|
||||
mongo_client = MongoClient(host=db_context.host, port=db_context.port)
|
||||
utxoset = mongo_client[db_context.name]['utxos']
|
||||
assert utxoset.count_documents({}) == 1
|
||||
utxo = utxoset.find_one()
|
||||
assert utxo['transaction_id'] == signed_create_tx.id
|
||||
assert utxo['output_index'] == 0
|
||||
if isinstance(b.connection, TarantoolDB):
|
||||
mocked_store_assets.assert_called_once_with(
|
||||
b.connection, # signed_create_tx.asset['data'] this was before
|
||||
@ -256,22 +265,23 @@ def test_store_bulk_transaction(mocker, b, signed_create_tx,
|
||||
mocked_store_metadata.reset_mock()
|
||||
mocked_store_transactions.reset_mock()
|
||||
b.store_bulk_transactions((signed_transfer_tx,))
|
||||
# assert utxoset.count_documents({}) == 1
|
||||
# utxo = utxoset.find_one()
|
||||
# assert utxo['transaction_id'] == signed_transfer_tx.id
|
||||
# assert utxo['output_index'] == 0
|
||||
if not isinstance(b.connection, TarantoolDB):
|
||||
assert utxoset.count_documents({}) == 1
|
||||
utxo = utxoset.find_one()
|
||||
assert utxo['transaction_id'] == signed_transfer_tx.id
|
||||
assert utxo['output_index'] == 0
|
||||
assert not mocked_store_assets.called
|
||||
mocked_store_metadata.asser_called_once_with(
|
||||
b.connection,
|
||||
[{'id': signed_transfer_tx.id,
|
||||
'metadata': signed_transfer_tx.metadata}],
|
||||
)
|
||||
mocked_store_transactions.assert_called_once_with(
|
||||
b.connection,
|
||||
[{k: v for k, v in signed_transfer_tx.to_dict().items()
|
||||
if k != 'metadata'}],
|
||||
)
|
||||
if not isinstance(b.connection, TarantoolDB):
|
||||
mocked_store_transactions.assert_called_once_with(
|
||||
b.connection,
|
||||
[{k: v for k, v in signed_transfer_tx.to_dict().items()
|
||||
if k != 'metadata'}],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user