Commits (3)
import os
class NodeApiCallProxy:
def __init__(self, node, method, params=None, jsonrpc='2.0', id_=1):
self.__node = node
......@@ -10,7 +13,7 @@ class NodeApiCallProxy:
def __call__(self, *args, only_result: bool = True, **kwargs):
self.__message['params'] = self._prepare_params(*args, **kwargs)
return self.__node.send(
response = self.__node.send(
self.__message['method'],
self.__message['params'],
jsonrpc=self.__message['jsonrpc'],
......@@ -18,6 +21,16 @@ class NodeApiCallProxy:
only_result=only_result,
)
def schemas_should_be_automatically_validated() -> bool:
should_validate = os.getenv('TEST_TOOLS_VALIDATE_RESPONSE_SCHEMAS', default='FALSE')
return should_validate.lower() == 'true' or should_validate == '1'
if schemas_should_be_automatically_validated():
from schemas.get_schema import get_schema # pylint: disable=import-outside-toplevel, import-error
get_schema(self.__message['method']).validate(response)
return response
@staticmethod
def _prepare_params(*args, **kwargs):
if args:
......
......@@ -103,6 +103,8 @@ class NodeConfig:
self.psql_index_threshold = Integer()
self.psql_operations_threads_number = Integer()
self.psql_transactions_threads_number = Integer()
self.enable_block_log_compression = Boolean()
self.block_log_compression_level = Integer()
def __setattr__(self, key, value):
entries = self.__get_entries()
......
......@@ -38,5 +38,7 @@ def create_default_config():
config.enable_stale_production = False
config.required_participation = 33
config.witness_skip_enforce_bandwidth = '1'
config.enable_block_log_compression = True
config.block_log_compression_level = 15
return config
......@@ -71,6 +71,14 @@ class AssetBase:
if type(self) is type(other):
return self.amount == other.amount
if isinstance(other, dict):
if set(self.as_nai().keys()) == set(other.keys()):
return self.as_nai() == other
raise KeyError(f'The keys did not match. '
f'Expected: {set(self.as_nai().keys())}. '
f'Actual: {set(other.keys())}')
raise TypeError(f'Assets can\'t be compared with objects of type {type(other)}')
def __str__(self):
......