mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge bec2abeb55daaeb376109279c2bb450b4efa74ca into 96932793b1c05ed809e186a1c1e17185fb1742cb
This commit is contained in:
commit
a4efdb2a1e
@ -7,6 +7,7 @@
|
||||
from pymongo import DESCENDING
|
||||
|
||||
from bigchaindb import backend
|
||||
from bigchaindb.backend import exceptions
|
||||
from bigchaindb.backend.exceptions import DuplicateKeyError
|
||||
from bigchaindb.backend.utils import module_dispatch_registrar
|
||||
from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection
|
||||
@ -227,8 +228,10 @@ def store_unspent_outputs(conn, *unspent_outputs):
|
||||
ordered=False,
|
||||
)
|
||||
)
|
||||
except DuplicateKeyError:
|
||||
# TODO log warning at least
|
||||
except DuplicateKeyError as err:
|
||||
raise exceptions.DuplicateKeyError(
|
||||
f'Duplicate key in transactions list {unspent_outputs}. Exception raised with error {err}'
|
||||
)
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@ -98,22 +98,6 @@ class BigchainDB(object):
|
||||
return (500, 'Internal error')
|
||||
|
||||
return (202, '')
|
||||
# result = response['result']
|
||||
# if mode == self.mode_list[2]:
|
||||
# return self._process_commit_mode_response(result)
|
||||
# else:
|
||||
# status_code = result['code']
|
||||
# return self._process_status_code(status_code,
|
||||
# 'Error while processing transaction')
|
||||
|
||||
# def _process_commit_mode_response(self, result):
|
||||
# check_tx_status_code = result['check_tx']['code']
|
||||
# if check_tx_status_code == 0:
|
||||
# deliver_tx_status_code = result['deliver_tx']['code']
|
||||
# return self._process_status_code(deliver_tx_status_code,
|
||||
# 'Error while commiting the transaction')
|
||||
# else:
|
||||
# return (500, 'Error while validating the transaction')
|
||||
|
||||
def process_status_code(self, status_code, failure_msg):
|
||||
return (202, '') if status_code == 0 else (500, failure_msg)
|
||||
|
||||
@ -84,13 +84,6 @@ def test_deliver_tx__valid_create_updates_db(b, init_chain_request):
|
||||
app.commit()
|
||||
assert b.get_transaction(tx.id).id == tx.id
|
||||
|
||||
# unspent_outputs = b.get_unspent_outputs()
|
||||
# unspent_output = next(unspent_outputs)
|
||||
# expected_unspent_output = next(tx.unspent_outputs)._asdict()
|
||||
# assert unspent_output == expected_unspent_output
|
||||
# with pytest.raises(StopIteration):
|
||||
# next(unspent_outputs)
|
||||
|
||||
|
||||
def test_deliver_tx__double_spend_fails(b, init_chain_request):
|
||||
from bigchaindb import App
|
||||
|
||||
@ -195,12 +195,6 @@ def test_store_transaction(mocker, b, signed_create_tx,
|
||||
mocked_store_transaction = mocker.patch(
|
||||
'bigchaindb.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() == 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,
|
||||
@ -219,10 +213,7 @@ 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() == 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,
|
||||
@ -245,12 +236,7 @@ def test_store_bulk_transaction(mocker, b, signed_create_tx,
|
||||
mocked_store_transactions = mocker.patch(
|
||||
'bigchaindb.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() == 1
|
||||
# utxo = utxoset.find_one()
|
||||
# assert utxo['transaction_id'] == signed_create_tx.id
|
||||
# assert utxo['output_index'] == 0
|
||||
|
||||
mocked_store_assets.assert_called_once_with(
|
||||
b.connection,
|
||||
[{'id': signed_create_tx.id, 'data': signed_create_tx.asset['data']}],
|
||||
@ -268,10 +254,7 @@ 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() == 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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user