mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge branch 'master' of github.com:bigchaindb/bigchaindb
This commit is contained in:
commit
9bd19bccf0
@ -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)
|
||||
|
||||
|
||||
@ -2,3 +2,4 @@
|
||||
testpaths = tests/
|
||||
norecursedirs = .* *.egg *.egg-info env* devenv* docs
|
||||
addopts = -m tendermint
|
||||
looponfailroots = bigchaindb tests
|
||||
|
||||
@ -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])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user