fixed get block test case

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2022-12-07 16:51:39 +01:00
parent adb85b7590
commit 10567fcc8d
No known key found for this signature in database
GPG Key ID: FA5EE906EB55316A
2 changed files with 3 additions and 3 deletions

View File

@ -238,7 +238,7 @@ def get_block(connection, block_id=None):
@register_query(TarantoolDBConnection) @register_query(TarantoolDBConnection)
def get_block_with_transaction(connection, txid: str): def get_block_with_transaction(connection, txid: str):
_block = connection.run(connection.space("blocks").select(txid, index="block_by_transaction_id")) _block = connection.run(connection.space("blocks").select(txid, index="block_by_transaction_id"))
return _block[0] if len(_block) == 1 else [] return _block if len(_block) > 0 else []
@register_query(TarantoolDBConnection) @register_query(TarantoolDBConnection)

View File

@ -59,8 +59,8 @@ def test_get_block_containing_transaction(b, client, alice):
block = Block(app_hash="random_utxo", height=13, transactions=[tx.id]) block = Block(app_hash="random_utxo", height=13, transactions=[tx.id])
b.store_block(block._asdict()) b.store_block(block._asdict())
res = client.get("{}?transaction_id={}".format(BLOCKS_ENDPOINT, tx.id)) res = client.get("{}?transaction_id={}".format(BLOCKS_ENDPOINT, tx.id))
expected_response = [block.height] expected_height = block.height
assert res.json == expected_response assert res.json[0][2] == expected_height
assert res.status_code == 200 assert res.status_code == 200