add backlog count (#806)

This commit is contained in:
Ryan Henderson 2016-11-14 10:03:59 +01:00 committed by GitHub
parent 32a247552c
commit c8553abb41
2 changed files with 20 additions and 0 deletions

View File

@ -293,6 +293,17 @@ class RethinkDBBackend:
r.table('bigchain', read_mode=self.read_mode) r.table('bigchain', read_mode=self.read_mode)
.count()) .count())
def count_backlog(self):
"""Count the number of transactions in the backlog table.
Returns:
The number of transactions in the backlog.
"""
return self.connection.run(
r.table('backlog', read_mode=self.read_mode)
.count())
def write_vote(self, vote): def write_vote(self, vote):
"""Write a vote to the votes table. """Write a vote to the votes table.

View File

@ -592,6 +592,15 @@ class TestBigchainApi(object):
with pytest.raises(TransactionDoesNotExist) as excinfo: with pytest.raises(TransactionDoesNotExist) as excinfo:
tx.validate(Bigchain()) tx.validate(Bigchain())
def test_count_backlog(self, b, user_vk):
from bigchaindb.models import Transaction
for _ in range(4):
tx = Transaction.create([b.me], [user_vk]).sign([b.me_private])
b.write_transaction(tx)
assert b.backend.count_backlog() == 4
class TestTransactionValidation(object): class TestTransactionValidation(object):
def test_create_operation_with_inputs(self, b, user_vk, create_tx): def test_create_operation_with_inputs(self, b, user_vk, create_tx):