mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge pull request #2069 from bigchaindb/remove-all-statuses-endpoints-for-realz
Remove all code for all /statuses endpoints
This commit is contained in:
commit
5af6c7b7a3
@ -5,7 +5,6 @@ from bigchaindb.web.views import (
|
||||
metadata,
|
||||
blocks,
|
||||
info,
|
||||
statuses,
|
||||
transactions as tx,
|
||||
outputs,
|
||||
votes,
|
||||
@ -31,7 +30,6 @@ ROUTES_API_V1 = [
|
||||
r('metadata/', metadata.MetadataApi),
|
||||
r('blocks/<string:block_id>', blocks.BlockApi),
|
||||
r('blocks/', blocks.BlockListApi),
|
||||
r('statuses/', statuses.StatusApi),
|
||||
r('transactions/<string:tx_id>', tx.TransactionApi),
|
||||
r('transactions', tx.TransactionListApi),
|
||||
r('outputs/', outputs.OutputListApi),
|
||||
|
@ -46,7 +46,6 @@ def get_api_v1_info(api_prefix):
|
||||
return {
|
||||
'docs': ''.join(docs_url),
|
||||
'transactions': '{}transactions/'.format(api_prefix),
|
||||
'statuses': '{}statuses/'.format(api_prefix),
|
||||
'assets': '{}assets/'.format(api_prefix),
|
||||
'outputs': '{}outputs/'.format(api_prefix),
|
||||
'streams': websocket_root,
|
||||
|
@ -1,45 +0,0 @@
|
||||
"""This module provides the blueprint for the statuses API endpoints.
|
||||
|
||||
For more information please refer to the documentation: http://bigchaindb.com/http-api
|
||||
"""
|
||||
from flask import current_app
|
||||
from flask_restful import Resource, reqparse
|
||||
|
||||
from bigchaindb.web.views.base import make_error
|
||||
|
||||
|
||||
class StatusApi(Resource):
|
||||
def get(self):
|
||||
"""API endpoint to get details about the status of a transaction or a block.
|
||||
|
||||
Return:
|
||||
A ``dict`` in the format ``{'status': <status>}``, where
|
||||
``<status>`` is one of "valid", "invalid", "undecided", "backlog".
|
||||
"""
|
||||
parser = reqparse.RequestParser()
|
||||
parser.add_argument('transaction_id', type=str)
|
||||
parser.add_argument('block_id', type=str)
|
||||
|
||||
args = parser.parse_args(strict=True)
|
||||
tx_id = args['transaction_id']
|
||||
block_id = args['block_id']
|
||||
|
||||
# logical xor - exactly one query argument required
|
||||
if bool(tx_id) == bool(block_id):
|
||||
return make_error(400, 'Provide exactly one query parameter. Choices are: block_id, transaction_id')
|
||||
|
||||
pool = current_app.config['bigchain_pool']
|
||||
status = None
|
||||
|
||||
with pool() as bigchain:
|
||||
if tx_id:
|
||||
status = bigchain.get_status(tx_id)
|
||||
elif block_id:
|
||||
_, status = bigchain.get_block(block_id=block_id, include_status=True)
|
||||
|
||||
if not status:
|
||||
return make_error(404)
|
||||
|
||||
return {
|
||||
'status': status
|
||||
}
|
@ -13,7 +13,6 @@ def test_api_root_endpoint(client, wsserver_base_url):
|
||||
'v1': {
|
||||
'docs': ''.join(docs_url),
|
||||
'transactions': '/api/v1/transactions/',
|
||||
'statuses': '/api/v1/statuses/',
|
||||
'assets': '/api/v1/assets/',
|
||||
'outputs': '/api/v1/outputs/',
|
||||
'streams': '{}/api/v1/streams/valid_transactions'.format(
|
||||
@ -37,7 +36,6 @@ def test_api_v1_endpoint(client, wsserver_base_url):
|
||||
api_v1_info = {
|
||||
'docs': ''.join(docs_url),
|
||||
'transactions': '/transactions/',
|
||||
'statuses': '/statuses/',
|
||||
'assets': '/assets/',
|
||||
'outputs': '/outputs/',
|
||||
'streams': '{}/api/v1/streams/valid_transactions'.format(
|
||||
|
@ -1,94 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
STATUSES_ENDPOINT = '/api/v1/statuses'
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_get_transaction_status_endpoint(b, client, user_pk):
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
tx, status = b.get_transaction(input_tx.txid, include_status=True)
|
||||
res = client.get(STATUSES_ENDPOINT + '?transaction_id=' + input_tx.txid)
|
||||
assert status == res.json['status']
|
||||
assert res.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_get_transaction_status_endpoint_returns_404_if_not_found(client):
|
||||
res = client.get(STATUSES_ENDPOINT + '?transaction_id=123')
|
||||
assert res.status_code == 404
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_get_block_status_endpoint_undecided(b, client):
|
||||
tx = Transaction.create([b.me], [([b.me], 1)])
|
||||
tx = tx.sign([b.me_private])
|
||||
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block)
|
||||
|
||||
status = b.block_election_status(block)
|
||||
|
||||
res = client.get(STATUSES_ENDPOINT + '?block_id=' + block.id)
|
||||
assert status == res.json['status']
|
||||
assert res.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_get_block_status_endpoint_valid(b, client):
|
||||
tx = Transaction.create([b.me], [([b.me], 1)])
|
||||
tx = tx.sign([b.me_private])
|
||||
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block)
|
||||
|
||||
# vote the block valid
|
||||
vote = b.vote(block.id, b.get_last_voted_block().id, True)
|
||||
b.write_vote(vote)
|
||||
|
||||
status = b.block_election_status(block)
|
||||
|
||||
res = client.get(STATUSES_ENDPOINT + '?block_id=' + block.id)
|
||||
assert status == res.json['status']
|
||||
assert res.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_get_block_status_endpoint_invalid(b, client):
|
||||
tx = Transaction.create([b.me], [([b.me], 1)])
|
||||
tx = tx.sign([b.me_private])
|
||||
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block)
|
||||
|
||||
# vote the block valid
|
||||
vote = b.vote(block.id, b.get_last_voted_block().id, False)
|
||||
b.write_vote(vote)
|
||||
|
||||
status = b.block_election_status(block)
|
||||
|
||||
res = client.get(STATUSES_ENDPOINT + '?block_id=' + block.id)
|
||||
assert status == res.json['status']
|
||||
assert res.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_get_block_status_endpoint_returns_404_if_not_found(client):
|
||||
res = client.get(STATUSES_ENDPOINT + '?block_id=123')
|
||||
assert res.status_code == 404
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_get_status_endpoint_returns_400_bad_query_params(client):
|
||||
res = client.get(STATUSES_ENDPOINT)
|
||||
assert res.status_code == 400
|
||||
|
||||
res = client.get(STATUSES_ENDPOINT + '?ts_id=123')
|
||||
assert res.status_code == 400
|
||||
|
||||
res = client.get(STATUSES_ENDPOINT + '?transaction_id=123&block_id=123')
|
||||
assert res.status_code == 400
|
@ -44,9 +44,6 @@ def test_post_create_transaction_endpoint(b, client):
|
||||
|
||||
assert res.status_code == 202
|
||||
|
||||
assert '../statuses?transaction_id={}'.format(tx.id) in \
|
||||
res.headers['Location']
|
||||
|
||||
assert res.json['inputs'][0]['owners_before'][0] == user_pub
|
||||
assert res.json['outputs'][0]['public_keys'][0] == user_pub
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user