mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-25 06:55:45 +00:00
separated asset test fixed
This commit is contained in:
parent
b1501ef51e
commit
51db31cf7c
@ -109,9 +109,10 @@ def get_metadata(connection, transaction_ids: list):
|
|||||||
_returned_data = []
|
_returned_data = []
|
||||||
space = connection.space("meta_data")
|
space = connection.space("meta_data")
|
||||||
for _id in transaction_ids:
|
for _id in transaction_ids:
|
||||||
metadata = space.select(_id, index="id_search")
|
metadata = space.select(_id, index="id_search").data
|
||||||
|
if len(metadata) > 0:
|
||||||
_returned_data.append(metadata)
|
_returned_data.append(metadata)
|
||||||
return _returned_data
|
return _returned_data if len(_returned_data) > 0 else None
|
||||||
|
|
||||||
|
|
||||||
@register_query(TarantoolDB)
|
@register_query(TarantoolDB)
|
||||||
@ -146,7 +147,7 @@ def get_asset(connection, asset_id: str):
|
|||||||
space = connection.space("assets")
|
space = connection.space("assets")
|
||||||
_data = space.select(asset_id, index="txid_search")
|
_data = space.select(asset_id, index="txid_search")
|
||||||
_data = _data.data
|
_data = _data.data
|
||||||
return _data[0] if len(_data) > 0 else []
|
return _data[0][0] if len(_data) > 0 else []
|
||||||
|
|
||||||
|
|
||||||
@register_query(TarantoolDB)
|
@register_query(TarantoolDB)
|
||||||
|
|||||||
@ -196,7 +196,9 @@ class TransactionCompose:
|
|||||||
def convert_to_dict(self):
|
def convert_to_dict(self):
|
||||||
transaction = {k: None for k in list(self._map.keys())}
|
transaction = {k: None for k in list(self._map.keys())}
|
||||||
transaction["id"] = self._get_transaction_id()
|
transaction["id"] = self._get_transaction_id()
|
||||||
|
if "asset" in transaction:
|
||||||
transaction["asset"] = self._get_asset()
|
transaction["asset"] = self._get_asset()
|
||||||
|
if "metadata" in transaction:
|
||||||
transaction["metadata"] = self._get_metadata()
|
transaction["metadata"] = self._get_metadata()
|
||||||
transaction["version"] = self._get_transaction_version()
|
transaction["version"] = self._get_transaction_version()
|
||||||
transaction["operation"] = self._get_transaction_operation()
|
transaction["operation"] = self._get_transaction_operation()
|
||||||
|
|||||||
@ -1170,8 +1170,8 @@ class Transaction(object):
|
|||||||
tx_body (dict): The Transaction to be transformed.
|
tx_body (dict): The Transaction to be transformed.
|
||||||
"""
|
"""
|
||||||
# NOTE: Remove reference to avoid side effects
|
# NOTE: Remove reference to avoid side effects
|
||||||
|
print(f"\nbefore deepcopy {tx_body}")
|
||||||
tx_body = deepcopy(tx_body)
|
tx_body = deepcopy(tx_body)
|
||||||
# print( f"\n tx body 1: {tx_body}")
|
|
||||||
tx_body = rapidjson.loads(rapidjson.dumps(tx_body))
|
tx_body = rapidjson.loads(rapidjson.dumps(tx_body))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -1181,13 +1181,8 @@ class Transaction(object):
|
|||||||
|
|
||||||
tx_body['id'] = None
|
tx_body['id'] = None
|
||||||
#tx_body = Transaction._remove_signatures(tx_body)
|
#tx_body = Transaction._remove_signatures(tx_body)
|
||||||
## print(f"\n\n tx_body3: {tx_body}")
|
|
||||||
tx_body_serialized = Transaction._to_str(tx_body)
|
tx_body_serialized = Transaction._to_str(tx_body)
|
||||||
valid_tx_id = Transaction._to_hash(tx_body_serialized)
|
valid_tx_id = Transaction._to_hash(tx_body_serialized)
|
||||||
# print( f"\n valid TX : {valid_tx_id}")
|
|
||||||
# print( f"\n proposed TX id : {proposed_tx_id}")
|
|
||||||
# print( f"\n tx body 2: {tx_body}")
|
|
||||||
# print( f"\n tx serialized : {tx_body_serialized}")
|
|
||||||
if proposed_tx_id != valid_tx_id:
|
if proposed_tx_id != valid_tx_id:
|
||||||
err_msg= ("The transaction's id '{}' isn't equal to "
|
err_msg= ("The transaction's id '{}' isn't equal to "
|
||||||
"the hash of its body, i.e. it's not valid.")
|
"the hash of its body, i.e. it's not valid.")
|
||||||
|
|||||||
@ -245,20 +245,19 @@ class Planetmint(object):
|
|||||||
|
|
||||||
def get_transaction(self, transaction_id):
|
def get_transaction(self, transaction_id):
|
||||||
transaction = backend.query.get_transaction(self.connection, transaction_id)
|
transaction = backend.query.get_transaction(self.connection, transaction_id)
|
||||||
# if transaction:
|
if transaction:
|
||||||
# asset = backend.query.get_asset(self.connection, transaction_id)
|
asset = backend.query.get_asset(self.connection, transaction_id)
|
||||||
# metadata = backend.query.get_metadata(self.connection, [transaction_id])
|
metadata = backend.query.get_metadata(self.connection, [transaction_id])
|
||||||
# if asset:
|
if asset:
|
||||||
# transaction['asset'] = asset
|
transaction['asset'] = asset
|
||||||
#
|
|
||||||
# if 'metadata' not in transaction:
|
if 'metadata' not in transaction:
|
||||||
# metadata = metadata[0] if metadata else None
|
metadata = metadata[0] if metadata else None
|
||||||
# if metadata:
|
if metadata:
|
||||||
# metadata = metadata.get('metadata')
|
metadata = metadata.get('metadata')
|
||||||
#
|
|
||||||
# transaction.update({'metadata': metadata})
|
transaction.update({'metadata': metadata})
|
||||||
#
|
|
||||||
# transaction = Transaction.from_dict(transaction)
|
|
||||||
transaction = Transaction.from_dict(transaction)
|
transaction = Transaction.from_dict(transaction)
|
||||||
|
|
||||||
return transaction
|
return transaction
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user