mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 22:45:44 +00:00
test_get_block PASSED
This commit is contained in:
parent
ca6ebfae0b
commit
c6feac5754
@ -312,6 +312,7 @@ def get_block(block_id=[], connection=None):
|
|||||||
space = connection.space("blocks")
|
space = connection.space("blocks")
|
||||||
_block = space.select(block_id, index="block_search", limit=1)
|
_block = space.select(block_id, index="block_search", limit=1)
|
||||||
_block = _block.data[0]
|
_block = _block.data[0]
|
||||||
|
space = connection.space("blocks_tx")
|
||||||
_txblock = space.select(_block[2], index="block_search")
|
_txblock = space.select(_block[2], index="block_search")
|
||||||
_txblock = _txblock.data
|
_txblock = _txblock.data
|
||||||
return {"app_hash": _block[0], "height": _block[1], "transactions": [_tx[0] for _tx in _txblock]}
|
return {"app_hash": _block[0], "height": _block[1], "transactions": [_tx[0] for _tx in _txblock]}
|
||||||
|
|||||||
@ -310,17 +310,19 @@ def test_store_block():
|
|||||||
|
|
||||||
|
|
||||||
def test_get_block():
|
def test_get_block():
|
||||||
from planetmint.backend import connect, query
|
|
||||||
from planetmint.lib import Block
|
from planetmint.lib import Block
|
||||||
conn = connect()
|
from planetmint.backend import connect
|
||||||
|
from planetmint.backend.tarantool import query
|
||||||
|
|
||||||
|
conn = connect().get_connection()
|
||||||
|
|
||||||
block = Block(app_hash='random_utxo',
|
block = Block(app_hash='random_utxo',
|
||||||
height=3,
|
height=3,
|
||||||
transactions=[])
|
transactions=[])
|
||||||
|
|
||||||
conn.db.blocks.insert_one(block._asdict())
|
query.store_block(connection=conn, block=block._asdict())
|
||||||
|
|
||||||
block = dict(query.get_block(conn, 3))
|
block = dict(query.get_block(connection=conn, block_id=3))
|
||||||
assert block['height'] == 3
|
assert block['height'] == 3
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user