mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Add more blocks in inputs fixture
This commit is contained in:
parent
e9b4b99946
commit
e0d0ab21d3
@ -598,9 +598,11 @@ class Bigchain(object):
|
||||
.order_by(r.desc(r.row['block']['timestamp'])) \
|
||||
.run(self.conn)
|
||||
|
||||
# FIXME: I (@vrde) don't like this solution. Filtering should be done at a
|
||||
# database level. Solving issue #444 can help untangling the situation
|
||||
unvoted = filter(lambda block: not util.is_genesis_block(block), unvoted)
|
||||
|
||||
return unvoted
|
||||
return list(unvoted)
|
||||
|
||||
def block_election_status(self, block):
|
||||
"""Tally the votes on a block, and return the status: valid, invalid, or undecided."""
|
||||
|
@ -98,7 +98,7 @@ def cleanup_tables(request, node_config):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inputs(user_vk, amount=1, b=None):
|
||||
def inputs(user_vk, amount=4, b=None, blocks=4):
|
||||
from bigchaindb.exceptions import GenesisBlockAlreadyExistsError
|
||||
# 1. create the genesis block
|
||||
b = b or Bigchain()
|
||||
@ -108,6 +108,7 @@ def inputs(user_vk, amount=1, b=None):
|
||||
pass
|
||||
|
||||
# 2. create block with transactions for `USER` to spend
|
||||
for block in range(blocks):
|
||||
transactions = []
|
||||
for i in range(amount):
|
||||
tx = b.create_transaction(b.me, user_vk, None, 'CREATE')
|
||||
@ -117,4 +118,3 @@ def inputs(user_vk, amount=1, b=None):
|
||||
|
||||
block = b.create_block(transactions)
|
||||
b.write_block(block, durability='hard')
|
||||
return block
|
||||
|
@ -182,11 +182,13 @@ class TestBigchainApi(object):
|
||||
def test_genesis_block(self, b):
|
||||
response = list(r.table('bigchain')
|
||||
.filter(util.is_genesis_block)
|
||||
.run(b.conn))[0]
|
||||
.run(b.conn))
|
||||
|
||||
assert len(response['block']['transactions']) == 1
|
||||
assert response['block']['transactions'][0]['transaction']['operation'] == 'GENESIS'
|
||||
assert response['block']['transactions'][0]['transaction']['fulfillments'][0]['input'] is None
|
||||
assert len(response) == 1
|
||||
block = response[0]
|
||||
assert len(block['block']['transactions']) == 1
|
||||
assert block['block']['transactions'][0]['transaction']['operation'] == 'GENESIS'
|
||||
assert block['block']['transactions'][0]['transaction']['fulfillments'][0]['input'] is None
|
||||
|
||||
def test_create_genesis_block_fails_if_table_not_empty(self, b):
|
||||
b.create_genesis_block()
|
||||
@ -1988,6 +1990,7 @@ class TestCryptoconditions(object):
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_transfer_asset_with_hashlock_condition(self, b, user_vk, user_sk):
|
||||
owned_count = len(b.get_owned_ids(user_vk))
|
||||
first_input_tx = b.get_owned_ids(user_vk).pop()
|
||||
|
||||
hashlock_tx = b.create_transaction(user_vk, None, first_input_tx, 'TRANSFER')
|
||||
@ -2010,7 +2013,7 @@ class TestCryptoconditions(object):
|
||||
|
||||
assert b.validate_transaction(hashlock_tx_signed) == hashlock_tx_signed
|
||||
assert b.is_valid_transaction(hashlock_tx_signed) == hashlock_tx_signed
|
||||
assert len(b.get_owned_ids(user_vk)) == 1
|
||||
assert len(b.get_owned_ids(user_vk)) == owned_count
|
||||
|
||||
b.write_transaction(hashlock_tx_signed)
|
||||
|
||||
@ -2018,7 +2021,7 @@ class TestCryptoconditions(object):
|
||||
block = b.create_block([hashlock_tx_signed])
|
||||
b.write_block(block, durability='hard')
|
||||
|
||||
assert len(b.get_owned_ids(user_vk)) == 0
|
||||
assert len(b.get_owned_ids(user_vk)) == owned_count - 1
|
||||
|
||||
def test_create_and_fulfill_asset_with_hashlock_condition(self, b, user_vk):
|
||||
hashlock_tx = b.create_transaction(b.me, None, None, 'CREATE')
|
||||
|
Loading…
x
Reference in New Issue
Block a user