Merge bec2abeb55daaeb376109279c2bb450b4efa74ca into 96932793b1c05ed809e186a1c1e17185fb1742cb

This commit is contained in:
Zachary Bowen 2018-08-31 13:27:41 +00:00 committed by GitHub
commit a4efdb2a1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 45 deletions

View File

@ -7,6 +7,7 @@
from pymongo import DESCENDING from pymongo import DESCENDING
from bigchaindb import backend from bigchaindb import backend
from bigchaindb.backend import exceptions
from bigchaindb.backend.exceptions import DuplicateKeyError from bigchaindb.backend.exceptions import DuplicateKeyError
from bigchaindb.backend.utils import module_dispatch_registrar from bigchaindb.backend.utils import module_dispatch_registrar
from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection
@ -227,8 +228,10 @@ def store_unspent_outputs(conn, *unspent_outputs):
ordered=False, ordered=False,
) )
) )
except DuplicateKeyError: except DuplicateKeyError as err:
# TODO log warning at least raise exceptions.DuplicateKeyError(
f'Duplicate key in transactions list {unspent_outputs}. Exception raised with error {err}'
)
pass pass

View File

@ -98,22 +98,6 @@ class BigchainDB(object):
return (500, 'Internal error') return (500, 'Internal error')
return (202, '') 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): def process_status_code(self, status_code, failure_msg):
return (202, '') if status_code == 0 else (500, failure_msg) return (202, '') if status_code == 0 else (500, failure_msg)

View File

@ -84,13 +84,6 @@ def test_deliver_tx__valid_create_updates_db(b, init_chain_request):
app.commit() app.commit()
assert b.get_transaction(tx.id).id == tx.id 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): def test_deliver_tx__double_spend_fails(b, init_chain_request):
from bigchaindb import App from bigchaindb import App

View File

@ -195,12 +195,6 @@ def test_store_transaction(mocker, b, signed_create_tx,
mocked_store_transaction = mocker.patch( mocked_store_transaction = mocker.patch(
'bigchaindb.backend.query.store_transactions') 'bigchaindb.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)
# 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( mocked_store_asset.assert_called_once_with(
b.connection, b.connection,
@ -219,10 +213,7 @@ 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() == 1
# utxo = utxoset.find_one()
# 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,
@ -245,12 +236,7 @@ def test_store_bulk_transaction(mocker, b, signed_create_tx,
mocked_store_transactions = mocker.patch( mocked_store_transactions = mocker.patch(
'bigchaindb.backend.query.store_transactions') 'bigchaindb.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)
# 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( mocked_store_assets.assert_called_once_with(
b.connection, b.connection,
[{'id': signed_create_tx.id, 'data': signed_create_tx.asset['data']}], [{'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_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() == 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,