Merge branch 'master' into create-dynamic-upsert-validator-commands

This commit is contained in:
z-bowen 2018-08-29 14:49:37 +02:00
commit e163547a7e
3 changed files with 25 additions and 1 deletions

View File

@ -285,7 +285,8 @@ class BigchainDB(object):
current_spent_transactions = []
for ctxn in current_transactions:
for ctxn_input in ctxn.inputs:
if ctxn_input.fulfills.txid == txid and\
if ctxn_input.fulfills and\
ctxn_input.fulfills.txid == txid and\
ctxn_input.fulfills.output == output:
current_spent_transactions.append(ctxn)

View File

@ -2,3 +2,4 @@
testpaths = tests/
norecursedirs = .* *.egg *.egg-info env* devenv* docs
addopts = -m tendermint
looponfailroots = bigchaindb tests

View File

@ -419,3 +419,25 @@ def test_get_spent_transaction_critical_double_spend(b, alice, bob, carol):
with pytest.raises(CriticalDoubleSpend):
b.get_spent(tx.id, tx_transfer.inputs[0].fulfills.output)
def test_validation_with_transaction_buffer(b):
from bigchaindb.common.crypto import generate_key_pair
from bigchaindb.models import Transaction
priv_key, pub_key = generate_key_pair()
create_tx = Transaction.create([pub_key], [([pub_key], 10)]).sign([priv_key])
transfer_tx = Transaction.transfer(create_tx.to_inputs(),
[([pub_key], 10)],
asset_id=create_tx.id).sign([priv_key])
double_spend = Transaction.transfer(create_tx.to_inputs(),
[([pub_key], 10)],
asset_id=create_tx.id).sign([priv_key])
assert b.is_valid_transaction(create_tx)
assert b.is_valid_transaction(transfer_tx, [create_tx])
assert not b.is_valid_transaction(create_tx, [create_tx])
assert not b.is_valid_transaction(transfer_tx, [create_tx, transfer_tx])
assert not b.is_valid_transaction(double_spend, [create_tx, transfer_tx])