mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: we don't test the transaction split
Solution: undelete `test_store_transaction`
This commit is contained in:
parent
b20ad40908
commit
2c6c082f52
@ -183,6 +183,55 @@ def test_update_utxoset(tb, signed_create_tx, signed_transfer_tx, db_context):
|
||||
assert utxo['output_index'] == 0
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_store_transaction(mocker, tb, signed_create_tx,
|
||||
signed_transfer_tx, db_context):
|
||||
mocked_store_asset = mocker.patch('bigchaindb.backend.query.store_assets')
|
||||
mocked_store_metadata = mocker.patch(
|
||||
'bigchaindb.backend.query.store_metadatas')
|
||||
mocked_store_transaction = mocker.patch(
|
||||
'bigchaindb.backend.query.store_transactions')
|
||||
tb.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() == 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(
|
||||
tb.connection,
|
||||
[{'id': signed_create_tx.id, 'data': signed_create_tx.asset['data']}],
|
||||
)
|
||||
mocked_store_metadata.assert_called_once_with(
|
||||
tb.connection,
|
||||
[{'id': signed_create_tx.id, 'metadata': signed_create_tx.metadata}],
|
||||
)
|
||||
mocked_store_transaction.assert_called_once_with(
|
||||
tb.connection,
|
||||
[{k: v for k, v in signed_create_tx.to_dict().items()
|
||||
if k not in ('asset', 'metadata')}],
|
||||
)
|
||||
mocked_store_asset.reset_mock()
|
||||
mocked_store_metadata.reset_mock()
|
||||
mocked_store_transaction.reset_mock()
|
||||
tb.store_bulk_transactions([signed_transfer_tx])
|
||||
# assert utxoset.count() == 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(
|
||||
tb.connection,
|
||||
[{'id': signed_transfer_tx.id, 'metadata': signed_transfer_tx.metadata}],
|
||||
)
|
||||
mocked_store_transaction.assert_called_once_with(
|
||||
tb.connection,
|
||||
[{k: v for k, v in signed_transfer_tx.to_dict().items()
|
||||
if k != 'metadata'}],
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_store_bulk_transaction(mocker, tb, signed_create_tx,
|
||||
signed_transfer_tx, db_context):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user