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,23 +170,29 @@ def test_update_utxoset(b, signed_create_tx, signed_transfer_tx, db_conn):
|
|||||||
@pytest.mark.bdb
|
@pytest.mark.bdb
|
||||||
def test_store_transaction(mocker, b, signed_create_tx,
|
def test_store_transaction(mocker, b, signed_create_tx,
|
||||||
signed_transfer_tx, db_context):
|
signed_transfer_tx, db_context):
|
||||||
|
from planetmint.backend.tarantool.connection import TarantoolDB
|
||||||
mocked_store_asset = mocker.patch('planetmint.backend.query.store_assets')
|
mocked_store_asset = mocker.patch('planetmint.backend.query.store_assets')
|
||||||
mocked_store_metadata = mocker.patch(
|
mocked_store_metadata = mocker.patch(
|
||||||
'planetmint.backend.query.store_metadatas')
|
'planetmint.backend.query.store_metadatas')
|
||||||
mocked_store_transaction = mocker.patch(
|
mocked_store_transaction = mocker.patch(
|
||||||
'planetmint.backend.query.store_transactions')
|
'planetmint.backend.query.store_transactions')
|
||||||
b.store_bulk_transactions([signed_create_tx])
|
b.store_bulk_transactions([signed_create_tx])
|
||||||
# mongo_client = MongoClient(host=db_context.host, port=db_context.port)
|
if not isinstance(b.connection, TarantoolDB):
|
||||||
# utxoset = mongo_client[db_context.name]['utxos']
|
mongo_client = MongoClient(host=db_context.host, port=db_context.port)
|
||||||
# assert utxoset.count_documents({}) == 1
|
utxoset = mongo_client[db_context.name]['utxos']
|
||||||
# utxo = utxoset.find_one()
|
assert utxoset.count_documents({}) == 1
|
||||||
# assert utxo['transaction_id'] == signed_create_tx.id
|
utxo = utxoset.find_one()
|
||||||
# assert utxo['output_index'] == 0
|
assert utxo['transaction_id'] == signed_create_tx.id
|
||||||
|
assert utxo['output_index'] == 0
|
||||||
mocked_store_asset.assert_called_once_with(
|
mocked_store_asset.assert_called_once_with(
|
||||||
b.connection,
|
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['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, 'tx_id': signed_create_tx.id, 'asset_id': signed_create_tx.id}]
|
||||||
|
)
|
||||||
mocked_store_metadata.assert_called_once_with(
|
mocked_store_metadata.assert_called_once_with(
|
||||||
b.connection,
|
b.connection,
|
||||||
[{'id': signed_create_tx.id, 'metadata': signed_create_tx.metadata}],
|
[{'id': signed_create_tx.id, 'metadata': signed_create_tx.metadata}],
|
||||||
@ -200,15 +206,17 @@ def test_store_transaction(mocker, b, signed_create_tx,
|
|||||||
mocked_store_metadata.reset_mock()
|
mocked_store_metadata.reset_mock()
|
||||||
mocked_store_transaction.reset_mock()
|
mocked_store_transaction.reset_mock()
|
||||||
b.store_bulk_transactions([signed_transfer_tx])
|
b.store_bulk_transactions([signed_transfer_tx])
|
||||||
# assert utxoset.count_documents({}) == 1
|
if not isinstance(b.connection, TarantoolDB):
|
||||||
# utxo = utxoset.find_one()
|
assert utxoset.count_documents({}) == 1
|
||||||
# assert utxo['transaction_id'] == signed_transfer_tx.id
|
utxo = utxoset.find_one()
|
||||||
# assert utxo['output_index'] == 0
|
assert utxo['transaction_id'] == signed_transfer_tx.id
|
||||||
|
assert utxo['output_index'] == 0
|
||||||
assert not mocked_store_asset.called
|
assert not mocked_store_asset.called
|
||||||
mocked_store_metadata.asser_called_once_with(
|
mocked_store_metadata.asser_called_once_with(
|
||||||
b.connection,
|
b.connection,
|
||||||
[{'id': signed_transfer_tx.id, 'metadata': signed_transfer_tx.metadata}],
|
[{'id': signed_transfer_tx.id, 'metadata': signed_transfer_tx.metadata}],
|
||||||
)
|
)
|
||||||
|
if not isinstance(b.connection, TarantoolDB):
|
||||||
mocked_store_transaction.assert_called_once_with(
|
mocked_store_transaction.assert_called_once_with(
|
||||||
b.connection,
|
b.connection,
|
||||||
[{k: v for k, v in signed_transfer_tx.to_dict().items()
|
[{k: v for k, v in signed_transfer_tx.to_dict().items()
|
||||||
@ -227,12 +235,13 @@ def test_store_bulk_transaction(mocker, b, signed_create_tx,
|
|||||||
mocked_store_transactions = mocker.patch(
|
mocked_store_transactions = mocker.patch(
|
||||||
'planetmint.backend.query.store_transactions')
|
'planetmint.backend.query.store_transactions')
|
||||||
b.store_bulk_transactions((signed_create_tx,))
|
b.store_bulk_transactions((signed_create_tx,))
|
||||||
# mongo_client = MongoClient(host=db_context.host, port=db_context.port)
|
if not isinstance(b.connection, TarantoolDB):
|
||||||
# utxoset = mongo_client[db_context.name]['utxos']
|
mongo_client = MongoClient(host=db_context.host, port=db_context.port)
|
||||||
# assert utxoset.count_documents({}) == 1
|
utxoset = mongo_client[db_context.name]['utxos']
|
||||||
# utxo = utxoset.find_one()
|
assert utxoset.count_documents({}) == 1
|
||||||
# assert utxo['transaction_id'] == signed_create_tx.id
|
utxo = utxoset.find_one()
|
||||||
# assert utxo['output_index'] == 0
|
assert utxo['transaction_id'] == signed_create_tx.id
|
||||||
|
assert utxo['output_index'] == 0
|
||||||
if isinstance(b.connection, TarantoolDB):
|
if isinstance(b.connection, TarantoolDB):
|
||||||
mocked_store_assets.assert_called_once_with(
|
mocked_store_assets.assert_called_once_with(
|
||||||
b.connection, # signed_create_tx.asset['data'] this was before
|
b.connection, # signed_create_tx.asset['data'] this was before
|
||||||
@ -256,17 +265,18 @@ def test_store_bulk_transaction(mocker, b, signed_create_tx,
|
|||||||
mocked_store_metadata.reset_mock()
|
mocked_store_metadata.reset_mock()
|
||||||
mocked_store_transactions.reset_mock()
|
mocked_store_transactions.reset_mock()
|
||||||
b.store_bulk_transactions((signed_transfer_tx,))
|
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):
|
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
|
assert not mocked_store_assets.called
|
||||||
mocked_store_metadata.asser_called_once_with(
|
mocked_store_metadata.asser_called_once_with(
|
||||||
b.connection,
|
b.connection,
|
||||||
[{'id': signed_transfer_tx.id,
|
[{'id': signed_transfer_tx.id,
|
||||||
'metadata': signed_transfer_tx.metadata}],
|
'metadata': signed_transfer_tx.metadata}],
|
||||||
)
|
)
|
||||||
|
if not isinstance(b.connection, TarantoolDB):
|
||||||
mocked_store_transactions.assert_called_once_with(
|
mocked_store_transactions.assert_called_once_with(
|
||||||
b.connection,
|
b.connection,
|
||||||
[{k: v for k, v in signed_transfer_tx.to_dict().items()
|
[{k: v for k, v in signed_transfer_tx.to_dict().items()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user