mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-25 06:55:45 +00:00
resolved merge conflicts
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
commit
e239368c66
@ -17,6 +17,7 @@ from json import dumps, loads
|
||||
|
||||
register_query = module_dispatch_registrar(query)
|
||||
|
||||
|
||||
@register_query(TarantoolDBConnection)
|
||||
def _group_transaction_by_ids(connection, txids: list):
|
||||
_transactions = []
|
||||
@ -53,24 +54,42 @@ def store_transactions(connection, signed_transactions: list):
|
||||
txprepare = TransactionDecompose(transaction)
|
||||
txtuples = txprepare.convert_to_tuple()
|
||||
try:
|
||||
connection.run(connection.space("transactions").insert(txtuples["transactions"]))
|
||||
connection.run(
|
||||
connection.space("transactions").insert(txtuples["transactions"]),
|
||||
only_data=False
|
||||
)
|
||||
except: # This is used for omitting duplicate error in database for test -> test_bigchain_api::test_double_inclusion
|
||||
continue
|
||||
|
||||
for _in in txtuples["inputs"]:
|
||||
connection.run(connection.space("inputs").insert(_in))
|
||||
connection.run(
|
||||
connection.space("inputs").insert(_in),
|
||||
only_data=False
|
||||
)
|
||||
|
||||
for _out in txtuples["outputs"]:
|
||||
connection.run(connection.space("outputs").insert(_out))
|
||||
connection.run(
|
||||
connection.space("outputs").insert(_out),
|
||||
only_data=False
|
||||
)
|
||||
|
||||
for _key in txtuples["keys"]:
|
||||
connection.run(connection.space("keys").insert(_key))
|
||||
connection.run(
|
||||
connection.space("keys").insert(_key),
|
||||
only_data=False
|
||||
)
|
||||
|
||||
if txtuples["metadata"] is not None:
|
||||
connection.run(connection.space("meta_data").insert(txtuples["metadata"]))
|
||||
connection.run(
|
||||
connection.space("meta_data").insert(txtuples["metadata"]),
|
||||
only_data=False
|
||||
)
|
||||
|
||||
if txtuples["asset"] is not None:
|
||||
connection.run(connection.space("asset").insert(txtuples["asset"]))
|
||||
connection.run(
|
||||
connection.space("assets").insert(txtuples["asset"]),
|
||||
only_data=False
|
||||
)
|
||||
|
||||
|
||||
@register_query(TarantoolDBConnection)
|
||||
@ -485,7 +504,8 @@ def get_election(connection, election_id: str):
|
||||
|
||||
|
||||
@register_query(TarantoolDBConnection)
|
||||
def get_asset_tokens_for_public_key(connection, asset_id: str, public_key: str): # FIXME Something can be wrong with this function ! (public_key) is not used
|
||||
def get_asset_tokens_for_public_key(connection, asset_id: str,
|
||||
public_key: str): # FIXME Something can be wrong with this function ! (public_key) is not used
|
||||
# space = connection.space("keys")
|
||||
# _keys = space.select([public_key], index="keys_search")
|
||||
_transactions = connection.run(
|
||||
|
||||
@ -91,7 +91,7 @@ def test_bigchain_show_config(capsys):
|
||||
|
||||
def test__run_init(mocker):
|
||||
init_db_mock = mocker.patch(
|
||||
'planetmint.backend.tarantool.connection.TarantoolDB.init_database')
|
||||
'planetmint.backend.tarantool.connection.TarantoolDBConnection.init_database')
|
||||
|
||||
from planetmint.backend.connection import connect
|
||||
|
||||
|
||||
@ -553,7 +553,7 @@ def tarantool_client(db_context): # TODO Here add TarantoolConnectionClass
|
||||
|
||||
@pytest.fixture
|
||||
def utxo_collection(tarantool_client):
|
||||
return tarantool_client.space("utxos")
|
||||
return tarantool_client.get_space("utxos")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@ -30,11 +30,9 @@ def test_asset_is_separated_from_transaciton(b):
|
||||
from planetmint.transactions.common.crypto import generate_key_pair
|
||||
from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
||||
|
||||
|
||||
if isinstance(b.connection, TarantoolDBConnection):
|
||||
pytest.skip("This specific function is skipped because, assets are stored differently if using Tarantool")
|
||||
|
||||
|
||||
alice = generate_key_pair()
|
||||
bob = generate_key_pair()
|
||||
|
||||
@ -342,7 +340,7 @@ def test_delete_many_unspent_outputs(b, utxoset):
|
||||
assert utxo_collection.count_documents(
|
||||
{'transaction_id': 'a', 'output_index': 1}) == 1
|
||||
else: # TODO It looks ugly because query.get_unspent_outputs function, has not yet implemented query parameter.
|
||||
utx_space = b.connection.space("utxos")
|
||||
utx_space = b.connection.get_space("utxos")
|
||||
res1 = utx_space.select(['a', 0], index="id_search").data
|
||||
res2 = utx_space.select(['b', 0], index="id_search").data
|
||||
assert len(res1) + len(res2) == 0
|
||||
@ -350,7 +348,6 @@ def test_delete_many_unspent_outputs(b, utxoset):
|
||||
assert len(res3) == 1
|
||||
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_store_zero_unspent_output(b, utxo_collection):
|
||||
res = b.store_unspent_outputs()
|
||||
@ -370,12 +367,12 @@ def test_store_one_unspent_output(b, unspent_output_1, utxo_collection):
|
||||
'output_index': unspent_output_1['output_index']}
|
||||
) == 1
|
||||
else:
|
||||
utx_space = b.connection.space("utxos")
|
||||
res = utx_space.select([unspent_output_1["transaction_id"], unspent_output_1["output_index"]], index="id_search")
|
||||
utx_space = b.connection.get_space("utxos")
|
||||
res = utx_space.select([unspent_output_1["transaction_id"], unspent_output_1["output_index"]],
|
||||
index="id_search")
|
||||
assert len(res.data) == 1
|
||||
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_store_many_unspent_outputs(b, unspent_outputs, utxo_collection):
|
||||
from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
||||
@ -387,7 +384,7 @@ def test_store_many_unspent_outputs(b, unspent_outputs, utxo_collection):
|
||||
{'transaction_id': unspent_outputs[0]['transaction_id']}
|
||||
) == 3
|
||||
else:
|
||||
utxo_space = b.connection.space("utxos") # .select([], index="transaction_search").data
|
||||
utxo_space = b.connection.get_space("utxos") # .select([], index="transaction_search").data
|
||||
res = utxo_space.select([unspent_outputs[0]["transaction_id"]], index="transaction_search")
|
||||
assert len(res.data) == 3
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user