From 96472d6bb9cef24d0cef1c3383d3f97dca6723ea Mon Sep 17 00:00:00 2001 From: andrei Date: Mon, 9 May 2022 12:03:23 +0300 Subject: [PATCH] test_integration.py -> fixed issue with block object --- planetmint/backend/tarantool/query.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/planetmint/backend/tarantool/query.py b/planetmint/backend/tarantool/query.py index f92dd87..5ba5f19 100644 --- a/planetmint/backend/tarantool/query.py +++ b/planetmint/backend/tarantool/query.py @@ -169,18 +169,19 @@ def get_latest_block(connection): # TODO Here is used DESCENDING OPERATOR space = connection.space("blocks") _all_blocks = space.select() _all_blocks = _all_blocks.data - hash = '' - heigth = 0 - txs = [] + block = {"app_hash": '', "height": 0, "transactions": []} + if len(_all_blocks) > 0: _block = sorted(_all_blocks, key=itemgetter(1), reverse=True)[0] space = connection.space("blocks_tx") _txids = space.select(_block[2], index="block_search") _txids = _txids.data - hash = _block[0] - heigth = _block[1] - txs = [tx[0] for tx in _txids] - return {"app_hash": hash, "height": heigth, "transactions": txs} + block["app_hash"] = _block[0] + block["height"] = _block[1] + block["transactions"] = [tx[0] for tx in _txids] + else: + block = None + return block @register_query(TarantoolDB)