mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-24 06:25:45 +00:00
blackified python files
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
5d63e2945a
commit
58977b5280
@ -81,7 +81,6 @@ def zenroom_script_input():
|
||||
return SCRIPT_INPUT
|
||||
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def zenroom_data():
|
||||
return ZENROOM_DATA
|
||||
|
||||
@ -38,26 +38,34 @@ def test_zenroom_signing(
|
||||
zenroomscpt = ZenroomSha256(script=fulfill_script_zencode, data=zenroom_data, keys=zen_public_keys)
|
||||
print(f"zenroom is: {zenroomscpt.script}")
|
||||
|
||||
def test_zenroom_signing(gen_key_zencode, secret_key_to_private_key_zencode,
|
||||
fulfill_script_zencode, zenroom_data, zenroom_house_assets,
|
||||
condition_script_zencode):
|
||||
|
||||
def test_zenroom_signing(
|
||||
gen_key_zencode,
|
||||
secret_key_to_private_key_zencode,
|
||||
fulfill_script_zencode,
|
||||
zenroom_data,
|
||||
zenroom_house_assets,
|
||||
condition_script_zencode,
|
||||
):
|
||||
|
||||
biolabs = generate_keypair()
|
||||
version = '2.0'
|
||||
|
||||
alice = json.loads(zencode_exec(gen_key_zencode).output)['keyring']
|
||||
bob = json.loads(zencode_exec(gen_key_zencode).output)['keyring']
|
||||
|
||||
zen_public_keys = json.loads(zencode_exec(secret_key_to_private_key_zencode.format('Alice'),
|
||||
keys=json.dumps({'keyring': alice})).output)
|
||||
zen_public_keys.update(json.loads(zencode_exec(secret_key_to_private_key_zencode.format('Bob'),
|
||||
keys=json.dumps({'keyring': bob})).output))
|
||||
version = "2.0"
|
||||
|
||||
alice = json.loads(zencode_exec(gen_key_zencode).output)["keyring"]
|
||||
bob = json.loads(zencode_exec(gen_key_zencode).output)["keyring"]
|
||||
|
||||
zen_public_keys = json.loads(
|
||||
zencode_exec(secret_key_to_private_key_zencode.format("Alice"), keys=json.dumps({"keyring": alice})).output
|
||||
)
|
||||
zen_public_keys.update(
|
||||
json.loads(
|
||||
zencode_exec(secret_key_to_private_key_zencode.format("Bob"), keys=json.dumps({"keyring": bob})).output
|
||||
)
|
||||
)
|
||||
|
||||
zenroomscpt = ZenroomSha256(script=fulfill_script_zencode, data=zenroom_data, keys=zen_public_keys)
|
||||
print(F'zenroom is: {zenroomscpt.script}')
|
||||
|
||||
print(f"zenroom is: {zenroomscpt.script}")
|
||||
|
||||
# CRYPTO-CONDITIONS: generate the condition uri
|
||||
condition_uri_zen = zenroomscpt.condition.serialize_uri()
|
||||
print(f"\nzenroom condition URI: {condition_uri_zen}")
|
||||
@ -93,12 +101,8 @@ def test_zenroom_signing(gen_key_zencode, secret_key_to_private_key_zencode,
|
||||
"output": ["ok"],
|
||||
"policies": {},
|
||||
}
|
||||
metadata = {
|
||||
"result": {
|
||||
"output": ["ok"]
|
||||
}
|
||||
}
|
||||
|
||||
metadata = {"result": {"output": ["ok"]}}
|
||||
|
||||
token_creation_tx = {
|
||||
"operation": "CREATE",
|
||||
"asset": {"data": multihash(marshal({"test": "my asset"}))},
|
||||
|
||||
@ -42,7 +42,7 @@ This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community.
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior directed at yourself or another community member may be
|
||||
reported by contacting a project maintainer at [mail@planetmint.io](mailto:mail@planetmint.io). All
|
||||
reported by contacting a project maintainer at [mail@planetmint.io](mailto:contact@planetmint.io). All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is appropriate to the circumstances. Maintainers are
|
||||
obligated to maintain confidentiality with regard to the reporter of an
|
||||
|
||||
@ -20,11 +20,13 @@ BACKENDS = {
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _kwargs_parser(key, kwargs):
|
||||
if kwargs.get(key):
|
||||
return kwargs[key]
|
||||
return None
|
||||
|
||||
|
||||
class DBSingleton(type):
|
||||
_instances = {}
|
||||
|
||||
@ -39,24 +41,34 @@ class DBSingleton(type):
|
||||
except KeyError:
|
||||
logger.info("Backend {} not supported".format(backend))
|
||||
raise ConfigurationError
|
||||
modulepath, _, class_name = BACKENDS[backend].rpartition('.')
|
||||
modulepath, _, class_name = BACKENDS[backend].rpartition(".")
|
||||
Class = getattr(import_module(modulepath), class_name)
|
||||
cls._instances[cls] = super(DBSingleton, Class).__call__(*args, **kwargs)
|
||||
return cls._instances[cls]
|
||||
|
||||
class Connection(metaclass=DBSingleton):
|
||||
|
||||
class Connection(metaclass=DBSingleton):
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
|
||||
class DBConnection(metaclass=DBSingleton):
|
||||
"""Connection class interface.
|
||||
All backend implementations should provide a connection class that inherits
|
||||
from and implements this class.
|
||||
"""
|
||||
|
||||
def __init__(self, host: str =None, port: int = None, login: str = None, password: str = None, backend: str = None,
|
||||
connection_timeout: int = None, max_tries: int = None, **kwargs):
|
||||
def __init__(
|
||||
self,
|
||||
host: str = None,
|
||||
port: int = None,
|
||||
login: str = None,
|
||||
password: str = None,
|
||||
backend: str = None,
|
||||
connection_timeout: int = None,
|
||||
max_tries: int = None,
|
||||
**kwargs
|
||||
):
|
||||
"""Create a new :class:`~.Connection` instance.
|
||||
Args:
|
||||
host (str): the host to connect to.
|
||||
@ -70,15 +82,15 @@ class DBConnection(metaclass=DBSingleton):
|
||||
**kwargs: arbitrary keyword arguments provided by the
|
||||
configuration's ``database`` settings
|
||||
"""
|
||||
dbconf = Config().get()['database']
|
||||
dbconf = Config().get()["database"]
|
||||
|
||||
self.host = host or dbconf["host"] if not kwargs.get("host") else kwargs["host"]
|
||||
self.port = port or dbconf['port'] if not kwargs.get("port") else kwargs["port"]
|
||||
self.login = login or dbconf['login'] if not kwargs.get("login") else kwargs["login"]
|
||||
self.password = password or dbconf['password'] if not kwargs.get("password") else kwargs["password"]
|
||||
self.port = port or dbconf["port"] if not kwargs.get("port") else kwargs["port"]
|
||||
self.login = login or dbconf["login"] if not kwargs.get("login") else kwargs["login"]
|
||||
self.password = password or dbconf["password"] if not kwargs.get("password") else kwargs["password"]
|
||||
|
||||
self.connection_timeout = connection_timeout if connection_timeout is not None else Config().get()["database"]
|
||||
self.max_tries = max_tries if max_tries is not None else dbconf['max_tries']
|
||||
self.max_tries = max_tries if max_tries is not None else dbconf["max_tries"]
|
||||
self.max_tries_counter = range(self.max_tries) if self.max_tries != 0 else repeat(0)
|
||||
|
||||
def run(self, query):
|
||||
|
||||
@ -8,18 +8,16 @@ from ssl import CERT_REQUIRED
|
||||
import pymongo
|
||||
|
||||
from planetmint.config import Config
|
||||
from planetmint.backend.exceptions import (DuplicateKeyError,
|
||||
OperationError,
|
||||
ConnectionError)
|
||||
from planetmint.backend.exceptions import DuplicateKeyError, OperationError, ConnectionError
|
||||
from planetmint.transactions.common.exceptions import ConfigurationError
|
||||
from planetmint.utils import Lazy
|
||||
from planetmint.backend.connection import DBConnection, _kwargs_parser
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class LocalMongoDBConnection(DBConnection):
|
||||
|
||||
def __init__(self, host: str =None, port: int = None, login: str = None, password: str = None, **kwargs):
|
||||
class LocalMongoDBConnection(DBConnection):
|
||||
def __init__(self, host: str = None, port: int = None, login: str = None, password: str = None, **kwargs):
|
||||
"""Create a new Connection instance.
|
||||
|
||||
Args:
|
||||
@ -31,17 +29,18 @@ class LocalMongoDBConnection(DBConnection):
|
||||
|
||||
super().__init__(host=host, port=port, login=login, password=password, **kwargs)
|
||||
|
||||
dbconf = Config().get()['database']
|
||||
self.dbname = _kwargs_parser(key="name", kwargs=kwargs) or dbconf['name']
|
||||
self.replicaset = _kwargs_parser(key="replicaset", kwargs=kwargs) or dbconf['replicaset']
|
||||
self.ssl = _kwargs_parser(key="ssl", kwargs=kwargs) or dbconf['ssl']
|
||||
|
||||
self.ca_cert = _kwargs_parser(key="ca_cert", kwargs=kwargs) or dbconf['ca_cert']
|
||||
self.certfile = _kwargs_parser(key="certfile", kwargs=kwargs) or dbconf['certfile']
|
||||
self.keyfile = _kwargs_parser(key="keyfile", kwargs=kwargs) or dbconf['keyfile']
|
||||
self.keyfile_passphrase = _kwargs_parser(key="keyfile_passphrase", kwargs=kwargs) or dbconf[
|
||||
'keyfile_passphrase']
|
||||
self.crlfile = _kwargs_parser(key="crlfile", kwargs=kwargs) or dbconf['crlfile']
|
||||
dbconf = Config().get()["database"]
|
||||
self.dbname = _kwargs_parser(key="name", kwargs=kwargs) or dbconf["name"]
|
||||
self.replicaset = _kwargs_parser(key="replicaset", kwargs=kwargs) or dbconf["replicaset"]
|
||||
self.ssl = _kwargs_parser(key="ssl", kwargs=kwargs) or dbconf["ssl"]
|
||||
|
||||
self.ca_cert = _kwargs_parser(key="ca_cert", kwargs=kwargs) or dbconf["ca_cert"]
|
||||
self.certfile = _kwargs_parser(key="certfile", kwargs=kwargs) or dbconf["certfile"]
|
||||
self.keyfile = _kwargs_parser(key="keyfile", kwargs=kwargs) or dbconf["keyfile"]
|
||||
self.keyfile_passphrase = (
|
||||
_kwargs_parser(key="keyfile_passphrase", kwargs=kwargs) or dbconf["keyfile_passphrase"]
|
||||
)
|
||||
self.crlfile = _kwargs_parser(key="crlfile", kwargs=kwargs) or dbconf["crlfile"]
|
||||
self.max_tries = _kwargs_parser(key="max_tries", kwargs=kwargs)
|
||||
self.connection_timeout = _kwargs_parser(key="connection_timeout", kwargs=kwargs)
|
||||
self.__conn = None
|
||||
@ -72,8 +71,7 @@ class LocalMongoDBConnection(DBConnection):
|
||||
try:
|
||||
return query.run(self.connect())
|
||||
except pymongo.errors.AutoReconnect:
|
||||
logger.warning('Lost connection to the database, '
|
||||
'retrying query.')
|
||||
logger.warning("Lost connection to the database, " "retrying query.")
|
||||
return query.run(self.connect())
|
||||
except pymongo.errors.AutoReconnect as exc:
|
||||
raise ConnectionError from exc
|
||||
@ -130,14 +128,12 @@ class LocalMongoDBConnection(DBConnection):
|
||||
**MONGO_OPTS,
|
||||
)
|
||||
if self.login is not None:
|
||||
client[self.dbname].authenticate(self.login,
|
||||
mechanism='MONGODB-X509')
|
||||
client[self.dbname].authenticate(self.login, mechanism="MONGODB-X509")
|
||||
self.__conn = client
|
||||
return client
|
||||
|
||||
except (pymongo.errors.ConnectionFailure,
|
||||
pymongo.errors.OperationFailure) as exc:
|
||||
logger.info('Exception in connect(): {}'.format(exc))
|
||||
except (pymongo.errors.ConnectionFailure, pymongo.errors.OperationFailure) as exc:
|
||||
logger.info("Exception in connect(): {}".format(exc))
|
||||
raise ConnectionError(str(exc)) from exc
|
||||
except pymongo.errors.ConfigurationError as exc:
|
||||
raise ConfigurationError from exc
|
||||
@ -147,9 +143,10 @@ class LocalMongoDBConnection(DBConnection):
|
||||
self.__conn.close()
|
||||
self.__conn = None
|
||||
except Exception as exc:
|
||||
logger.info('Exception in planetmint.backend.localmongodb.close(): {}'.format(exc))
|
||||
logger.info("Exception in planetmint.backend.localmongodb.close(): {}".format(exc))
|
||||
raise ConnectionError(str(exc)) from exc
|
||||
|
||||
|
||||
MONGO_OPTS = {
|
||||
"socketTimeoutMS": 20000,
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
from functools import singledispatch
|
||||
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# Planetmint and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
|
||||
@ -135,8 +135,12 @@ def init_database(connection=None, dbname=None):
|
||||
"""
|
||||
|
||||
connection = connection or Connection()
|
||||
print("=========================================", connection.__class__, "=========================================================")
|
||||
dbname = dbname or Config().get()['database']['name']
|
||||
print(
|
||||
"=========================================",
|
||||
connection.__class__,
|
||||
"=========================================================",
|
||||
)
|
||||
dbname = dbname or Config().get()["database"]["name"]
|
||||
|
||||
create_database(connection, dbname)
|
||||
create_tables(connection, dbname)
|
||||
|
||||
@ -71,7 +71,7 @@ class TarantoolDBConnection(DBConnection):
|
||||
self.__conn.close()
|
||||
self.__conn = None
|
||||
except Exception as exc:
|
||||
logger.info('Exception in planetmint.backend.tarantool.close(): {}'.format(exc))
|
||||
logger.info("Exception in planetmint.backend.tarantool.close(): {}".format(exc))
|
||||
raise ConnectionError(str(exc)) from exc
|
||||
|
||||
def get_space(self, space_name: str):
|
||||
|
||||
@ -16,7 +16,7 @@ register_query = module_dispatch_registrar(convert)
|
||||
def prepare_asset(connection, transaction_type, transaction_id, filter_operation, asset):
|
||||
asset_id = transaction_id
|
||||
if transaction_type not in filter_operation:
|
||||
asset_id = asset['id']
|
||||
asset_id = asset["id"]
|
||||
return tuple([asset, transaction_id, asset_id])
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import copy
|
||||
import logging
|
||||
import os
|
||||
|
||||
# from planetmint.log import DEFAULT_LOGGING_CONFIG as log_config
|
||||
from planetmint.version import __version__ # noqa
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ from logging.config import dictConfig as set_logging_config
|
||||
from planetmint.config import Config, DEFAULT_LOGGING_CONFIG
|
||||
import os
|
||||
|
||||
|
||||
def _normalize_log_level(level):
|
||||
try:
|
||||
return level.upper()
|
||||
|
||||
@ -10,7 +10,8 @@ from planetmint.exceptions import BigchainDBError
|
||||
|
||||
class ConfigurationError(BigchainDBError):
|
||||
"""Raised when there is a problem with server configuration"""
|
||||
|
||||
|
||||
|
||||
class ConnectionError(BigchainDBError):
|
||||
"""Raised when there is a problem with server connection"""
|
||||
|
||||
|
||||
@ -904,12 +904,8 @@ class Transaction(object):
|
||||
if asset_id != self.asset["id"]:
|
||||
raise AssetIdMismatch(("The asset id of the input does not" " match the asset id of the" " transaction"))
|
||||
|
||||
input_amount = sum(
|
||||
[input_condition.amount for input_condition in input_conditions]
|
||||
)
|
||||
output_amount = sum(
|
||||
[output_condition.amount for output_condition in self.outputs]
|
||||
)
|
||||
input_amount = sum([input_condition.amount for input_condition in input_conditions])
|
||||
output_amount = sum([output_condition.amount for output_condition in self.outputs])
|
||||
|
||||
if output_amount != input_amount:
|
||||
raise AmountError(
|
||||
|
||||
10
setup.py
10
setup.py
@ -89,15 +89,7 @@ docs_require = [
|
||||
|
||||
check_setuptools_features()
|
||||
|
||||
dev_require = [
|
||||
"ipdb",
|
||||
"ipython",
|
||||
"watchdog",
|
||||
"logging_tree",
|
||||
"pre-commit",
|
||||
"twine",
|
||||
"ptvsd"
|
||||
]
|
||||
dev_require = ["ipdb", "ipython", "watchdog", "logging_tree", "pre-commit", "twine", "ptvsd"]
|
||||
|
||||
tests_require = [
|
||||
"coverage",
|
||||
|
||||
@ -16,6 +16,7 @@ pytestmark = pytest.mark.bdb
|
||||
|
||||
def test_get_txids_filtered(signed_create_tx, signed_transfer_tx, db_conn):
|
||||
from planetmint.backend.tarantool import query
|
||||
|
||||
# create and insert two blocks, one for the create and one for the
|
||||
# transfer transaction
|
||||
create_tx_dict = signed_create_tx.to_dict()
|
||||
|
||||
@ -11,8 +11,8 @@ def test_get_connection_raises_a_configuration_error(monkeypatch):
|
||||
from planetmint.backend.connection import Connection
|
||||
from planetmint.backend.localmongodb.connection import LocalMongoDBConnection
|
||||
from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
||||
|
||||
|
||||
with pytest.raises(ConnectionError):
|
||||
LocalMongoDBConnection('localhost', '1337', 'mydb', 'password')
|
||||
LocalMongoDBConnection("localhost", "1337", "mydb", "password")
|
||||
with pytest.raises(ConnectionError):
|
||||
TarantoolDBConnection('localhost', '1337', 'mydb', 'password')
|
||||
TarantoolDBConnection("localhost", "1337", "mydb", "password")
|
||||
|
||||
@ -8,6 +8,7 @@ import pytest
|
||||
|
||||
from planetmint.config import Config
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_run_configure(monkeypatch):
|
||||
from planetmint.commands import planetmint
|
||||
|
||||
@ -21,6 +21,7 @@ from planetmint.transactions.types.elections.chain_migration_election import Cha
|
||||
|
||||
from tests.utils import generate_election, generate_validators
|
||||
|
||||
|
||||
def test_make_sure_we_dont_remove_any_command():
|
||||
# thanks to: http://stackoverflow.com/a/18161115/597097
|
||||
from planetmint.commands.planetmint import create_parser
|
||||
@ -95,6 +96,7 @@ def test_bigchain_show_config(capsys):
|
||||
# dict returned is different that what is expected after run_show_config
|
||||
# and run_show_config updates the planetmint.config
|
||||
from planetmint.config import Config
|
||||
|
||||
_config = Config().get()
|
||||
sorted_config = json.dumps(_config, indent=4, sort_keys=True)
|
||||
print(f"_config : {sorted_config}")
|
||||
@ -103,8 +105,7 @@ def test_bigchain_show_config(capsys):
|
||||
|
||||
|
||||
def test__run_init(mocker):
|
||||
init_db_mock = mocker.patch(
|
||||
'planetmint.backend.tarantool.connection.TarantoolDBConnection.init_database')
|
||||
init_db_mock = mocker.patch("planetmint.backend.tarantool.connection.TarantoolDBConnection.init_database")
|
||||
|
||||
conn = Connection()
|
||||
conn.init_database()
|
||||
|
||||
@ -23,6 +23,7 @@ from planetmint.backend.connection import Connection
|
||||
from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
||||
|
||||
import pytest
|
||||
|
||||
# from pymongo import MongoClient
|
||||
|
||||
from planetmint import ValidatorElection
|
||||
@ -117,21 +118,21 @@ def _configure_planetmint(request):
|
||||
config_utils.set_config(config)
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
@pytest.fixture(scope="session")
|
||||
def _setup_database(_configure_planetmint): # TODO Here is located setup database
|
||||
from planetmint.config import Config
|
||||
|
||||
print('Initializing test db')
|
||||
dbname = Config().get()['database']['name']
|
||||
print("Initializing test db")
|
||||
dbname = Config().get()["database"]["name"]
|
||||
conn = Connection()
|
||||
|
||||
_drop_db(conn, dbname)
|
||||
schema.init_database(conn, dbname)
|
||||
print('Finishing init database')
|
||||
print("Finishing init database")
|
||||
|
||||
yield
|
||||
|
||||
print('Deleting `{}` database'.format(dbname))
|
||||
print("Deleting `{}` database".format(dbname))
|
||||
conn = Connection()
|
||||
_drop_db(conn, dbname)
|
||||
|
||||
@ -144,9 +145,10 @@ def _bdb(_setup_database, _configure_planetmint):
|
||||
from planetmint.transactions.common.transaction import Transaction
|
||||
from .utils import flush_db
|
||||
from planetmint.config import Config
|
||||
|
||||
conn = Connection()
|
||||
yield
|
||||
dbname = Config().get()['database']['name']
|
||||
dbname = Config().get()["database"]["name"]
|
||||
flush_db(conn, dbname)
|
||||
|
||||
to_dict.cache_clear()
|
||||
@ -250,6 +252,7 @@ def abci_fixture():
|
||||
|
||||
return types_pb2
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def b():
|
||||
from planetmint import Planetmint
|
||||
@ -547,6 +550,7 @@ def tarantool_client(db_context): # TODO Here add TarantoolConnectionClass
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def utxo_collection(tarantool_client, _setup_database):
|
||||
return tarantool_client.get_space("utxos")
|
||||
@ -564,6 +568,7 @@ def dummy_unspent_outputs():
|
||||
@pytest.fixture
|
||||
def utxoset(dummy_unspent_outputs, utxo_collection):
|
||||
from json import dumps
|
||||
|
||||
num_rows_before_operation = utxo_collection.select().rowcount
|
||||
for utxo in dummy_unspent_outputs:
|
||||
res = utxo_collection.insert((utxo["transaction_id"], utxo["output_index"], dumps(utxo)))
|
||||
@ -619,6 +624,7 @@ def node_keys():
|
||||
"PecJ58SaNRsWJZodDmqjpCWqG6btdwXFHLyE40RYlYM=": "uz8bYgoL4rHErWT1gjjrnA+W7bgD/uDQWSRKDmC8otc95wnnxJo1GxYlmh0OaqOkJaobpu13BcUcvITjRFiVgw==",
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def priv_validator_path(node_keys):
|
||||
(public_key, private_key) = list(node_keys.items())[0]
|
||||
|
||||
@ -290,6 +290,7 @@ def test_delete_zero_unspent_outputs(b, utxoset):
|
||||
@pytest.mark.bdb
|
||||
def test_delete_one_unspent_outputs(b, utxoset):
|
||||
from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
||||
|
||||
unspent_outputs, utxo_collection = utxoset
|
||||
delete_res = b.delete_unspent_outputs(unspent_outputs[0])
|
||||
if not isinstance(b.connection, TarantoolDBConnection):
|
||||
@ -318,6 +319,7 @@ def test_delete_one_unspent_outputs(b, utxoset):
|
||||
@pytest.mark.bdb
|
||||
def test_delete_many_unspent_outputs(b, utxoset):
|
||||
from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
||||
|
||||
unspent_outputs, utxo_collection = utxoset
|
||||
delete_res = b.delete_unspent_outputs(*unspent_outputs[::2])
|
||||
if not isinstance(b.connection, TarantoolDBConnection):
|
||||
@ -355,6 +357,7 @@ def test_store_zero_unspent_output(b, utxo_collection):
|
||||
@pytest.mark.bdb
|
||||
def test_store_one_unspent_output(b, unspent_output_1, utxo_collection):
|
||||
from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
||||
|
||||
res = b.store_unspent_outputs(unspent_output_1)
|
||||
if not isinstance(b.connection, TarantoolDBConnection):
|
||||
assert res.acknowledged
|
||||
@ -379,6 +382,7 @@ def test_store_one_unspent_output(b, unspent_output_1, utxo_collection):
|
||||
@pytest.mark.bdb
|
||||
def test_store_many_unspent_outputs(b, unspent_outputs, utxo_collection):
|
||||
from planetmint.backend.tarantool.connection import TarantoolDBConnection
|
||||
|
||||
res = b.store_unspent_outputs(*unspent_outputs)
|
||||
if not isinstance(b.connection, TarantoolDBConnection):
|
||||
assert res.acknowledged
|
||||
|
||||
@ -55,25 +55,28 @@ def config(request, monkeypatch):
|
||||
monkeypatch.setattr("planetmint.config", config)
|
||||
return config
|
||||
|
||||
|
||||
def test_bigchain_class_initialization_with_parameters():
|
||||
from planetmint.backend.localmongodb.connection import LocalMongoDBConnection
|
||||
from planetmint.transactions.common.exceptions import ConfigurationError
|
||||
|
||||
init_db_kwargs = {
|
||||
'backend': 'localmongodb',
|
||||
'host': 'this_is_the_db_host',
|
||||
'port': 12345,
|
||||
'name': 'this_is_the_db_name',
|
||||
"backend": "localmongodb",
|
||||
"host": "this_is_the_db_host",
|
||||
"port": 12345,
|
||||
"name": "this_is_the_db_name",
|
||||
}
|
||||
with pytest.raises(ConfigurationError):
|
||||
LocalMongoDBConnection(**init_db_kwargs)
|
||||
|
||||
|
||||
def test_bigchain_class_default_initialization(config):
|
||||
from planetmint import Planetmint
|
||||
from planetmint.validation import BaseValidationRules
|
||||
|
||||
planet = Planetmint()
|
||||
assert planet.connection.host == config['database']['host']
|
||||
assert planet.connection.port == config['database']['port']
|
||||
assert planet.connection.host == config["database"]["host"]
|
||||
assert planet.connection.port == config["database"]["port"]
|
||||
assert planet.validation == BaseValidationRules
|
||||
|
||||
|
||||
|
||||
@ -348,9 +348,7 @@ def test_post_transfer_transaction_endpoint(client, user_pk, user_sk, posted_cre
|
||||
|
||||
|
||||
@pytest.mark.abci
|
||||
def test_post_invalid_transfer_transaction_returns_400(
|
||||
client, user_pk, posted_create_tx
|
||||
):
|
||||
def test_post_invalid_transfer_transaction_returns_400(client, user_pk, posted_create_tx):
|
||||
from planetmint.transactions.common.exceptions import InvalidSignature
|
||||
|
||||
transfer_tx = Transfer.generate(posted_create_tx.to_inputs(), [([user_pk], 1)], asset_id=posted_create_tx.id)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user