test_store_block PASSED

This commit is contained in:
andrei 2022-02-18 16:30:21 +02:00
parent 954363aaa1
commit ca6ebfae0b
2 changed files with 11 additions and 7 deletions

View File

@ -43,7 +43,8 @@ def _group_transaction_by_ids(txids: list, connection):
"inputs": [
{
"owners_before": _in[2],
"fulfills": {"transaction_id": _in[3], "output_index": int(_in[4])} if len(_in[3]) > 0 and len( # TODO Now it is working because of data type cast to INTEGER for field "output_index"
"fulfills": {"transaction_id": _in[3], "output_index": int(_in[4])} if len(_in[3]) > 0 and len(
# TODO Now it is working because of data type cast to INTEGER for field "output_index"
_in[4]) > 0 else None,
"fulfillment": _in[1]
} for _in in _txinputs
@ -307,7 +308,7 @@ def get_spending_transactions(inputs, connection):
# @register_query(LocalMongoDBConnection)
def get_block(block_id: str, connection):
def get_block(block_id=[], connection=None):
space = connection.space("blocks")
_block = space.select(block_id, index="block_search", limit=1)
_block = _block.data[0]

View File

@ -294,16 +294,19 @@ def test_get_spending_transactions_multiple_inputs():
def test_store_block():
from planetmint.backend import connect, query
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',
height=3,
transactions=[])
query.store_block(conn, block._asdict())
cursor = conn.db.blocks.find({}, projection={'_id': False})
assert cursor.collection.count_documents({}) == 1
query.store_block(connection=conn, block=block._asdict())
# block = query.get_block(connection=conn)
blocks = conn.space("blocks").select([])
assert len(blocks.data) == 1
def test_get_block():