Problem: memoization for to_dict disabled

Solution: enable memoization and fix failing tests
This commit is contained in:
Vanshdeep Singh 2018-09-04 10:52:15 +02:00
parent 9280ac62a7
commit 9689072ea4
2 changed files with 4 additions and 4 deletions

View File

@ -28,7 +28,7 @@ from bigchaindb.common.exceptions import (KeypairMismatchException,
AmountError, AssetIdMismatch, AmountError, AssetIdMismatch,
ThresholdTooDeep) ThresholdTooDeep)
from bigchaindb.common.utils import serialize from bigchaindb.common.utils import serialize
from .memoize import memoize_from_dict # , memoize_to_dict from .memoize import memoize_from_dict, memoize_to_dict
UnspentOutput = namedtuple( UnspentOutput = namedtuple(
@ -1061,7 +1061,7 @@ class Transaction(object):
def __hash__(self): def __hash__(self):
return hash(self.id) return hash(self.id)
# @memoize_to_dict @memoize_to_dict
def to_dict(self): def to_dict(self):
"""Transforms the object to a Python dictionary. """Transforms the object to a Python dictionary.

View File

@ -202,7 +202,7 @@ def test_get_owned_ids(signed_create_tx, user_pk):
conn = connect() conn = connect()
# insert a transaction # insert a transaction
conn.db.transactions.insert_one(signed_create_tx.to_dict()) conn.db.transactions.insert_one(deepcopy(signed_create_tx.to_dict()))
txns = list(query.get_owned_ids(conn, user_pk)) txns = list(query.get_owned_ids(conn, user_pk))
@ -221,7 +221,7 @@ def test_get_spending_transactions(user_pk, user_sk):
tx2 = Transaction.transfer([inputs[0]], out, tx1.id).sign([user_sk]) tx2 = Transaction.transfer([inputs[0]], out, tx1.id).sign([user_sk])
tx3 = Transaction.transfer([inputs[1]], out, tx1.id).sign([user_sk]) tx3 = Transaction.transfer([inputs[1]], out, tx1.id).sign([user_sk])
tx4 = Transaction.transfer([inputs[2]], out, tx1.id).sign([user_sk]) tx4 = Transaction.transfer([inputs[2]], out, tx1.id).sign([user_sk])
txns = [tx.to_dict() for tx in [tx1, tx2, tx3, tx4]] txns = [deepcopy(tx.to_dict()) for tx in [tx1, tx2, tx3, tx4]]
conn.db.transactions.insert_many(txns) conn.db.transactions.insert_many(txns)
links = [inputs[0].fulfills.to_dict(), inputs[2].fulfills.to_dict()] links = [inputs[0].fulfills.to_dict(), inputs[2].fulfills.to_dict()]