diff --git a/bigchaindb/web/views/blocks.py b/bigchaindb/web/views/blocks.py index 6f63b5d7..4f185d12 100644 --- a/bigchaindb/web/views/blocks.py +++ b/bigchaindb/web/views/blocks.py @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 072b8725..ebb7aabe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/tests/web/test_blocks.py b/tests/web/test_blocks.py index 81bc80c3..c61bf27b 100644 --- a/tests/web/test_blocks.py +++ b/tests/web/test_blocks.py @@ -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)