From 345fc27a39209f424783c1d54595f877038c469b Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Tue, 6 Dec 2016 14:27:39 +0100 Subject: [PATCH] Remove durability from all database-related calls --- bigchaindb/backend/query.py | 2 +- bigchaindb/core.py | 8 +- tests/assets/test_digital_assets.py | 8 +- tests/assets/test_divisible_assets.py | 34 +++---- tests/db/conftest.py | 4 +- tests/db/test_bigchain_api.py | 131 ++++++++++++++++---------- tests/pipelines/test_stale_monitor.py | 8 +- tests/pipelines/test_vote.py | 14 +-- 8 files changed, 121 insertions(+), 88 deletions(-) diff --git a/bigchaindb/backend/query.py b/bigchaindb/backend/query.py index 75557051..a3fe29ef 100644 --- a/bigchaindb/backend/query.py +++ b/bigchaindb/backend/query.py @@ -203,7 +203,7 @@ def get_votes_by_block_id_and_voter(connection, block_id, node_pubkey): @singledispatch -def write_block(connection, block, durability='soft'): +def write_block(connection, block): """Write a block to the bigchain table. Args: diff --git a/bigchaindb/core.py b/bigchaindb/core.py index fdf7588e..f0e1b89c 100644 --- a/bigchaindb/core.py +++ b/bigchaindb/core.py @@ -61,7 +61,7 @@ class Bigchain(object): if not self.me or not self.me_private: raise exceptions.KeypairNotFoundException() - def write_transaction(self, signed_transaction, durability='soft'): + def write_transaction(self, signed_transaction): """Write the transaction to bigchain. When first writing a transaction to the bigchain the transaction will be kept in a backlog until @@ -509,14 +509,14 @@ class Bigchain(object): return has_previous_vote - def write_block(self, block, durability='soft'): + def write_block(self, block): """Write a block to bigchain. Args: block (Block): block to write to bigchain. """ - return backend.query.write_block(self.connection, block.to_str(), durability=durability) + return backend.query.write_block(self.connection, block.to_str()) def transaction_exists(self, transaction_id): return backend.query.has_transaction(self.connection, transaction_id) @@ -554,7 +554,7 @@ class Bigchain(object): raise exceptions.GenesisBlockAlreadyExistsError('Cannot create the Genesis block') block = self.prepare_genesis_block() - self.write_block(block, durability='hard') + self.write_block(block) return block diff --git a/tests/assets/test_digital_assets.py b/tests/assets/test_digital_assets.py index 5d8654f2..6c95284a 100644 --- a/tests/assets/test_digital_assets.py +++ b/tests/assets/test_digital_assets.py @@ -91,7 +91,7 @@ def test_get_asset_id_transfer_transaction(b, user_pk, user_sk): tx_transfer_signed = tx_transfer.sign([user_sk]) # create a block block = b.create_block([tx_transfer_signed]) - b.write_block(block, durability='hard') + b.write_block(block) # vote the block valid vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -130,7 +130,7 @@ def test_get_transactions_by_asset_id(b, user_pk, user_sk): tx_transfer_signed = tx_transfer.sign([user_sk]) # create the block block = b.create_block([tx_transfer_signed]) - b.write_block(block, durability='hard') + b.write_block(block) # vote the block valid vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -163,7 +163,7 @@ def test_get_transactions_by_asset_id_with_invalid_block(b, user_pk, user_sk): tx_transfer_signed = tx_transfer.sign([user_sk]) # create the block block = b.create_block([tx_transfer_signed]) - b.write_block(block, durability='hard') + b.write_block(block) # vote the block invalid vote = b.vote(block.id, b.get_last_voted_block().id, False) b.write_vote(vote) @@ -187,7 +187,7 @@ def test_get_asset_by_id(b, user_pk, user_sk): tx_transfer_signed = tx_transfer.sign([user_sk]) # create the block block = b.create_block([tx_transfer_signed]) - b.write_block(block, durability='hard') + b.write_block(block) # vote the block valid vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) diff --git a/tests/assets/test_divisible_assets.py b/tests/assets/test_divisible_assets.py index 13059c7c..01cb99e0 100644 --- a/tests/assets/test_divisible_assets.py +++ b/tests/assets/test_divisible_assets.py @@ -141,7 +141,7 @@ def test_single_in_single_own_single_out_single_own_transfer(b, user_pk, # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -175,7 +175,7 @@ def test_single_in_single_own_multiple_out_single_own_transfer(b, user_pk, # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -211,7 +211,7 @@ def test_single_in_single_own_single_out_multiple_own_transfer(b, user_pk, # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -252,7 +252,7 @@ def test_single_in_single_own_multiple_out_mix_own_transfer(b, user_pk, # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -294,7 +294,7 @@ def test_single_in_multiple_own_single_out_single_own_transfer(b, user_pk, # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -333,7 +333,7 @@ def test_multiple_in_single_own_single_out_single_own_transfer(b, user_pk, # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -370,7 +370,7 @@ def test_multiple_in_multiple_own_single_out_single_own_transfer(b, user_pk, # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -415,7 +415,7 @@ def test_muiltiple_in_mix_own_multiple_out_single_own_transfer(b, user_pk, # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -460,7 +460,7 @@ def test_muiltiple_in_mix_own_multiple_out_mix_own_transfer(b, user_pk, # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -512,7 +512,7 @@ def test_multiple_in_different_transactions(b, user_pk, user_sk): # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -528,7 +528,7 @@ def test_multiple_in_different_transactions(b, user_pk, user_sk): # create block block = b.create_block([tx_transfer1_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -569,7 +569,7 @@ def test_amount_error_transfer(b, user_pk, user_sk): # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -612,7 +612,7 @@ def test_threshold_same_public_key(b, user_pk, user_sk): # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -641,7 +641,7 @@ def test_sum_amount(b, user_pk, user_sk): # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -670,7 +670,7 @@ def test_divide(b, user_pk, user_sk): # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -703,7 +703,7 @@ def test_non_positive_amounts_on_transfer(b, user_pk): # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) @@ -729,7 +729,7 @@ def test_non_positive_amounts_on_transfer_validate(b, user_pk, user_sk): # create block block = b.create_block([tx_create_signed]) assert block.validate(b) == block - b.write_block(block, durability='hard') + b.write_block(block) # vote vote = b.vote(block.id, b.get_last_voted_block().id, True) b.write_vote(vote) diff --git a/tests/db/conftest.py b/tests/db/conftest.py index 860b489b..4959e2d2 100644 --- a/tests/db/conftest.py +++ b/tests/db/conftest.py @@ -89,7 +89,7 @@ def inputs(user_pk): for i in range(10) ] block = b.create_block(transactions) - b.write_block(block, durability='hard') + b.write_block(block) # 3. vote the blocks valid, so that the inputs are valid vote = b.vote(block.id, prev_block_id, True) @@ -127,7 +127,7 @@ def inputs_shared(user_pk, user2_pk): for i in range(10) ] block = b.create_block(transactions) - b.write_block(block, durability='hard') + b.write_block(block) # 3. vote the blocks valid, so that the inputs are valid vote = b.vote(block.id, prev_block_id, True) diff --git a/tests/db/test_bigchain_api.py b/tests/db/test_bigchain_api.py index ca63eb4b..723f7ae3 100644 --- a/tests/db/test_bigchain_api.py +++ b/tests/db/test_bigchain_api.py @@ -41,7 +41,7 @@ class TestBigchainApi(object): tx = tx.sign([b.me_private]) monkeypatch.setattr('time.time', lambda: 1) block1 = b.create_block([tx]) - b.write_block(block1, durability='hard') + b.write_block(block1) # Manipulate vote to create a cyclic Blockchain vote = b.vote(block1.id, b.get_last_voted_block().id, True) @@ -79,7 +79,7 @@ class TestBigchainApi(object): monkeypatch.setattr('time.time', lambda: 1) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) assert b.has_previous_vote(block.id, block.voters) is False @@ -99,21 +99,21 @@ class TestBigchainApi(object): monkeypatch.setattr('time.time', lambda: 1) block1 = b.create_block([tx]) - b.write_block(block1, durability='hard') + b.write_block(block1) monkeypatch.setattr('time.time', lambda: 2) transfer_tx = Transaction.transfer(tx.to_inputs(), [([b.me], 1)], tx.asset) transfer_tx = transfer_tx.sign([b.me_private]) block2 = b.create_block([transfer_tx]) - b.write_block(block2, durability='hard') + b.write_block(block2) monkeypatch.setattr('time.time', lambda: 3333333333) transfer_tx2 = Transaction.transfer(tx.to_inputs(), [([b.me], 1)], tx.asset) transfer_tx2 = transfer_tx2.sign([b.me_private]) block3 = b.create_block([transfer_tx2]) - b.write_block(block3, durability='hard') + b.write_block(block3) # Vote both block2 and block3 valid to provoke a double spend vote = b.vote(block2.id, b.get_last_voted_block().id, True) @@ -135,11 +135,11 @@ class TestBigchainApi(object): monkeypatch.setattr('time.time', lambda: 1) block1 = b.create_block([tx]) - b.write_block(block1, durability='hard') + b.write_block(block1) monkeypatch.setattr('time.time', lambda: 2222222222) block2 = b.create_block([tx]) - b.write_block(block2, durability='hard') + b.write_block(block2) # Vote both blocks valid (creating a double spend) vote = b.vote(block1.id, b.get_last_voted_block().id, True) @@ -159,13 +159,13 @@ class TestBigchainApi(object): tx1 = Transaction.create([b.me], [([b.me], 1)]) tx1 = tx1.sign([b.me_private]) block1 = b.create_block([tx1]) - b.write_block(block1, durability='hard') + b.write_block(block1) monkeypatch.setattr('time.time', lambda: 2222222222) tx2 = Transaction.create([b.me], [([b.me], 1)]) tx2 = tx2.sign([b.me_private]) block2 = b.create_block([tx2]) - b.write_block(block2, durability='hard') + b.write_block(block2) # vote the first block invalid vote = b.vote(block1.id, b.get_last_voted_block().id, False) @@ -178,6 +178,39 @@ class TestBigchainApi(object): assert b.get_transaction(tx1.id) is None assert b.get_transaction(tx2.id) == tx2 + def test_get_transactions_for_metadata(self, b, user_pk): + from bigchaindb.models import Transaction + + metadata = {'msg': 'Hello BigchainDB!'} + tx = Transaction.create([b.me], [([user_pk], 1)], metadata=metadata) + + block = b.create_block([tx]) + b.write_block(block) + + matches = b.get_transaction_by_metadata_id(tx.metadata.data_id) + assert len(matches) == 1 + assert matches[0].id == tx.id + + @pytest.mark.usefixtures('inputs') + def test_get_transactions_for_metadata_invalid_block(self, b, user_pk): + from bigchaindb.models import Transaction + + metadata = {'msg': 'Hello BigchainDB!'} + tx = Transaction.create([b.me], [([user_pk], 1)], metadata=metadata) + + block = b.create_block([tx]) + b.write_block(block) + # vote block invalid + vote = b.vote(block.id, b.get_last_voted_block().id, False) + b.write_vote(vote) + + matches = b.get_transaction_by_metadata_id(tx.metadata.data_id) + assert len(matches) == 0 + + def test_get_transactions_for_metadata_mismatch(self, b): + matches = b.get_transaction_by_metadata_id('missing') + assert not matches + @pytest.mark.usefixtures('inputs') def test_write_transaction(self, b, user_pk, user_sk): from bigchaindb.models import Transaction @@ -209,7 +242,7 @@ class TestBigchainApi(object): # create block and write it to the bighcain before retrieving the transaction block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) response, status = b.get_transaction(tx.id, include_status=True) # add validity information, which will be returned @@ -229,7 +262,7 @@ class TestBigchainApi(object): # create block block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) # vote the block invalid vote = b.vote(block.id, b.get_last_voted_block().id, False) @@ -255,7 +288,7 @@ class TestBigchainApi(object): # create block block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) # vote the block invalid vote = b.vote(block.id, b.get_last_voted_block().id, False) @@ -274,8 +307,8 @@ class TestBigchainApi(object): block = query.get_genesis_block(b.connection) assert len(block['block']['transactions']) == 1 - assert block['block']['transactions'][0]['operation'] == 'GENESIS' - assert block['block']['transactions'][0]['fulfillments'][0]['input'] is None + 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): from bigchaindb.common.exceptions import GenesisBlockAlreadyExistsError @@ -307,7 +340,7 @@ class TestBigchainApi(object): def test_get_previous_block(self, b): last_block = b.get_last_block() new_block = b.create_block([]) - b.write_block(new_block, durability='hard') + b.write_block(new_block) prev_block = b.get_previous_block(new_block) @@ -317,7 +350,7 @@ class TestBigchainApi(object): def test_get_previous_block_id(self, b): last_block = b.get_last_block() new_block = b.create_block([]) - b.write_block(new_block, durability='hard') + b.write_block(new_block) prev_block_id = b.get_previous_block_id(new_block) @@ -334,7 +367,7 @@ class TestBigchainApi(object): @pytest.mark.usefixtures('inputs') def test_get_block_by_id(self, b): new_block = dummy_block() - b.write_block(new_block, durability='hard') + b.write_block(new_block) assert b.get_block(new_block.id) == new_block.to_dict() block, status = b.get_block(new_block.id, include_status=True) @@ -363,9 +396,9 @@ class TestBigchainApi(object): monkeypatch.setattr('time.time', lambda: 3) block_3 = dummy_block() - b.write_block(block_1, durability='hard') - b.write_block(block_2, durability='hard') - b.write_block(block_3, durability='hard') + b.write_block(block_1) + b.write_block(block_2) + b.write_block(block_3) # make sure all the votes are written with the same timestamps monkeypatch.setattr('time.time', lambda: 4) @@ -390,9 +423,9 @@ class TestBigchainApi(object): monkeypatch.setattr('time.time', lambda: 3) block_3 = dummy_block() - b.write_block(block_1, durability='hard') - b.write_block(block_2, durability='hard') - b.write_block(block_3, durability='hard') + b.write_block(block_1) + b.write_block(block_2) + b.write_block(block_3) # make sure all the votes are written with different timestamps monkeypatch.setattr('time.time', lambda: 4) @@ -412,7 +445,7 @@ class TestBigchainApi(object): genesis = b.create_genesis_block() block_1 = dummy_block() - b.write_block(block_1, durability='hard') + b.write_block(block_1) b.write_vote(b.vote(block_1.id, genesis.id, True)) retrieved_block_1 = b.get_block(block_1.id) @@ -430,7 +463,7 @@ class TestBigchainApi(object): b.create_genesis_block() block_1 = dummy_block() - b.write_block(block_1, durability='hard') + b.write_block(block_1) # insert duplicate votes vote_1 = b.vote(block_1.id, b.get_last_voted_block().id, True) vote_2 = b.vote(block_1.id, b.get_last_voted_block().id, True) @@ -448,7 +481,7 @@ class TestBigchainApi(object): genesis = b.create_genesis_block() block_1 = dummy_block() - b.write_block(block_1, durability='hard') + b.write_block(block_1) # insert duplicate votes for i in range(2): b.write_vote(b.vote(block_1.id, genesis.id, True)) @@ -468,7 +501,7 @@ class TestBigchainApi(object): b.create_genesis_block() block_1 = dummy_block() - b.write_block(block_1, durability='hard') + b.write_block(block_1) vote_1 = b.vote(block_1.id, b.get_last_voted_block().id, True) # mangle the signature vote_1['signature'] = 'a' * 87 @@ -610,7 +643,7 @@ class TestTransactionValidation(object): b.write_transaction(signed_transfer_tx) block = b.create_block([signed_transfer_tx]) - b.write_block(block, durability='hard') + b.write_block(block) # vote block valid vote = b.vote(block.id, b.get_last_voted_block().id, True) @@ -618,7 +651,7 @@ class TestTransactionValidation(object): sleep(1) - signed_transfer_tx.metadata = {'different': 1} + signed_transfer_tx.metadata.data = {'different': 1} # FIXME: https://github.com/bigchaindb/bigchaindb/issues/592 with pytest.raises(DoubleSpend): b.validate_transaction(signed_transfer_tx) @@ -641,7 +674,7 @@ class TestTransactionValidation(object): # create block block = b.create_block([transfer_tx]) assert b.validate_block(block) == block - b.write_block(block, durability='hard') + b.write_block(block) # check that the transaction is still valid after being written to the # bigchain @@ -665,7 +698,7 @@ class TestTransactionValidation(object): # create block block = b.create_block([transfer_tx]) - b.write_block(block, durability='hard') + b.write_block(block) # create transaction with the undecided input tx_invalid = Transaction.transfer(transfer_tx.to_inputs(), @@ -810,7 +843,7 @@ class TestMultipleInputs(object): tx = Transaction.create([b.me], [([user_pk, user2_pk], 1)]) tx = tx.sign([b.me_private]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) # vote block valid vote = b.vote(block.id, b.get_last_voted_block().id, True) @@ -843,7 +876,7 @@ class TestMultipleInputs(object): tx = Transaction.create([b.me], [([user_pk, user2_pk], 1)]) tx = tx.sign([b.me_private]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) # vote block valid vote = b.vote(block.id, b.get_last_voted_block().id, True) @@ -871,7 +904,7 @@ class TestMultipleInputs(object): tx = Transaction.create([b.me], [([user_pk], 1)]) tx = tx.sign([b.me_private]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) owned_inputs_user1 = b.get_owned_ids(user_pk) owned_inputs_user2 = b.get_owned_ids(user2_pk) @@ -881,7 +914,7 @@ class TestMultipleInputs(object): tx = Transaction.transfer(tx.to_inputs(), [([user2_pk], 1)], tx.asset) tx = tx.sign([user_sk]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) owned_inputs_user1 = b.get_owned_ids(user_pk) owned_inputs_user2 = b.get_owned_ids(user2_pk) @@ -901,7 +934,7 @@ class TestMultipleInputs(object): tx = Transaction.create([b.me], [([user_pk], 1)]) tx = tx.sign([b.me_private]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) # vote the block VALID vote = b.vote(block.id, genesis.id, True) @@ -918,7 +951,7 @@ class TestMultipleInputs(object): tx.asset) tx_invalid = tx_invalid.sign([user_sk]) block = b.create_block([tx_invalid]) - b.write_block(block, durability='hard') + b.write_block(block) # vote the block invalid vote = b.vote(block.id, b.get_last_voted_block().id, False) @@ -946,7 +979,7 @@ class TestMultipleInputs(object): asset=asset) tx_create_signed = tx_create.sign([b.me_private]) block = b.create_block([tx_create_signed]) - b.write_block(block, durability='hard') + b.write_block(block) # get input owned_inputs_user1 = b.get_owned_ids(user_pk) @@ -963,7 +996,7 @@ class TestMultipleInputs(object): asset=tx_create.asset) tx_transfer_signed = tx_transfer.sign([user_sk]) block = b.create_block([tx_transfer_signed]) - b.write_block(block, durability='hard') + b.write_block(block) owned_inputs_user1 = b.get_owned_ids(user_pk) owned_inputs_user2 = b.get_owned_ids(user2_pk) @@ -982,7 +1015,7 @@ class TestMultipleInputs(object): tx = Transaction.create([b.me], [([user_pk, user2_pk], 1)]) tx = tx.sign([b.me_private]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) owned_inputs_user1 = b.get_owned_ids(user_pk) owned_inputs_user2 = b.get_owned_ids(user2_pk) @@ -994,7 +1027,7 @@ class TestMultipleInputs(object): tx = Transaction.transfer(tx.to_inputs(), [([user3_pk], 1)], tx.asset) tx = tx.sign([user_sk, user2_sk]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) owned_inputs_user1 = b.get_owned_ids(user_pk) owned_inputs_user2 = b.get_owned_ids(user2_pk) @@ -1010,7 +1043,7 @@ class TestMultipleInputs(object): tx = Transaction.create([b.me], [([user_pk], 1)]) tx = tx.sign([b.me_private]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) owned_inputs_user1 = b.get_owned_ids(user_pk).pop() @@ -1024,7 +1057,7 @@ class TestMultipleInputs(object): tx = Transaction.transfer(tx.to_inputs(), [([user2_pk], 1)], tx.asset) tx = tx.sign([user_sk]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) spent_inputs_user1 = b.get_spent(input_txid, input_cid) assert spent_inputs_user1 == tx @@ -1041,7 +1074,7 @@ class TestMultipleInputs(object): tx = Transaction.create([b.me], [([user_pk], 1)]) tx = tx.sign([b.me_private]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) # vote the block VALID vote = b.vote(block.id, genesis.id, True) @@ -1059,7 +1092,7 @@ class TestMultipleInputs(object): tx = Transaction.transfer(tx.to_inputs(), [([user2_pk], 1)], tx.asset) tx = tx.sign([user_sk]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) # vote the block invalid vote = b.vote(block.id, b.get_last_voted_block().id, False) @@ -1088,7 +1121,7 @@ class TestMultipleInputs(object): asset=asset) tx_create_signed = tx_create.sign([b.me_private]) block = b.create_block([tx_create_signed]) - b.write_block(block, durability='hard') + b.write_block(block) owned_inputs_user1 = b.get_owned_ids(user_pk) @@ -1102,7 +1135,7 @@ class TestMultipleInputs(object): asset=tx_create.asset) tx_transfer_signed = tx_transfer.sign([user_sk]) block = b.create_block([tx_transfer_signed]) - b.write_block(block, durability='hard') + b.write_block(block) # check that used inputs are marked as spent for ffill in tx_create.to_inputs()[:2]: @@ -1129,7 +1162,7 @@ class TestMultipleInputs(object): tx = tx.sign([b.me_private]) transactions.append(tx) block = b.create_block(transactions) - b.write_block(block, durability='hard') + b.write_block(block) owned_inputs_user1 = b.get_owned_ids(user_pk) @@ -1142,7 +1175,7 @@ class TestMultipleInputs(object): [([user3_pk], 1)], transactions[0].asset) tx = tx.sign([user_sk, user2_sk]) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) # check that used inputs are marked as spent assert b.get_spent(transactions[0].id, 0) == tx diff --git a/tests/pipelines/test_stale_monitor.py b/tests/pipelines/test_stale_monitor.py index 47705889..d90cf4f0 100644 --- a/tests/pipelines/test_stale_monitor.py +++ b/tests/pipelines/test_stale_monitor.py @@ -10,7 +10,7 @@ def test_get_stale(b, user_pk): from bigchaindb.models import Transaction tx = Transaction.create([b.me], [([user_pk], 1)]) tx = tx.sign([b.me_private]) - b.write_transaction(tx, durability='hard') + b.write_transaction(tx) stm = stale.StaleTransactionMonitor(timeout=0.001, backlog_reassign_delay=0.001) @@ -28,7 +28,7 @@ def test_reassign_transactions(b, user_pk): # test with single node tx = Transaction.create([b.me], [([user_pk], 1)]) tx = tx.sign([b.me_private]) - b.write_transaction(tx, durability='hard') + b.write_transaction(tx) stm = stale.StaleTransactionMonitor(timeout=0.001, backlog_reassign_delay=0.001) @@ -37,7 +37,7 @@ def test_reassign_transactions(b, user_pk): # test with federation tx = Transaction.create([b.me], [([user_pk], 1)]) tx = tx.sign([b.me_private]) - b.write_transaction(tx, durability='hard') + b.write_transaction(tx) stm = stale.StaleTransactionMonitor(timeout=0.001, backlog_reassign_delay=0.001) @@ -53,7 +53,7 @@ def test_reassign_transactions(b, user_pk): tx = Transaction.create([b.me], [([user_pk], 1)]) tx = tx.sign([b.me_private]) stm.bigchain.nodes_except_me = ['lol'] - b.write_transaction(tx, durability='hard') + b.write_transaction(tx) stm.bigchain.nodes_except_me = None tx = list(query.get_stale_transactions(b.connection, 0))[0] diff --git a/tests/pipelines/test_vote.py b/tests/pipelines/test_vote.py index 3e737424..0f471c0b 100644 --- a/tests/pipelines/test_vote.py +++ b/tests/pipelines/test_vote.py @@ -277,7 +277,7 @@ def test_valid_block_voting_with_transfer_transactions(monkeypatch, b): monkeypatch.setattr('time.time', lambda: 1111111111) block = b.create_block([tx]) - b.write_block(block, durability='hard') + b.write_block(block) # create a `TRANSFER` transaction test_user2_priv, test_user2_pub = crypto.generate_key_pair() @@ -287,7 +287,7 @@ def test_valid_block_voting_with_transfer_transactions(monkeypatch, b): monkeypatch.setattr('time.time', lambda: 2222222222) block2 = b.create_block([tx2]) - b.write_block(block2, durability='hard') + b.write_block(block2) inpipe = Pipe() outpipe = Pipe() @@ -501,11 +501,11 @@ def test_voter_considers_unvoted_blocks_when_single_node(monkeypatch, b): monkeypatch.setattr('time.time', lambda: 2222222222) block_1 = dummy_block(b) block_ids.append(block_1.id) - b.write_block(block_1, durability='hard') monkeypatch.setattr('time.time', lambda: 3333333333) + b.write_block(block_1) block_2 = dummy_block(b) block_ids.append(block_2.id) - b.write_block(block_2, durability='hard') + b.write_block(block_2) vote_pipeline = vote.create_pipeline() vote_pipeline.setup(indata=vote.get_changefeed(), outdata=outpipe) @@ -520,7 +520,7 @@ def test_voter_considers_unvoted_blocks_when_single_node(monkeypatch, b): monkeypatch.setattr('time.time', lambda: 4444444444) block_3 = dummy_block(b) block_ids.append(block_3.id) - b.write_block(block_3, durability='hard') + b.write_block(block_3) # Same as before with the two `get`s outpipe.get() @@ -547,12 +547,12 @@ def test_voter_chains_blocks_with_the_previous_ones(monkeypatch, b): monkeypatch.setattr('time.time', lambda: 2222222222) block_1 = dummy_block(b) block_ids.append(block_1.id) - b.write_block(block_1, durability='hard') + b.write_block(block_1) monkeypatch.setattr('time.time', lambda: 3333333333) block_2 = dummy_block(b) block_ids.append(block_2.id) - b.write_block(block_2, durability='hard') + b.write_block(block_2) vote_pipeline = vote.create_pipeline() vote_pipeline.setup(indata=vote.get_changefeed(), outdata=outpipe)