Skip to content

Commit

Permalink
Problem: FastQuery not working (#2153)
Browse files Browse the repository at this point in the history
Solution: Fix FastQuery Class
  • Loading branch information
kansi authored and vrde committed Mar 23, 2018
1 parent cffd68f commit 283f685
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bigchaindb/tendermint/fastquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class FastQuery():
"""
Database queries that join on block results from a single node.
"""
def __init__(self, connection):
self.connection = connection

def get_outputs_by_public_key(self, public_key):
"""
Expand Down
2 changes: 1 addition & 1 deletion bigchaindb/tendermint/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def validate_transaction(self, tx, current_transactions=[]):

@property
def fastquery(self):
return fastquery.FastQuery(self.connection, self.me)
return fastquery.FastQuery(self.connection)


Block = namedtuple('Block', ('app_hash', 'height', 'transactions'))
27 changes: 27 additions & 0 deletions tests/tendermint/test_fastquery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pytest

from bigchaindb.common.transaction import TransactionLink
from bigchaindb.models import Transaction

pytestmark = [pytest.mark.bdb, pytest.mark.tendermint]


@pytest.fixture
def txns(b, user_pk, user_sk, user2_pk, user2_sk):
txs = [Transaction.create([user_pk], [([user2_pk], 1)]).sign([user_sk]),
Transaction.create([user2_pk], [([user_pk], 1)]).sign([user2_sk]),
Transaction.create([user_pk], [([user_pk], 1), ([user2_pk], 1)])
.sign([user_sk])]
b.store_bulk_transactions(txs)
return txs


def test_get_outputs_by_public_key(b, user_pk, user2_pk, txns):
assert b.fastquery.get_outputs_by_public_key(user_pk) == [
TransactionLink(txns[1].id, 0),
TransactionLink(txns[2].id, 0)
]
assert b.fastquery.get_outputs_by_public_key(user2_pk) == [
TransactionLink(txns[0].id, 0),
TransactionLink(txns[2].id, 1),
]

0 comments on commit 283f685

Please sign in to comment.