mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Unique index for bigchain collection, fixed test case
This commit is contained in:
parent
421c67c621
commit
263e9a25f6
@ -50,9 +50,10 @@ def drop_database(conn, dbname):
|
||||
def create_bigchain_secondary_index(conn, dbname):
|
||||
logger.info('Create `bigchain` secondary index.')
|
||||
|
||||
# secondary index on block id which is should be unique
|
||||
# secondary index on block id which should be unique
|
||||
conn.conn[dbname]['bigchain'].create_index('id',
|
||||
name='block_id')
|
||||
name='block_id',
|
||||
unique=True)
|
||||
|
||||
# to order blocks by timestamp
|
||||
conn.conn[dbname]['bigchain'].create_index([('block.timestamp',
|
||||
|
@ -299,12 +299,13 @@ def test_count_blocks(signed_create_tx):
|
||||
from bigchaindb.models import Block
|
||||
conn = connect()
|
||||
|
||||
assert query.count_blocks(conn) == 0
|
||||
|
||||
# create and insert some blocks
|
||||
block = Block(transactions=[signed_create_tx])
|
||||
conn.db.bigchain.insert_one(block.to_dict())
|
||||
conn.db.bigchain.insert_one(block.to_dict())
|
||||
|
||||
assert query.count_blocks(conn) == 2
|
||||
assert query.count_blocks(conn) == 1
|
||||
|
||||
|
||||
def test_count_backlog(signed_create_tx):
|
||||
|
Loading…
x
Reference in New Issue
Block a user