From aa3cc8bb3a7acb26da2671978d815f2a0689683f Mon Sep 17 00:00:00 2001 From: codegeschrei Date: Tue, 17 Jul 2018 18:09:19 +0200 Subject: [PATCH] Problem: some tests are not activated Solution: activate and remove or fix tests --- tests/test_core.py | 24 +++++++++--------------- tests/test_txlist.py | 39 ++++++++++----------------------------- 2 files changed, 19 insertions(+), 44 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index 9f6150e6..d473c9d1 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,5 +1,7 @@ import pytest +pytestmark = [pytest.mark.tendermint, pytest.mark.bdb] + @pytest.fixture def config(request, monkeypatch): @@ -17,6 +19,10 @@ def config(request, monkeypatch): 'connection_timeout': 5000, 'max_tries': 3 }, + 'tendermint': { + 'host': 'localhost', + 'port': 26657, + }, 'CONFIGURED': True, } @@ -37,7 +43,7 @@ def test_bigchain_class_default_initialization(config): assert bigchain.consensus == BaseConsensusRules -def test_bigchain_class_initialization_with_parameters(config): +def test_bigchain_class_initialization_with_parameters(): from bigchaindb.tendermint import BigchainDB from bigchaindb.backend import connect from bigchaindb.consensus import BaseConsensusRules @@ -48,7 +54,7 @@ def test_bigchain_class_initialization_with_parameters(config): 'name': 'this_is_the_db_name', } connection = connect(**init_db_kwargs) - bigchain = BigchainDB(connection=connection, **init_db_kwargs) + bigchain = BigchainDB(connection=connection) assert bigchain.connection == connection assert bigchain.connection.host == init_db_kwargs['host'] assert bigchain.connection.port == init_db_kwargs['port'] @@ -56,19 +62,7 @@ def test_bigchain_class_initialization_with_parameters(config): assert bigchain.consensus == BaseConsensusRules -def test_get_blocks_status_containing_tx(monkeypatch): - from bigchaindb.backend import query as backend_query - from bigchaindb.tendermint import BigchainDB - blocks = [ - {'id': 1}, {'id': 2} - ] - monkeypatch.setattr(backend_query, 'get_blocks_status_from_transaction', lambda x: blocks) - monkeypatch.setattr(BigchainDB, 'block_election_status', lambda x, y, z: BigchainDB.BLOCK_VALID) - bigchain = BigchainDB(public_key='pubkey', private_key='privkey') - with pytest.raises(Exception): - bigchain.get_blocks_status_containing_tx('txid') - - +@pytest.mark.skip @pytest.mark.genesis def test_get_spent_issue_1271(b, alice, bob, carol): from bigchaindb.models import Transaction diff --git a/tests/test_txlist.py b/tests/test_txlist.py index 61c31bb8..7b4f4d5d 100644 --- a/tests/test_txlist.py +++ b/tests/test_txlist.py @@ -4,46 +4,27 @@ This test module defines it's own fixture which is used by all the tests. """ import pytest +pytestmark = pytest.mark.tendermint + @pytest.fixture -def txlist(b, user_pk, user2_pk, user_sk, user2_sk, genesis_block): +def txlist(b, user_pk, user2_pk, user_sk, user2_sk): from bigchaindb.models import Transaction - prev_block_id = genesis_block.id - # Create first block with CREATE transactions + # Create two CREATE transactions create1 = Transaction.create([user_pk], [([user2_pk], 6)]) \ .sign([user_sk]) + create2 = Transaction.create([user2_pk], [([user2_pk], 5), ([user_pk], 5)]) \ - .sign([user2_sk]) - block1 = b.create_block([create1, create2]) - b.write_block(block1) + .sign([user2_sk]) - # Create second block with TRANSFER transactions + # Create a TRANSFER transactions transfer1 = Transaction.transfer(create1.to_inputs(), [([user_pk], 8)], create1.id).sign([user2_sk]) - block2 = b.create_block([transfer1]) - b.write_block(block2) - # Create block with double spend - tx_doublespend = Transaction.transfer(create1.to_inputs(), [([user_pk], 9)], - create1.id).sign([user2_sk]) - block_doublespend = b.create_block([tx_doublespend]) - b.write_block(block_doublespend) - - # Vote on all the blocks - prev_block_id = genesis_block.id - for bid in [block1.id, block2.id]: - vote = b.vote(bid, prev_block_id, True) - prev_block_id = bid - b.write_vote(vote) - - # Create undecided block - untx = Transaction.create([user_pk], [([user2_pk], 7)]) \ - .sign([user_sk]) - block_undecided = b.create_block([untx]) - b.write_block(block_undecided) + b.store_bulk_transactions([create1, create2, transfer1]) return type('', (), { 'create1': create1, @@ -54,8 +35,8 @@ def txlist(b, user_pk, user2_pk, user_sk, user2_sk, genesis_block): @pytest.mark.bdb def test_get_txlist_by_asset(b, txlist): res = b.get_transactions_filtered(txlist.create1.id) - assert set(tx.id for tx in res) == set([txlist.transfer1.id, - txlist.create1.id]) + assert sorted(set(tx.id for tx in res)) == sorted( + set([txlist.transfer1.id, txlist.create1.id])) @pytest.mark.bdb