return empty list if no blocks found

This commit is contained in:
diminator 2017-01-12 16:36:13 +01:00 committed by Brett Sun
parent f018a4f6e7
commit 3919cc3d5d
3 changed files with 8 additions and 10 deletions

View File

@ -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

View File

@ -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:

View File

@ -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)