Problem: I removed a test that covered writing to the DB and checking that everything is stored faithfully

Solution: Replaced it and got it working again
This commit is contained in:
z-bowen 2018-08-10 17:09:23 +02:00
parent dacdf58c79
commit 2167af83c4

View File

@ -34,6 +34,7 @@ class TestBigchainApi(object):
def test_get_spent_with_double_spend_detected(self, b, alice): def test_get_spent_with_double_spend_detected(self, b, alice):
from bigchaindb.models import Transaction from bigchaindb.models import Transaction
from bigchaindb.common.exceptions import DoubleSpend from bigchaindb.common.exceptions import DoubleSpend
from bigchaindb.exceptions import CriticalDoubleSpend
tx = Transaction.create([alice.public_key], [([alice.public_key], 1)]) tx = Transaction.create([alice.public_key], [([alice.public_key], 1)])
tx = tx.sign([alice.private_key]) tx = tx.sign([alice.private_key])
@ -55,6 +56,11 @@ class TestBigchainApi(object):
with pytest.raises(DoubleSpend): with pytest.raises(DoubleSpend):
b.validate_transaction(transfer_tx2) b.validate_transaction(transfer_tx2)
b.store_bulk_transactions([transfer_tx2])
with pytest.raises(CriticalDoubleSpend):
b.get_spent(tx.id, 0)
@pytest.mark.tendermint @pytest.mark.tendermint
def test_get_block_status_for_tx_with_double_inclusion(self, b, alice): def test_get_block_status_for_tx_with_double_inclusion(self, b, alice):
from bigchaindb.models import Transaction from bigchaindb.models import Transaction
@ -87,7 +93,7 @@ class TestBigchainApi(object):
tx3 = Transaction.create([alice.public_key], [([alice.public_key], 1)], tx3 = Transaction.create([alice.public_key], [([alice.public_key], 1)],
asset=asset3).sign([alice.private_key]) asset=asset3).sign([alice.private_key])
# create the block # write the transactions to the DB
b.store_bulk_transactions([tx1, tx2, tx3]) b.store_bulk_transactions([tx1, tx2, tx3])
# get the assets through text search # get the assets through text search
@ -116,6 +122,26 @@ class TestBigchainApi(object):
with pytest.raises(InputDoesNotExist): with pytest.raises(InputDoesNotExist):
tx.validate(b) tx.validate(b)
@pytest.mark.tendermint
def test_write_transaction(self, b, user_sk, user_pk, alice, create_tx):
from bigchaindb.models import Transaction
asset1 = {'msg': 'BigchainDB 1'}
tx = Transaction.create([alice.public_key], [([alice.public_key], 1)],
asset=asset1).sign([alice.private_key])
b.store_bulk_transactions([tx])
tx_from_db = b.get_transaction(tx.id)
before = tx.to_dict()
after = tx_from_db.to_dict()
assert before['asset']['data'] == after['asset']['data']
before.pop('asset', None)
after.pop('asset', None)
assert before == after
class TestTransactionValidation(object): class TestTransactionValidation(object):
def test_non_create_input_not_found(self, b, user_pk, signed_transfer_tx): def test_non_create_input_not_found(self, b, user_pk, signed_transfer_tx):