mirror of
https://github.com/planetmint/planetmint.git
synced 2025-03-30 15:08:31 +00:00
removed deprecated query and test cases
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
a7d8a8e9f5
commit
e62e4231a6
@ -167,21 +167,6 @@ def delete_transactions(conn, txn_ids):
|
||||
conn.run(conn.collection("transactions").delete_many({"id": {"$in": txn_ids}}))
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def store_unspent_outputs(conn, *unspent_outputs):
|
||||
if unspent_outputs:
|
||||
try:
|
||||
return conn.run(
|
||||
conn.collection("utxos").insert_many(
|
||||
unspent_outputs,
|
||||
ordered=False,
|
||||
)
|
||||
)
|
||||
except DuplicateKeyError:
|
||||
# TODO log warning at least
|
||||
pass
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def delete_unspent_outputs(conn, *unspent_outputs):
|
||||
if unspent_outputs:
|
||||
|
@ -264,13 +264,6 @@ def store_block(conn, block):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@singledispatch
|
||||
def store_unspent_outputs(connection, unspent_outputs):
|
||||
"""Store unspent outputs in ``utxo_set`` table."""
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@singledispatch
|
||||
def delete_unspent_outputs(connection, unspent_outputs):
|
||||
"""Delete unspent outputs in ``utxo_set`` table."""
|
||||
|
@ -342,25 +342,6 @@ def delete_transactions(connection, txn_ids: list):
|
||||
connection.connect().delete(TARANT_TABLE_GOVERNANCE, _id)
|
||||
|
||||
|
||||
@register_query(TarantoolDBConnection)
|
||||
@catch_db_exception
|
||||
def store_unspent_outputs(connection, *unspent_outputs: list):
|
||||
result = []
|
||||
if unspent_outputs:
|
||||
for utxo in unspent_outputs:
|
||||
try:
|
||||
output = (
|
||||
connection.connect()
|
||||
.insert(TARANT_TABLE_UTXOS, (uuid4().hex, utxo["transaction_id"], utxo["output_index"], utxo))
|
||||
.data
|
||||
)
|
||||
result.append(output)
|
||||
except Exception as e:
|
||||
logger.info(f"Could not insert unspent output: {e}")
|
||||
raise OperationDataInsertionError()
|
||||
return result
|
||||
|
||||
|
||||
@register_query(TarantoolDBConnection)
|
||||
@catch_db_exception
|
||||
def delete_unspent_outputs(connection, unspent_outputs: list):
|
||||
|
@ -223,50 +223,6 @@ def test_delete_many_unspent_outputs(b, dummy_unspent_outputs):
|
||||
assert len(res3) == 1
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_store_zero_unspent_output(b):
|
||||
utxos = b.models.connection.get_space("utxos")
|
||||
num_rows_before_operation = utxos.select().rowcount
|
||||
res = store_unspent_outputs(b.models.connection)
|
||||
num_rows_after_operation = utxos.select().rowcount
|
||||
assert res is None
|
||||
assert num_rows_before_operation == num_rows_after_operation
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_store_one_unspent_output(b, unspent_output_1, utxo_collection):
|
||||
from planetmint.backend.tarantool.sync_io.connection import TarantoolDBConnection
|
||||
|
||||
res = store_unspent_outputs(b.models.connection, unspent_output_1)
|
||||
if not isinstance(b.models.connection, TarantoolDBConnection):
|
||||
assert res.acknowledged
|
||||
assert len(list(res)) == 1
|
||||
assert (
|
||||
utxo_collection.count_documents(
|
||||
{
|
||||
"transaction_id": unspent_output_1["transaction_id"],
|
||||
"output_index": unspent_output_1["output_index"],
|
||||
}
|
||||
)
|
||||
== 1
|
||||
)
|
||||
else:
|
||||
utx_space = b.models.connection.get_space("utxos")
|
||||
res = utx_space.select(
|
||||
[unspent_output_1["transaction_id"], unspent_output_1["output_index"]],
|
||||
index="utxo_by_transaction_id_and_output_index",
|
||||
)
|
||||
assert len(res.data) == 1
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_store_many_unspent_outputs(b, unspent_outputs):
|
||||
store_unspent_outputs(b.models.connection, *unspent_outputs)
|
||||
utxo_space = b.models.connection.get_space("utxos")
|
||||
res = utxo_space.select([unspent_outputs[0]["transaction_id"]], index="utxos_by_transaction_id")
|
||||
assert len(res.data) == 3
|
||||
|
||||
|
||||
def test_get_utxoset_merkle_root_when_no_utxo(b):
|
||||
assert get_utxoset_merkle_root(b.models.connection) == sha3_256(b"").hexdigest()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user