mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
return empty list if no blocks found
This commit is contained in:
parent
f018a4f6e7
commit
3919cc3d5d
@ -58,8 +58,7 @@ class BlockListApi(Resource):
|
||||
if status:
|
||||
blocks = {k: v for k, v in blocks.items() if v == status}
|
||||
blocks = list(blocks.keys())
|
||||
|
||||
if not blocks:
|
||||
return make_error(404)
|
||||
else:
|
||||
blocks = []
|
||||
|
||||
return blocks
|
||||
|
@ -40,7 +40,7 @@ services:
|
||||
BIGCHAINDB_DATABASE_HOST: rdb
|
||||
BIGCHAINDB_SERVER_BIND: 0.0.0.0:9984
|
||||
ports:
|
||||
- "9984"
|
||||
- "9984:9984"
|
||||
command: bigchaindb start
|
||||
|
||||
bdb-mdb:
|
||||
|
@ -38,6 +38,11 @@ def test_get_blocks_by_txid_endpoint(b, client):
|
||||
tx2 = Transaction.create([b.me], [([b.me], 10)])
|
||||
tx2 = tx2.sign([b.me_private])
|
||||
|
||||
res = client.get(BLOCKS_ENDPOINT + "?tx_id=" + tx.id)
|
||||
# test if block is retrieved as undecided
|
||||
assert res.status_code == 200
|
||||
assert len(res.json) == 0
|
||||
|
||||
block_invalid = b.create_block([tx])
|
||||
b.write_block(block_invalid)
|
||||
|
||||
@ -123,12 +128,6 @@ def test_get_blocks_by_txid_and_status_endpoint(b, client):
|
||||
assert len(res.json) == 1
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_get_blocks_by_txid_endpoint_returns_404_if_not_found(client):
|
||||
res = client.get(BLOCKS_ENDPOINT + "?tx_id=123")
|
||||
assert res.status_code == 404
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_get_blocks_by_txid_endpoint_returns_400_bad_query_params(client):
|
||||
res = client.get(BLOCKS_ENDPOINT)
|
||||
|
Loading…
x
Reference in New Issue
Block a user