diff --git a/bigchaindb/tendermint/lib.py b/bigchaindb/tendermint/lib.py index 3cf93ce5..66b568e2 100644 --- a/bigchaindb/tendermint/lib.py +++ b/bigchaindb/tendermint/lib.py @@ -41,10 +41,9 @@ class BigchainDB(Bigchain): # TODO: handle connection errors! requests.post(ENDPOINT, json=payload) - def write_transaction(self, transaction, **kwargs): + def write_transaction(self, transaction, **mode): # This method offers backward compatibility with the Web API. """Submit a valid transaction to the mempool.""" - mode = kwargs self.post_transaction(transaction, mode) def store_transaction(self, transaction): diff --git a/bigchaindb/web/views/transactions.py b/bigchaindb/web/views/transactions.py index e49cd189..e53058b4 100644 --- a/bigchaindb/web/views/transactions.py +++ b/bigchaindb/web/views/transactions.py @@ -56,10 +56,9 @@ class TransactionListApi(Resource): A ``dict`` containing the data about the transaction. """ parser = reqparse.RequestParser() - parser.add_argument('mode', type=parameters.valid_mode) + parser.add_argument('mode', type=parameters.valid_mode, + default='broadcast_tx_async') args = parser.parse_args() - if not str(args['mode']) or str(args['mode']) == 'None': - args['mode'] = 'broadcast_tx_async' pool = current_app.config['bigchain_pool'] diff --git a/tests/web/test_transactions.py b/tests/web/test_transactions.py index 39e1a00b..a67d790e 100644 --- a/tests/web/test_transactions.py +++ b/tests/web/test_transactions.py @@ -446,3 +446,5 @@ def test_post_transaction_invalid_mode(client): mode_endpoint = TX_ENDPOINT + '?mode=nope' response = client.post(mode_endpoint, data=json.dumps(tx.to_dict())) assert '400 BAD REQUEST' in response.status + assert 'Mode must be "async", "sync" or "commit"' ==\ + json.loads(response.data.decode('utf8'))['message']['mode']