mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 14:35:45 +00:00
fixed function from fast_query.py, problem was in deleteting functions
This commit is contained in:
parent
08c130492e
commit
7c4ca724f7
@ -308,9 +308,9 @@ def get_block_with_transaction(connection, txid: str):
|
||||
|
||||
@register_query(TarantoolDB)
|
||||
def delete_transactions(connection, txn_ids: list):
|
||||
space = connection.space("transactions")
|
||||
tx_space = connection.space("transactions")
|
||||
for _id in txn_ids:
|
||||
space.delete(_id)
|
||||
tx_space.delete(_id)
|
||||
inputs_space = connection.space("inputs")
|
||||
outputs_space = connection.space("outputs")
|
||||
k_space = connection.space("keys")
|
||||
@ -325,6 +325,13 @@ def delete_transactions(connection, txn_ids: list):
|
||||
for _outpID in _outputs:
|
||||
outputs_space.delete(_outpID[5], index="unique_search")
|
||||
|
||||
meta_space = connection.space("meta_data")
|
||||
for _id in txn_ids:
|
||||
meta_space.delete(_id, index="id_search")
|
||||
|
||||
assets_space = connection.space("assets")
|
||||
for _id in txn_ids:
|
||||
assets_space.delete(_id, index="txid_search")
|
||||
|
||||
# @register_query(TarantoolDB)
|
||||
# def store_unspent_outputs(conn, *unspent_outputs: list):
|
||||
|
||||
@ -8,7 +8,6 @@ import pytest
|
||||
from planetmint.common.transaction import TransactionLink
|
||||
from planetmint.models import Transaction
|
||||
|
||||
|
||||
pytestmark = pytest.mark.bdb
|
||||
|
||||
|
||||
@ -17,7 +16,7 @@ def txns(b, user_pk, user_sk, user2_pk, user2_sk):
|
||||
txs = [Transaction.create([user_pk], [([user2_pk], 1)]).sign([user_sk]),
|
||||
Transaction.create([user2_pk], [([user_pk], 1)]).sign([user2_sk]),
|
||||
Transaction.create([user_pk], [([user_pk], 1), ([user2_pk], 1)])
|
||||
.sign([user_sk])]
|
||||
.sign([user_sk])]
|
||||
b.store_bulk_transactions(txs)
|
||||
return txs
|
||||
|
||||
@ -78,11 +77,12 @@ def test_filter_unspent_outputs(b, user_pk, user_sk):
|
||||
|
||||
def test_outputs_query_key_order(b, user_pk, user_sk, user2_pk, user2_sk):
|
||||
from planetmint import backend
|
||||
from planetmint.backend import connect
|
||||
from planetmint.backend.connection import Connection
|
||||
from planetmint.backend import query
|
||||
|
||||
tx1 = Transaction.create([user_pk],
|
||||
[([user_pk], 3), ([user_pk], 2), ([user_pk], 1)])\
|
||||
.sign([user_sk])
|
||||
[([user_pk], 3), ([user_pk], 2), ([user_pk], 1)]) \
|
||||
.sign([user_sk])
|
||||
b.store_bulk_transactions([tx1])
|
||||
|
||||
inputs = tx1.to_inputs()
|
||||
@ -102,10 +102,12 @@ def test_outputs_query_key_order(b, user_pk, user_sk, user2_pk, user2_sk):
|
||||
assert len(outputs) == 1
|
||||
|
||||
# clean the transaction, metdata and asset collection
|
||||
conn = connect()
|
||||
conn.run(conn.collection('transactions').delete_many({}))
|
||||
conn.run(conn.collection('metadata').delete_many({}))
|
||||
conn.run(conn.collection('assets').delete_many({}))
|
||||
# conn = connect()
|
||||
connection = Connection()
|
||||
# conn.run(conn.collection('transactions').delete_many({}))
|
||||
# conn.run(conn.collection('metadata').delete_many({}))
|
||||
# conn.run(conn.collection('assets').delete_many({}))
|
||||
query.delete_transactions(connection, txn_ids=[tx1.id, tx2.id])
|
||||
|
||||
b.store_bulk_transactions([tx1])
|
||||
tx2_dict = tx2.to_dict()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user