mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 14:35:45 +00:00
get_spending_transactions pass
This commit is contained in:
parent
1833c04810
commit
a3a3c3ab97
@ -43,7 +43,7 @@ def _group_transaction_by_ids(txids: list, connection):
|
|||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"owners_before": _in[2],
|
"owners_before": _in[2],
|
||||||
"fulfills": {"transaction_id": _in[3], "output_index": _in[4]} if len(_in[3]) > 0 and len(
|
"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,
|
_in[4]) > 0 else None,
|
||||||
"fulfillment": _in[1]
|
"fulfillment": _in[1]
|
||||||
} for _in in _txinputs
|
} for _in in _txinputs
|
||||||
|
|||||||
@ -218,7 +218,6 @@ def test_get_owned_ids(signed_create_tx, user_pk):
|
|||||||
|
|
||||||
# insert a transaction
|
# insert a transaction
|
||||||
query.store_transactions(connection=conn, signed_transactions=[signed_create_tx.to_dict()])
|
query.store_transactions(connection=conn, signed_transactions=[signed_create_tx.to_dict()])
|
||||||
# TODO add back asset from assets space for function group_by_txids + meta_data field
|
|
||||||
txns = list(query.get_owned_ids(connection=conn, owner=user_pk))
|
txns = list(query.get_owned_ids(connection=conn, owner=user_pk))
|
||||||
tx_dict = signed_create_tx.to_dict()
|
tx_dict = signed_create_tx.to_dict()
|
||||||
founded = [tx for tx in txns if tx["id"] == tx_dict["id"]]
|
founded = [tx for tx in txns if tx["id"] == tx_dict["id"]]
|
||||||
@ -226,9 +225,10 @@ def test_get_owned_ids(signed_create_tx, user_pk):
|
|||||||
|
|
||||||
|
|
||||||
def test_get_spending_transactions(user_pk, user_sk):
|
def test_get_spending_transactions(user_pk, user_sk):
|
||||||
from planetmint.backend import connect, query
|
|
||||||
from planetmint.models import Transaction
|
from planetmint.models import Transaction
|
||||||
conn = connect()
|
from planetmint.backend import connect
|
||||||
|
from planetmint.backend.tarantool import query
|
||||||
|
conn = connect().get_connection()
|
||||||
|
|
||||||
out = [([user_pk], 1)]
|
out = [([user_pk], 1)]
|
||||||
tx1 = Transaction.create([user_pk], out * 3)
|
tx1 = Transaction.create([user_pk], out * 3)
|
||||||
@ -238,10 +238,10 @@ def test_get_spending_transactions(user_pk, user_sk):
|
|||||||
tx3 = Transaction.transfer([inputs[1]], out, tx1.id).sign([user_sk])
|
tx3 = Transaction.transfer([inputs[1]], out, tx1.id).sign([user_sk])
|
||||||
tx4 = Transaction.transfer([inputs[2]], out, tx1.id).sign([user_sk])
|
tx4 = Transaction.transfer([inputs[2]], out, tx1.id).sign([user_sk])
|
||||||
txns = [deepcopy(tx.to_dict()) for tx in [tx1, tx2, tx3, tx4]]
|
txns = [deepcopy(tx.to_dict()) for tx in [tx1, tx2, tx3, tx4]]
|
||||||
conn.db.transactions.insert_many(txns)
|
query.store_transactions(signed_transactions=txns, connection=conn)
|
||||||
|
|
||||||
links = [inputs[0].fulfills.to_dict(), inputs[2].fulfills.to_dict()]
|
links = [inputs[0].fulfills.to_dict(), inputs[2].fulfills.to_dict()]
|
||||||
txns = list(query.get_spending_transactions(conn, links))
|
txns = list(query.get_spending_transactions(connection=conn, inputs=links))
|
||||||
|
|
||||||
# tx3 not a member because input 1 not asked for
|
# tx3 not a member because input 1 not asked for
|
||||||
assert txns == [tx2.to_dict(), tx4.to_dict()]
|
assert txns == [tx2.to_dict(), tx4.to_dict()]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user