mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-26 07:25:44 +00:00
FIXED bug on tarantool initialization
This commit is contained in:
parent
949be41b84
commit
6b1f0adf4f
@ -23,18 +23,18 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class TarantoolDB:
|
||||
def __init__(self, host: str, port: int, user: str, password: str, reset_database: bool = False):
|
||||
self.db_connect = tarantool.connect(host=host, port=port, user=user, password=password)
|
||||
if reset_database:
|
||||
self.drop_database()
|
||||
self.init_database()
|
||||
self.db_connect = None
|
||||
self.db_connect = tarantool.connect(host=host, port=port, user=user, password=password)
|
||||
test_conn = self.db_connect.space("transactions")
|
||||
|
||||
def get_connection(self, space_name: str = None):
|
||||
return self.db_connect if space_name is None else self.db_connect.space(space_name)
|
||||
|
||||
def __read_commands(self, file_path):
|
||||
with open(file_path, "r") as cmd_file:
|
||||
commands = [line + '\n' for line in cmd_file.readlines() if len(str(line)) > 1]
|
||||
commands = [line.strip() for line in cmd_file.readlines() if len(str(line)) > 1]
|
||||
cmd_file.close()
|
||||
return commands
|
||||
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
box.space.abci_chains.drop()
|
||||
box.space.abci_chains:drop()
|
||||
|
||||
box.space.assets.drop()
|
||||
box.space.assets:drop()
|
||||
|
||||
box.space.blocks.drop()
|
||||
box.space.blocks:drop()
|
||||
|
||||
box.space.blocks_tx.drop()
|
||||
box.space.blocks_tx:drop()
|
||||
|
||||
box.space.elections.drop()
|
||||
box.space.elections:drop()
|
||||
|
||||
box.space.meta_datas.drop()
|
||||
box.space.meta_datas:drop()
|
||||
|
||||
box.space.pre_commits.drop()
|
||||
box.space.pre_commits:drop()
|
||||
|
||||
box.space.validators.drop()
|
||||
box.space.validators:drop()
|
||||
|
||||
box.space.transactions.drop()
|
||||
box.space.transactions:drop()
|
||||
|
||||
box.space.inputs.drop()
|
||||
box.space.inputs:drop()
|
||||
|
||||
box.space.outputs.drop()
|
||||
box.space.outputs:drop()
|
||||
|
||||
box.space.keys.drop()
|
||||
box.space.keys:drop()
|
||||
@ -63,5 +63,3 @@ keys:create_index('id_search', {type = 'hash', parts={'id'}})
|
||||
keys:create_index('keys_search', {type = 'tree', unique=false, parts={'public_key'}})
|
||||
keys:create_index('txid_search', {type = 'tree', unique=false, parts={'transaction_id'}})
|
||||
keys:create_index('output_search', {type = 'tree', unique=false, parts={'output_id'}})
|
||||
|
||||
box.schema.user.passwd('pass')
|
||||
|
||||
@ -10,7 +10,10 @@ def run(commands: list, config: dict):
|
||||
shell=True)
|
||||
|
||||
for cmd in commands:
|
||||
try:
|
||||
sshProcess.stdin.write(cmd)
|
||||
except:
|
||||
pass
|
||||
sshProcess.stdin.close()
|
||||
# TODO To add here Exception Handler for stdout
|
||||
# for line in sshProcess.stdout:
|
||||
|
||||
@ -19,24 +19,24 @@ def test_get_txids_filtered(signed_create_tx, signed_transfer_tx):
|
||||
from planetmint.models import Transaction
|
||||
conn = connect() # TODO First rewrite to get here tarantool connection
|
||||
print(conn)
|
||||
# # create and insert two blocks, one for the create and one for the
|
||||
# # transfer transaction
|
||||
# conn.db.transactions.insert_one(signed_create_tx.to_dict())
|
||||
# conn.db.transactions.insert_one(signed_transfer_tx.to_dict())
|
||||
#
|
||||
# asset_id = Transaction.get_asset_id([signed_create_tx, signed_transfer_tx])
|
||||
#
|
||||
# # Test get by just asset id
|
||||
# txids = set(query.get_txids_filtered(conn, asset_id))
|
||||
# assert txids == {signed_create_tx.id, signed_transfer_tx.id}
|
||||
#
|
||||
# # Test get by asset and CREATE
|
||||
# txids = set(query.get_txids_filtered(conn, asset_id, Transaction.CREATE))
|
||||
# assert txids == {signed_create_tx.id}
|
||||
#
|
||||
# # Test get by asset and TRANSFER
|
||||
# txids = set(query.get_txids_filtered(conn, asset_id, Transaction.TRANSFER))
|
||||
# assert txids == {signed_transfer_tx.id}
|
||||
# create and insert two blocks, one for the create and one for the
|
||||
# transfer transaction
|
||||
conn.db.transactions.insert_one(signed_create_tx.to_dict())
|
||||
conn.db.transactions.insert_one(signed_transfer_tx.to_dict())
|
||||
|
||||
asset_id = Transaction.get_asset_id([signed_create_tx, signed_transfer_tx])
|
||||
|
||||
# Test get by just asset id
|
||||
txids = set(query.get_txids_filtered(conn, asset_id))
|
||||
assert txids == {signed_create_tx.id, signed_transfer_tx.id}
|
||||
|
||||
# Test get by asset and CREATE
|
||||
txids = set(query.get_txids_filtered(conn, asset_id, Transaction.CREATE))
|
||||
assert txids == {signed_create_tx.id}
|
||||
|
||||
# Test get by asset and TRANSFER
|
||||
txids = set(query.get_txids_filtered(conn, asset_id, Transaction.TRANSFER))
|
||||
assert txids == {signed_transfer_tx.id}
|
||||
|
||||
|
||||
def test_write_assets():
|
||||
|
||||
@ -23,6 +23,7 @@ def test_get_txids_filtered(signed_create_tx, signed_transfer_tx):
|
||||
# transfer transaction
|
||||
create_tx_dict = signed_create_tx.to_dict()
|
||||
transfer_tx_dict = signed_transfer_tx.to_dict()
|
||||
|
||||
query.store_transactions(signed_transactions=[create_tx_dict], connection=conn)
|
||||
query.store_transactions(signed_transactions=[transfer_tx_dict], connection=conn)
|
||||
|
||||
@ -83,8 +84,6 @@ def test_get_assets():
|
||||
|
||||
@pytest.mark.parametrize('table', ['assets', 'metadata'])
|
||||
def test_text_search(table):
|
||||
from planetmint.backend import connect, query
|
||||
conn = connect()
|
||||
assert "PASS FOR NOW"
|
||||
|
||||
# # Example data and tests cases taken from the mongodb documentation
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user