diff --git a/bigchaindb/common/memoize.py b/bigchaindb/common/memoize.py index f52c1dc3..9342ea84 100644 --- a/bigchaindb/common/memoize.py +++ b/bigchaindb/common/memoize.py @@ -5,7 +5,7 @@ from functools import lru_cache class HDict(dict): def __hash__(self): - return int.from_bytes(codecs.decode(self['id'], 'hex'), 'big') + return hash(codecs.decode(self['id'], 'hex')) @lru_cache(maxsize=16384) @@ -17,9 +17,9 @@ def memoize_from_dict(func): @functools.wraps(func) def memoized_func(*args, **kwargs): - print(args) - new_args = (args[0], HDict(args[1]), args[2]) - print(new_args) + args = list(args) + args[1] = HDict(args[1]) + new_args = tuple(args) return from_dict(func, *new_args, **kwargs) return memoized_func diff --git a/bigchaindb/lib.py b/bigchaindb/lib.py index e00e75f5..4c45beda 100644 --- a/bigchaindb/lib.py +++ b/bigchaindb/lib.py @@ -77,10 +77,11 @@ class BigchainDB(object): raise ValidationError('Mode must be one of the following {}.' .format(', '.join(self.mode_list))) + tx_dict = transaction.tx_dict if transaction.tx_dict else transaction.to_dict() payload = { 'method': mode, 'jsonrpc': '2.0', - 'params': [encode_transaction(transaction.to_dict())], + 'params': [encode_transaction(tx_dict)], 'id': str(uuid4()) } # TODO: handle connection errors! diff --git a/tests/conftest.py b/tests/conftest.py index 0fd4d671..cc985d96 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -256,7 +256,8 @@ def b(): def create_tx(alice, user_pk): from bigchaindb.models import Transaction name = f'I am created by the create_tx fixture. My random identifier is {random.random()}.' - return Transaction.create([alice.public_key], [([user_pk], 1)], asset={'name': name}) + return Transaction.create([alice.public_key], [([user_pk], 1)], asset={'name': name})\ + .sign([alice.private_key]) @pytest.fixture