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')
def __init__(self, bigchaindb=None): self.bigchaindb = bigchaindb or BigchainDB() self.block_txn_ids = [] self.block_txn_hash = '' self.block_transactions = [] self.validators = None self.new_height = None
def test_bigchain_class_default_initialization(config): from bigchaindb.tendermint import BigchainDB from bigchaindb.consensus import BaseConsensusRules from bigchaindb.backend.connection import Connection bigchain = BigchainDB() assert isinstance(bigchain.connection, Connection) assert bigchain.connection.host == config['database']['host'] assert bigchain.connection.port == config['database']['port'] assert bigchain.connection.dbname == config['database']['name'] assert bigchain.consensus == BaseConsensusRules
def test_bigchain_instance_raises_when_not_configured(request, monkeypatch): import bigchaindb from bigchaindb import config_utils from bigchaindb.common import exceptions from bigchaindb.tendermint import BigchainDB assert 'CONFIGURED' not in bigchaindb.config # We need to disable ``bigchaindb.config_utils.autoconfigure`` to avoid reading # from existing configurations monkeypatch.setattr(config_utils, 'autoconfigure', lambda: 0) with pytest.raises(exceptions.ConfigurationError): BigchainDB()
def test_bigchain_class_initialization_with_parameters(config): from bigchaindb.tendermint import BigchainDB from bigchaindb.backend import connect from bigchaindb.consensus import BaseConsensusRules init_db_kwargs = { 'backend': 'localmongodb', 'host': 'this_is_the_db_host', 'port': 12345, 'name': 'this_is_the_db_name', } connection = connect(**init_db_kwargs) bigchain = BigchainDB(connection=connection, **init_db_kwargs) assert bigchain.connection == connection assert bigchain.connection.host == init_db_kwargs['host'] assert bigchain.connection.port == init_db_kwargs['port'] assert bigchain.connection.dbname == init_db_kwargs['name'] assert bigchain.consensus == BaseConsensusRules
def tb(): from bigchaindb.tendermint import BigchainDB return BigchainDB()