mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge branch 'master' into generalize-election-management-commands
This commit is contained in:
commit
faff4d6466
@ -45,6 +45,7 @@ The following steps are what we do to release a new version of _BigchainDB Serve
|
||||
- In `bigchaindb/version.py`:
|
||||
- update `__version__` to e.g. `0.9.0` (with no `.dev` on the end)
|
||||
- update `__short_version__` to e.g. `0.9` (with no `.dev` on the end)
|
||||
- In the docs about installing BigchainDB (and Tendermint), and in the associated scripts, recommend/install a version of Tendermint that _actually works_ with the soon-to-be-released version of BigchainDB. You can find all such references by doing a search for the previously-recommended version number, such as `0.22.8`.
|
||||
- In `setup.py`, _maybe_ update the development status item in the `classifiers` list. For example, one allowed value is `"Development Status :: 5 - Production/Stable"`. The [allowed values are listed at pypi.python.org](https://pypi.python.org/pypi?%3Aaction=list_classifiers).
|
||||
|
||||
1. **Wait for all the tests to pass!**
|
||||
|
||||
@ -143,6 +143,9 @@ def create_abci_chains_indexes(conn, dbname):
|
||||
conn.conn[dbname]['abci_chains'].create_index('height',
|
||||
name='height',
|
||||
unique=True,)
|
||||
|
||||
logger.info('Create `abci_chains.chain_id` secondary index.')
|
||||
|
||||
conn.conn[dbname]['abci_chains'].create_index('chain_id',
|
||||
name='chain_id',
|
||||
unique=True)
|
||||
|
||||
@ -352,7 +352,7 @@ def store_validator_set(conn, validator_update):
|
||||
|
||||
|
||||
@singledispatch
|
||||
def store_election_results(conn, validator_update):
|
||||
def store_election_results(conn, election):
|
||||
"""Store election results"""
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
@ -22,6 +22,8 @@ properties:
|
||||
properties:
|
||||
node_id:
|
||||
type: string
|
||||
seed:
|
||||
type: string
|
||||
public_key:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
|
||||
@ -100,7 +100,7 @@ class App(BaseApplication):
|
||||
|
||||
block = Block(app_hash=app_hash, height=height, transactions=[])
|
||||
self.bigchaindb.store_block(block._asdict())
|
||||
self.bigchaindb.store_validator_set(height + 1, validator_set, None)
|
||||
self.bigchaindb.store_validator_set(height + 1, validator_set)
|
||||
abci_chain_height = 0 if known_chain is None else known_chain['height']
|
||||
self.bigchaindb.store_abci_chain(abci_chain_height,
|
||||
genesis.chain_id, True)
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
import base58
|
||||
from uuid import uuid4
|
||||
|
||||
from bigchaindb import backend
|
||||
from bigchaindb.elections.vote import Vote
|
||||
@ -105,7 +106,7 @@ class Election(Transaction):
|
||||
input_conditions = []
|
||||
|
||||
duplicates = any(txn for txn in current_transactions if txn.id == self.id)
|
||||
if bigchain.get_transaction(self.id) or duplicates:
|
||||
if bigchain.is_committed(self.id) or duplicates:
|
||||
raise DuplicateTransaction('transaction `{}` already exists'
|
||||
.format(self.id))
|
||||
|
||||
@ -131,18 +132,20 @@ class Election(Transaction):
|
||||
|
||||
@classmethod
|
||||
def generate(cls, initiator, voters, election_data, metadata=None):
|
||||
# Break symmetry in case we need to call an election with the same properties twice
|
||||
uuid = uuid4()
|
||||
election_data['seed'] = str(uuid)
|
||||
|
||||
(inputs, outputs) = cls.validate_create(initiator, voters, election_data, metadata)
|
||||
election = cls(cls.OPERATION, {'data': election_data}, inputs, outputs, metadata)
|
||||
cls.validate_schema(election.to_dict(), skip_id=True)
|
||||
cls.validate_schema(election.to_dict())
|
||||
return election
|
||||
|
||||
@classmethod
|
||||
def validate_schema(cls, tx, skip_id=False):
|
||||
def validate_schema(cls, tx):
|
||||
"""Validate the election transaction. Since `ELECTION` extends `CREATE` transaction, all the validations for
|
||||
`CREATE` transaction should be inherited
|
||||
"""
|
||||
if not skip_id:
|
||||
cls.validate_id(tx)
|
||||
_validate_schema(TX_SCHEMA_COMMON, tx)
|
||||
_validate_schema(TX_SCHEMA_CREATE, tx)
|
||||
if cls.TX_SCHEMA_CUSTOM:
|
||||
|
||||
@ -435,14 +435,13 @@ class BigchainDB(object):
|
||||
def store_pre_commit_state(self, state):
|
||||
return backend.query.store_pre_commit_state(self.connection, state)
|
||||
|
||||
def store_validator_set(self, height, validators, election_id):
|
||||
def store_validator_set(self, height, validators):
|
||||
"""Store validator set at a given `height`.
|
||||
NOTE: If the validator set already exists at that `height` then an
|
||||
exception will be raised.
|
||||
"""
|
||||
return backend.query.store_validator_set(self.connection, {'height': height,
|
||||
'validators': validators,
|
||||
'election_id': election_id})
|
||||
'validators': validators})
|
||||
|
||||
def store_abci_chain(self, height, chain_id, is_synced=True):
|
||||
return backend.query.store_abci_chain(self.connection, height,
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
from bigchaindb.common.exceptions import InvalidPowerChange
|
||||
from bigchaindb.tendermint_utils import public_key_to_base64
|
||||
from bigchaindb.elections.election import Election
|
||||
from bigchaindb.common.schema import (TX_SCHEMA_VALIDATOR_ELECTION)
|
||||
from .validator_utils import (new_validator_set, encode_validator, validate_asset_public_key)
|
||||
@ -33,8 +32,8 @@ class ValidatorElection(Election):
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def validate_schema(cls, tx, skip_id=False):
|
||||
super(ValidatorElection, cls).validate_schema(tx, skip_id=skip_id)
|
||||
def validate_schema(cls, tx):
|
||||
super(ValidatorElection, cls).validate_schema(tx)
|
||||
validate_asset_public_key(tx['asset']['data']['public_key'])
|
||||
|
||||
@classmethod
|
||||
@ -46,18 +45,5 @@ class ValidatorElection(Election):
|
||||
validator_updates)
|
||||
|
||||
updated_validator_set = [v for v in updated_validator_set if v['voting_power'] > 0]
|
||||
bigchain.store_validator_set(new_height+1, updated_validator_set, election.id)
|
||||
bigchain.store_validator_set(new_height+1, updated_validator_set)
|
||||
return encode_validator(election.asset['data'])
|
||||
|
||||
def show_election(self, bigchain):
|
||||
|
||||
new_validator = self.asset['data']
|
||||
|
||||
public_key = public_key_to_base64(new_validator['public_key']['value'])
|
||||
power = new_validator['power']
|
||||
node_id = new_validator['node_id']
|
||||
status = self.get_status(bigchain)
|
||||
|
||||
response = f'public_key={public_key}\npower={power}\nnode_id={node_id}\nstatus={status}'
|
||||
|
||||
return response
|
||||
|
||||
@ -25,7 +25,7 @@ After the installation of MongoDB is complete, run MongoDB using `sudo mongod`
|
||||
|
||||
### Installing a Tendermint Executable
|
||||
|
||||
Find [the version number of the latest Tendermint release](https://github.com/tendermint/tendermint/releases) and install it using the following, where 0.22.8 should be replaced by the latest released version number:
|
||||
The version of BigchainDB Server described in these docs only works well with Tendermint 0.22.8 (not a higher version number). Install that:
|
||||
|
||||
```bash
|
||||
$ sudo apt install -y unzip
|
||||
|
||||
@ -85,7 +85,7 @@ Note: The `mongodb` package is _not_ the official MongoDB package from MongoDB t
|
||||
|
||||
#### Install Tendermint
|
||||
|
||||
Install a [recent version of Tendermint][tendermint:releases]. BigchainDB Server requires version 0.22.8 or newer.
|
||||
The version of BigchainDB Server described in these docs only works well with Tendermint 0.22.8 (not a higher version number). Install that:
|
||||
|
||||
```
|
||||
sudo apt install -y unzip
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
[pytest]
|
||||
testpaths = tests/
|
||||
norecursedirs = .* *.egg *.egg-info env* devenv* docs
|
||||
addopts = -m tendermint
|
||||
addopts = -m "not abci"
|
||||
looponfailroots = bigchaindb tests
|
||||
|
||||
@ -6,9 +6,6 @@ import pytest
|
||||
import random
|
||||
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
def test_asset_transfer(b, signed_create_tx, user_pk, user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
|
||||
@ -8,9 +8,6 @@ import random
|
||||
from bigchaindb.common.exceptions import DoubleSpend
|
||||
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
# CREATE divisible asset
|
||||
# Single input
|
||||
# Single owners_before
|
||||
|
||||
@ -9,7 +9,7 @@ import pymongo
|
||||
from pymongo import MongoClient
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.bdb, pytest.mark.tendermint]
|
||||
pytestmark = pytest.mark.bdb
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@ -10,7 +10,7 @@ import pymongo
|
||||
from bigchaindb.backend import connect, query
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.tendermint, pytest.mark.bdb]
|
||||
pytestmark = pytest.mark.bdb
|
||||
|
||||
|
||||
def test_get_txids_filtered(signed_create_tx, signed_transfer_tx):
|
||||
|
||||
@ -5,9 +5,6 @@
|
||||
import pytest
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.bdb, pytest.mark.tendermint]
|
||||
|
||||
|
||||
def test_init_creates_db_tables_and_indexes():
|
||||
import bigchaindb
|
||||
from bigchaindb import backend
|
||||
|
||||
@ -5,9 +5,6 @@
|
||||
import pytest
|
||||
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
def test_get_connection_raises_a_configuration_error(monkeypatch):
|
||||
from bigchaindb.common.exceptions import ConfigurationError
|
||||
from bigchaindb.backend import connect
|
||||
|
||||
@ -2,14 +2,9 @@
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
import pytest
|
||||
|
||||
from pytest import mark, raises
|
||||
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
@mark.parametrize('schema_func_name,args_qty', (
|
||||
('create_database', 1),
|
||||
('create_tables', 1),
|
||||
|
||||
@ -8,9 +8,6 @@ from types import ModuleType
|
||||
import pytest
|
||||
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_module():
|
||||
return ModuleType('mock_module')
|
||||
|
||||
@ -27,8 +27,8 @@ def mock_db_init_with_existing_db(monkeypatch):
|
||||
|
||||
@pytest.fixture
|
||||
def mock_processes_start(monkeypatch):
|
||||
from bigchaindb.utils import Process
|
||||
monkeypatch.setattr(Process, 'run', lambda *args: None)
|
||||
from bigchaindb import start
|
||||
monkeypatch.setattr(start, 'start', lambda *args: None)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -56,7 +56,7 @@ def run_start_args(request):
|
||||
@pytest.fixture
|
||||
def mocked_setup_logging(mocker):
|
||||
return mocker.patch(
|
||||
'bigchaindb.commands.utils.setup_logging',
|
||||
'bigchaindb.log.setup_logging',
|
||||
autospec=True,
|
||||
spec_set=True,
|
||||
)
|
||||
|
||||
@ -14,7 +14,6 @@ from bigchaindb import ValidatorElection
|
||||
from tests.conftest import node_keys
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_make_sure_we_dont_remove_any_command():
|
||||
# thanks to: http://stackoverflow.com/a/18161115/597097
|
||||
from bigchaindb.commands.bigchaindb import create_parser
|
||||
@ -33,7 +32,6 @@ def test_make_sure_we_dont_remove_any_command():
|
||||
assert parser.parse_args(['election', 'show', 'ELECTION_ID']).command
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@patch('bigchaindb.commands.utils.start')
|
||||
def test_main_entrypoint(mock_start):
|
||||
from bigchaindb.commands.bigchaindb import main
|
||||
@ -42,22 +40,21 @@ def test_main_entrypoint(mock_start):
|
||||
assert mock_start.called
|
||||
|
||||
|
||||
def test_bigchain_run_start(mock_run_configure,
|
||||
mock_processes_start,
|
||||
mock_db_init_with_existing_db,
|
||||
mocked_setup_logging):
|
||||
from bigchaindb import config
|
||||
@patch('bigchaindb.log.setup_logging')
|
||||
@patch('bigchaindb.commands.bigchaindb._run_init')
|
||||
@patch('bigchaindb.config_utils.autoconfigure')
|
||||
def test_bigchain_run_start(mock_setup_logging, mock_run_init,
|
||||
mock_autoconfigure, mock_processes_start):
|
||||
from bigchaindb.commands.bigchaindb import run_start
|
||||
args = Namespace(config=None, yes=True,
|
||||
skip_initialize_database=False)
|
||||
run_start(args)
|
||||
mocked_setup_logging.assert_called_once_with(user_log_config=config['log'])
|
||||
assert mock_setup_logging.called
|
||||
|
||||
|
||||
# TODO Please beware, that if debugging, the "-s" switch for pytest will
|
||||
# interfere with capsys.
|
||||
# See related issue: https://github.com/pytest-dev/pytest/issues/128
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.usefixtures('ignore_local_config_file')
|
||||
def test_bigchain_show_config(capsys):
|
||||
from bigchaindb.commands.bigchaindb import run_show_config
|
||||
@ -78,7 +75,6 @@ def test_bigchain_show_config(capsys):
|
||||
assert output_config == config
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_bigchain_run_init_when_db_exists(mocker, capsys):
|
||||
from bigchaindb.commands.bigchaindb import run_init
|
||||
from bigchaindb.common.exceptions import DatabaseAlreadyExists
|
||||
@ -98,7 +94,6 @@ def test_bigchain_run_init_when_db_exists(mocker, capsys):
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test__run_init(mocker):
|
||||
from bigchaindb.commands.bigchaindb import _run_init
|
||||
bigchain_mock = mocker.patch(
|
||||
@ -114,7 +109,6 @@ def test__run_init(mocker):
|
||||
connection=bigchain_mock.return_value.connection)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@patch('bigchaindb.backend.schema.drop_database')
|
||||
def test_drop_db_when_assumed_yes(mock_db_drop):
|
||||
from bigchaindb.commands.bigchaindb import run_drop
|
||||
@ -124,7 +118,6 @@ def test_drop_db_when_assumed_yes(mock_db_drop):
|
||||
assert mock_db_drop.called
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@patch('bigchaindb.backend.schema.drop_database')
|
||||
def test_drop_db_when_interactive_yes(mock_db_drop, monkeypatch):
|
||||
from bigchaindb.commands.bigchaindb import run_drop
|
||||
@ -136,7 +129,6 @@ def test_drop_db_when_interactive_yes(mock_db_drop, monkeypatch):
|
||||
assert mock_db_drop.called
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@patch('bigchaindb.backend.schema.drop_database')
|
||||
def test_drop_db_when_db_does_not_exist(mock_db_drop, capsys):
|
||||
from bigchaindb import config
|
||||
@ -151,7 +143,6 @@ def test_drop_db_when_db_does_not_exist(mock_db_drop, capsys):
|
||||
name=config['database']['name'])
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@patch('bigchaindb.backend.schema.drop_database')
|
||||
def test_drop_db_does_not_drop_when_interactive_no(mock_db_drop, monkeypatch):
|
||||
from bigchaindb.commands.bigchaindb import run_drop
|
||||
@ -166,7 +157,6 @@ def test_drop_db_does_not_drop_when_interactive_no(mock_db_drop, monkeypatch):
|
||||
# TODO Beware if you are putting breakpoints in there, and using the '-s'
|
||||
# switch with pytest. It will just hang. Seems related to the monkeypatching of
|
||||
# input_on_stderr.
|
||||
@pytest.mark.tendermint
|
||||
def test_run_configure_when_config_does_not_exist(monkeypatch,
|
||||
mock_write_config,
|
||||
mock_generate_key_pair,
|
||||
@ -179,7 +169,6 @@ def test_run_configure_when_config_does_not_exist(monkeypatch,
|
||||
assert return_value is None
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_run_configure_when_config_does_exist(monkeypatch,
|
||||
mock_write_config,
|
||||
mock_generate_key_pair,
|
||||
@ -201,7 +190,6 @@ def test_run_configure_when_config_does_exist(monkeypatch,
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.parametrize('backend', (
|
||||
'localmongodb',
|
||||
))
|
||||
@ -235,10 +223,9 @@ def test_run_start_when_db_already_exists(mocker,
|
||||
monkeypatch,
|
||||
run_start_args,
|
||||
mocked_setup_logging):
|
||||
from bigchaindb import config
|
||||
from bigchaindb.commands.bigchaindb import run_start
|
||||
from bigchaindb.common.exceptions import DatabaseAlreadyExists
|
||||
mocked_start = mocker.patch('bigchaindb.processes.start')
|
||||
mocked_start = mocker.patch('bigchaindb.start.start')
|
||||
|
||||
def mock_run_init():
|
||||
raise DatabaseAlreadyExists()
|
||||
@ -246,11 +233,9 @@ def test_run_start_when_db_already_exists(mocker,
|
||||
monkeypatch.setattr(
|
||||
'bigchaindb.commands.bigchaindb._run_init', mock_run_init)
|
||||
run_start(run_start_args)
|
||||
mocked_setup_logging.assert_called_once_with(user_log_config=config['log'])
|
||||
assert mocked_start.called
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@patch('bigchaindb.commands.utils.start')
|
||||
def test_calling_main(start_mock, monkeypatch):
|
||||
from bigchaindb.commands.bigchaindb import main
|
||||
@ -295,7 +280,6 @@ def test_recover_db_on_start(mock_run_recover,
|
||||
assert mock_start.called
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_run_recover(b, alice, bob):
|
||||
from bigchaindb.commands.bigchaindb import run_recover
|
||||
@ -365,7 +349,6 @@ def test_election_new_upsert_validator_with_tendermint(b, priv_validator_path, u
|
||||
assert b.get_transaction(election_id)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_election_new_upsert_validator_without_tendermint(caplog, b, priv_validator_path, user_sk):
|
||||
from bigchaindb.commands.bigchaindb import run_election_new_upsert_validator
|
||||
@ -391,7 +374,6 @@ def test_election_new_upsert_validator_without_tendermint(caplog, b, priv_valida
|
||||
assert b.get_transaction(election_id)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_election_new_upsert_validator_invalid_election(caplog, b, priv_validator_path, user_sk):
|
||||
from bigchaindb.commands.bigchaindb import run_election_new_upsert_validator
|
||||
@ -409,7 +391,6 @@ def test_election_new_upsert_validator_invalid_election(caplog, b, priv_validato
|
||||
assert caplog.records[0].msg.__class__ == FileNotFoundError
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_election_new_upsert_validator_invalid_power(caplog, b, priv_validator_path, user_sk):
|
||||
from bigchaindb.commands.bigchaindb import run_election_new_upsert_validator
|
||||
@ -461,7 +442,6 @@ def test_election_approve_with_tendermint(b, priv_validator_path, user_sk, valid
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.tendermint
|
||||
def test_election_approve_without_tendermint(caplog, b, priv_validator_path, new_validator, node_key):
|
||||
from bigchaindb.commands.bigchaindb import run_election_approve
|
||||
from argparse import Namespace
|
||||
@ -481,7 +461,6 @@ def test_election_approve_without_tendermint(caplog, b, priv_validator_path, new
|
||||
assert b.get_transaction(approval_id)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_election_approve_failure(caplog, b, priv_validator_path, new_validator, node_key):
|
||||
from bigchaindb.commands.bigchaindb import run_election_approve
|
||||
@ -506,7 +485,6 @@ def test_election_approve_failure(caplog, b, priv_validator_path, new_validator,
|
||||
assert caplog.records[0].msg == 'Failed to commit vote'
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_election_approve_called_with_bad_key(caplog, b, bad_validator_path, new_validator, node_key):
|
||||
from bigchaindb.commands.bigchaindb import run_election_approve
|
||||
|
||||
@ -10,8 +10,6 @@ import pytest
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def reset_bigchaindb_config(monkeypatch):
|
||||
|
||||
@ -10,7 +10,7 @@ from bigchaindb.common.crypto import generate_key_pair
|
||||
from bigchaindb.common.memoize import to_dict, from_dict
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.tendermint, pytest.mark.bdb]
|
||||
pytestmark = pytest.mark.bdb
|
||||
|
||||
|
||||
def test_memoize_to_dict(b):
|
||||
|
||||
@ -8,8 +8,6 @@ properties related to validation.
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from hypothesis import given
|
||||
from hypothesis_regex import regex
|
||||
from pytest import raises
|
||||
@ -25,9 +23,6 @@ UNSUPPORTED_CRYPTOCONDITION_TYPES = (
|
||||
'preimage-sha-256', 'prefix-sha-256', 'rsa-sha-256')
|
||||
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
################################################################################
|
||||
# Test of schema utils
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ from cryptoconditions import Ed25519Sha256
|
||||
from pytest import mark, raises
|
||||
from sha3 import sha3_256
|
||||
|
||||
pytestmark = [mark.tendermint, mark.bdb]
|
||||
pytestmark = mark.bdb
|
||||
|
||||
|
||||
def test_input_serialization(ffill_uri, user_pub):
|
||||
|
||||
@ -12,7 +12,6 @@ pytestmark = pytest.mark.bdb
|
||||
|
||||
class TestBigchainApi(object):
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_spent_with_double_spend_detected(self, b, alice):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.common.exceptions import DoubleSpend
|
||||
@ -43,7 +42,6 @@ class TestBigchainApi(object):
|
||||
with pytest.raises(CriticalDoubleSpend):
|
||||
b.get_spent(tx.id, 0)
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_double_inclusion(self, b, alice):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.backend.exceptions import OperationError
|
||||
@ -56,7 +54,6 @@ class TestBigchainApi(object):
|
||||
with pytest.raises(OperationError):
|
||||
b.store_bulk_transactions([tx])
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_text_search(self, b, alice):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
@ -81,7 +78,6 @@ class TestBigchainApi(object):
|
||||
assert len(assets) == 3
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
@pytest.mark.tendermint
|
||||
def test_non_create_input_not_found(self, b, user_pk):
|
||||
from cryptoconditions import Ed25519Sha256
|
||||
from bigchaindb.common.exceptions import InputDoesNotExist
|
||||
@ -97,7 +93,6 @@ class TestBigchainApi(object):
|
||||
with pytest.raises(InputDoesNotExist):
|
||||
tx.validate(b)
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_write_transaction(self, b, user_sk, user_pk, alice, create_tx):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
@ -120,7 +115,6 @@ class TestBigchainApi(object):
|
||||
|
||||
class TestTransactionValidation(object):
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_non_create_input_not_found(self, b, signed_transfer_tx):
|
||||
from bigchaindb.common.exceptions import InputDoesNotExist
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
@ -129,7 +123,6 @@ class TestTransactionValidation(object):
|
||||
with pytest.raises(InputDoesNotExist):
|
||||
b.validate_transaction(signed_transfer_tx)
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_non_create_valid_input_wrong_owner(self, b, user_pk):
|
||||
from bigchaindb.common.crypto import generate_key_pair
|
||||
@ -147,7 +140,6 @@ class TestTransactionValidation(object):
|
||||
with pytest.raises(InvalidSignature):
|
||||
b.validate_transaction(tx)
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_non_create_double_spend(self, b, signed_create_tx,
|
||||
signed_transfer_tx, double_spend_tx):
|
||||
@ -161,7 +153,6 @@ class TestTransactionValidation(object):
|
||||
|
||||
class TestMultipleInputs(object):
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_transfer_single_owner_single_input(self, b, inputs, user_pk,
|
||||
user_sk):
|
||||
from bigchaindb.common import crypto
|
||||
@ -181,7 +172,6 @@ class TestMultipleInputs(object):
|
||||
assert len(tx.inputs) == 1
|
||||
assert len(tx.outputs) == 1
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_single_owner_before_multiple_owners_after_single_input(self, b,
|
||||
user_sk,
|
||||
user_pk,
|
||||
@ -203,7 +193,6 @@ class TestMultipleInputs(object):
|
||||
assert len(tx.inputs) == 1
|
||||
assert len(tx.outputs) == 1
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_multiple_owners_before_single_owner_after_single_input(self, b,
|
||||
user_sk,
|
||||
@ -232,7 +221,6 @@ class TestMultipleInputs(object):
|
||||
assert len(transfer_tx.inputs) == 1
|
||||
assert len(transfer_tx.outputs) == 1
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_multiple_owners_before_multiple_owners_after_single_input(self, b,
|
||||
user_sk,
|
||||
@ -262,7 +250,6 @@ class TestMultipleInputs(object):
|
||||
assert len(tx.inputs) == 1
|
||||
assert len(tx.outputs) == 1
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_owned_ids_single_tx_single_output(self, b, user_sk, user_pk, alice):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
@ -290,7 +277,6 @@ class TestMultipleInputs(object):
|
||||
assert owned_inputs_user1 == [TransactionLink(tx.id, 0)]
|
||||
assert owned_inputs_user2 == [TransactionLink(tx_transfer.id, 0)]
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_owned_ids_single_tx_multiple_outputs(self, b, user_sk,
|
||||
user_pk, alice):
|
||||
from bigchaindb.common import crypto
|
||||
@ -326,7 +312,6 @@ class TestMultipleInputs(object):
|
||||
assert owned_inputs_user2 == [TransactionLink(tx_transfer.id, 0),
|
||||
TransactionLink(tx_transfer.id, 1)]
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_owned_ids_multiple_owners(self, b, user_sk, user_pk, alice):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
@ -359,7 +344,6 @@ class TestMultipleInputs(object):
|
||||
assert owned_inputs_user1 == owned_inputs_user2
|
||||
assert not spent_user1
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_spent_single_tx_single_output(self, b, user_sk, user_pk, alice):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
@ -386,7 +370,6 @@ class TestMultipleInputs(object):
|
||||
spent_inputs_user1 = b.get_spent(input_txid, 0)
|
||||
assert spent_inputs_user1 == tx
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_spent_single_tx_multiple_outputs(self, b, user_sk, user_pk, alice):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
@ -424,7 +407,6 @@ class TestMultipleInputs(object):
|
||||
# spendable by BigchainDB
|
||||
assert b.get_spent(tx_create.to_inputs()[2].fulfills.txid, 2) is None
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_spent_multiple_owners(self, b, user_sk, user_pk, alice):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
@ -461,7 +443,6 @@ class TestMultipleInputs(object):
|
||||
assert b.get_spent(unspent.id, 0) is None
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_outputs_filtered_only_unspent():
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
from bigchaindb.lib import BigchainDB
|
||||
@ -478,7 +459,6 @@ def test_get_outputs_filtered_only_unspent():
|
||||
assert out == [TransactionLink('b', 2)]
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_outputs_filtered_only_spent():
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
from bigchaindb.lib import BigchainDB
|
||||
@ -494,7 +474,6 @@ def test_get_outputs_filtered_only_spent():
|
||||
assert out == [TransactionLink('b', 2)]
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@patch('bigchaindb.fastquery.FastQuery.filter_unspent_outputs')
|
||||
@patch('bigchaindb.fastquery.FastQuery.filter_spent_outputs')
|
||||
def test_get_outputs_filtered(filter_spent, filter_unspent):
|
||||
@ -512,7 +491,6 @@ def test_get_outputs_filtered(filter_spent, filter_unspent):
|
||||
assert out == get_outputs.return_value
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_cant_spend_same_input_twice_in_tx(b, alice):
|
||||
"""Recreate duplicated fulfillments bug
|
||||
https://github.com/bigchaindb/bigchaindb/issues/1099
|
||||
@ -536,7 +514,6 @@ def test_cant_spend_same_input_twice_in_tx(b, alice):
|
||||
tx_transfer_signed.validate(b)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_transaction_unicode(b, alice):
|
||||
import copy
|
||||
from bigchaindb.common.utils import serialize
|
||||
|
||||
@ -28,7 +28,7 @@ from bigchaindb.upsert_validator.validator_utils import new_validator_set
|
||||
from bigchaindb.tendermint_utils import public_key_to_base64
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.tendermint, pytest.mark.bdb]
|
||||
pytestmark = pytest.mark.bdb
|
||||
|
||||
|
||||
def encode_tx_to_bytes(transaction):
|
||||
@ -427,7 +427,7 @@ def test_new_validator_set(b):
|
||||
|
||||
validators = [node1]
|
||||
updates = [node1_new_power, node2]
|
||||
b.store_validator_set(1, validators, 'election_id')
|
||||
b.store_validator_set(1, validators)
|
||||
updated_validator_set = new_validator_set(b.get_validators(1), updates)
|
||||
|
||||
updated_validators = []
|
||||
|
||||
@ -10,7 +10,6 @@ from aiohttp import ClientSession
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_process_event_new_block():
|
||||
from bigchaindb.event_stream import process_event
|
||||
|
||||
@ -48,7 +47,6 @@ def test_process_event_new_block():
|
||||
assert isinstance(block.data['height'], int)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_process_event_empty_block():
|
||||
from bigchaindb.event_stream import process_event
|
||||
|
||||
@ -69,7 +67,6 @@ def test_process_event_empty_block():
|
||||
assert event_queue.empty()
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_process_unknown_event():
|
||||
from bigchaindb.event_stream import process_event
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ from bigchaindb.common.transaction import TransactionLink
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.bdb, pytest.mark.tendermint]
|
||||
pytestmark = pytest.mark.bdb
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
||||
@ -14,7 +14,6 @@ from abci.encoding import read_messages
|
||||
from io import BytesIO
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_app(b, init_chain_request):
|
||||
from bigchaindb import App
|
||||
|
||||
@ -18,9 +18,6 @@ from bigchaindb import backend
|
||||
from bigchaindb.lib import Block
|
||||
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_asset_is_separated_from_transaciton(b):
|
||||
import copy
|
||||
|
||||
@ -10,11 +10,6 @@ try:
|
||||
except ImportError:
|
||||
from sha3 import sha3_256
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
def test_encode_decode_transaction(b):
|
||||
from bigchaindb.tendermint_utils import (encode_transaction,
|
||||
|
||||
@ -13,9 +13,6 @@ import bigchaindb
|
||||
ORIGINAL_CONFIG = copy.deepcopy(bigchaindb._config)
|
||||
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
@pytest.fixture(scope='function', autouse=True)
|
||||
def clean_config(monkeypatch, request):
|
||||
original_config = copy.deepcopy(ORIGINAL_CONFIG)
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config(request, monkeypatch):
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
import pytest
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
def test_event_handler():
|
||||
|
||||
@ -8,8 +8,6 @@ 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):
|
||||
|
||||
@ -7,8 +7,6 @@ from unittest.mock import patch, call
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_queue(monkeypatch):
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
@ -46,6 +47,15 @@ def valid_election_b(b, node_key, new_validator):
|
||||
new_validator, None).sign([node_key.private_key])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@patch('bigchaindb.elections.election.uuid4', lambda: 'mock_uuid4')
|
||||
def fixed_seed_election(b_mock, node_key, new_validator):
|
||||
voters = ValidatorElection.recipients(b_mock)
|
||||
return ValidatorElection.generate([node_key.public_key],
|
||||
voters,
|
||||
new_validator, None).sign([node_key.private_key])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ongoing_election(b, valid_election, ed25519_node_keys):
|
||||
validators = b.get_validators(height=1)
|
||||
|
||||
@ -16,7 +16,6 @@ from tests.utils import generate_block
|
||||
pytestmark = [pytest.mark.execute]
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_upsert_validator_valid_election_vote(b_mock, valid_election, ed25519_node_keys):
|
||||
b_mock.store_bulk_transactions([valid_election])
|
||||
@ -35,7 +34,6 @@ def test_upsert_validator_valid_election_vote(b_mock, valid_election, ed25519_no
|
||||
assert vote.validate(b_mock)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_upsert_validator_valid_non_election_vote(b_mock, valid_election, ed25519_node_keys):
|
||||
b_mock.store_bulk_transactions([valid_election])
|
||||
@ -55,7 +53,6 @@ def test_upsert_validator_valid_non_election_vote(b_mock, valid_election, ed2551
|
||||
.sign([key0.private_key])
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_upsert_validator_delegate_election_vote(b_mock, valid_election, ed25519_node_keys):
|
||||
alice = generate_key_pair()
|
||||
@ -92,7 +89,6 @@ def test_upsert_validator_delegate_election_vote(b_mock, valid_election, ed25519
|
||||
assert key0_casted_vote.validate(b_mock)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_upsert_validator_invalid_election_vote(b_mock, valid_election, ed25519_node_keys):
|
||||
b_mock.store_bulk_transactions([valid_election])
|
||||
@ -113,7 +109,6 @@ def test_upsert_validator_invalid_election_vote(b_mock, valid_election, ed25519_
|
||||
assert vote.validate(b_mock)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_valid_election_votes_received(b_mock, valid_election, ed25519_node_keys):
|
||||
alice = generate_key_pair()
|
||||
@ -159,7 +154,6 @@ def test_valid_election_votes_received(b_mock, valid_election, ed25519_node_keys
|
||||
assert valid_election.get_commited_votes(b_mock) == votes-2
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_valid_election_conclude(b_mock, valid_election, ed25519_node_keys):
|
||||
|
||||
@ -234,7 +228,7 @@ def test_upsert_validator(b, node_key, node_keys, ed25519_node_keys):
|
||||
|
||||
latest_block = b.get_latest_block()
|
||||
# reset the validator set
|
||||
b.store_validator_set(latest_block['height'], validators, 'previous_election_id')
|
||||
b.store_validator_set(latest_block['height'], validators)
|
||||
|
||||
power = 1
|
||||
public_key = '9B3119650DF82B9A5D8A12E38953EA47475C09F0C48A4E6A0ECE182944B24403'
|
||||
@ -273,7 +267,6 @@ def test_upsert_validator(b, node_key, node_keys, ed25519_node_keys):
|
||||
assert (public_key64 in validator_pub_keys)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@pytest.mark.bdb
|
||||
def test_get_validator_update(b, node_keys, node_key, ed25519_node_keys):
|
||||
reset_validator_set(b, node_keys, 1)
|
||||
@ -303,18 +296,15 @@ def test_get_validator_update(b, node_keys, node_key, ed25519_node_keys):
|
||||
assert not ValidatorElection.approved_update(b, 4, [tx_vote0, tx_vote1])
|
||||
|
||||
update = ValidatorElection.approved_update(b, 4, [tx_vote0, tx_vote1, tx_vote2])
|
||||
update_public_key = None
|
||||
if update:
|
||||
update_public_key = codecs.encode(update.pub_key.data, 'base64').decode().rstrip('\n')
|
||||
assert update
|
||||
update_public_key = codecs.encode(update.pub_key.data, 'base64').decode().rstrip('\n')
|
||||
assert update_public_key == public_key64
|
||||
|
||||
b.store_bulk_transactions([tx_vote0, tx_vote1])
|
||||
|
||||
update = ValidatorElection.approved_update(b, 4, [tx_vote2])
|
||||
if update:
|
||||
update_public_key = codecs.encode(update.pub_key.data, 'base64').decode().rstrip('\n')
|
||||
assert update
|
||||
update_public_key = codecs.encode(update.pub_key.data, 'base64').decode().rstrip('\n')
|
||||
assert update_public_key == public_key64
|
||||
|
||||
# remove validator
|
||||
@ -372,4 +362,4 @@ def reset_validator_set(b, node_keys, height):
|
||||
validators.append({'public_key': {'type': 'ed25519-base64',
|
||||
'value': node_pub},
|
||||
'voting_power': 10})
|
||||
b.store_validator_set(height, validators, 'election_id')
|
||||
b.store_validator_set(height, validators)
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
from argparse import Namespace
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
@ -13,7 +14,7 @@ from bigchaindb.common.exceptions import (DuplicateTransaction,
|
||||
MultipleInputsError,
|
||||
InvalidPowerChange)
|
||||
|
||||
pytestmark = [pytest.mark.tendermint, pytest.mark.bdb]
|
||||
pytestmark = pytest.mark.bdb
|
||||
|
||||
|
||||
def test_upsert_validator_valid_election(b_mock, new_validator, node_key):
|
||||
@ -72,16 +73,17 @@ def test_upsert_validator_invalid_inputs_election(b_mock, new_validator, node_ke
|
||||
election.validate(b_mock)
|
||||
|
||||
|
||||
def test_upsert_validator_invalid_election(b_mock, new_validator, node_key, valid_election):
|
||||
@patch('bigchaindb.elections.election.uuid4', lambda: 'mock_uuid4')
|
||||
def test_upsert_validator_invalid_election(b_mock, new_validator, node_key, fixed_seed_election):
|
||||
voters = ValidatorElection.recipients(b_mock)
|
||||
duplicate_election = ValidatorElection.generate([node_key.public_key],
|
||||
voters,
|
||||
new_validator, None).sign([node_key.private_key])
|
||||
|
||||
with pytest.raises(DuplicateTransaction):
|
||||
valid_election.validate(b_mock, [duplicate_election])
|
||||
fixed_seed_election.validate(b_mock, [duplicate_election])
|
||||
|
||||
b_mock.store_bulk_transactions([valid_election])
|
||||
b_mock.store_bulk_transactions([fixed_seed_election])
|
||||
|
||||
with pytest.raises(DuplicateTransaction):
|
||||
duplicate_election.validate(b_mock)
|
||||
|
||||
@ -17,8 +17,6 @@ from bigchaindb.common.exceptions import (AmountError,
|
||||
ThresholdTooDeep)
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
################################################################################
|
||||
# Helper functions
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ import pytest
|
||||
ASSETS_ENDPOINT = '/api/v1/assets/'
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_assets_with_empty_text_search(client):
|
||||
res = client.get(ASSETS_ENDPOINT + '?search=')
|
||||
assert res.json == {'status': 400,
|
||||
@ -15,14 +14,12 @@ def test_get_assets_with_empty_text_search(client):
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_assets_with_missing_text_search(client):
|
||||
res = client.get(ASSETS_ENDPOINT)
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.tendermint
|
||||
def test_get_assets_tendermint(client, b, alice):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
@ -49,7 +46,6 @@ def test_get_assets_tendermint(client, b, alice):
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.tendermint
|
||||
def test_get_assets_limit_tendermint(client, b, alice):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
|
||||
@ -9,8 +9,6 @@ from bigchaindb.lib import Block
|
||||
|
||||
BLOCKS_ENDPOINT = '/api/v1/blocks/'
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
@ -73,29 +71,3 @@ def test_get_blocks_by_txid_endpoint_returns_empty_list_not_found(client):
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123')
|
||||
assert res.status_code == 200
|
||||
assert len(res.json) == 0
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
def test_get_blocks_by_txid_endpoint_returns_400_bad_query_params(client):
|
||||
res = client.get(BLOCKS_ENDPOINT)
|
||||
assert res.status_code == 400
|
||||
|
||||
res = client.get(BLOCKS_ENDPOINT + '?ts_id=123')
|
||||
assert res.status_code == 400
|
||||
assert res.json == {
|
||||
'message': {
|
||||
'transaction_id': 'Missing required parameter in the JSON body or the post body or the query string'
|
||||
}
|
||||
}
|
||||
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123&foo=123')
|
||||
assert res.status_code == 400
|
||||
assert res.json == {
|
||||
'message': 'Unknown arguments: foo'
|
||||
}
|
||||
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123&status=123')
|
||||
assert res.status_code == 400
|
||||
assert res.json == {
|
||||
'message': 'Unknown arguments: status'
|
||||
}
|
||||
|
||||
@ -50,7 +50,5 @@ def test_get_blocks_by_txid_endpoint_returns_400_bad_query_params(client):
|
||||
res = client.get(BLOCKS_ENDPOINT + '?transaction_id=123&status=123')
|
||||
assert res.status_code == 400
|
||||
assert res.json == {
|
||||
'message': {
|
||||
'status': '123 is not a valid choice'
|
||||
}
|
||||
'message': 'Unknown arguments: status'
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ def test_api_v1_endpoint(client, wsserver_base_url):
|
||||
'streams': '{}/api/v1/streams/valid_transactions'.format(
|
||||
wsserver_base_url),
|
||||
'metadata': '/metadata/',
|
||||
'validators': '/validators'
|
||||
}
|
||||
res = client.get('/api/v1')
|
||||
assert res.json == api_v1_info
|
||||
|
||||
@ -7,7 +7,6 @@ import pytest
|
||||
METADATA_ENDPOINT = '/api/v1/metadata/'
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_metadata_with_empty_text_search(client):
|
||||
res = client.get(METADATA_ENDPOINT + '?search=')
|
||||
assert res.json == {'status': 400,
|
||||
@ -15,14 +14,12 @@ def test_get_metadata_with_empty_text_search(client):
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_metadata_with_missing_text_search(client):
|
||||
res = client.get(METADATA_ENDPOINT)
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.tendermint
|
||||
def test_get_metadata_tendermint(client, b, alice):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
@ -50,7 +47,6 @@ def test_get_metadata_tendermint(client, b, alice):
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.tendermint
|
||||
def test_get_metadata_limit_tendermint(client, b, alice):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ pytestmark = [pytest.mark.bdb, pytest.mark.usefixtures('inputs')]
|
||||
OUTPUTS_ENDPOINT = '/api/v1/outputs/'
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_outputs_endpoint(client, user_pk):
|
||||
m = MagicMock()
|
||||
m.txid = 'a'
|
||||
@ -26,7 +25,6 @@ def test_get_outputs_endpoint(client, user_pk):
|
||||
gof.assert_called_once_with(user_pk, None)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_outputs_endpoint_unspent(client, user_pk):
|
||||
m = MagicMock()
|
||||
m.txid = 'a'
|
||||
@ -40,7 +38,6 @@ def test_get_outputs_endpoint_unspent(client, user_pk):
|
||||
gof.assert_called_once_with(user_pk, False)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_outputs_endpoint_spent(client, user_pk):
|
||||
m = MagicMock()
|
||||
m.txid = 'a'
|
||||
@ -54,13 +51,11 @@ def test_get_outputs_endpoint_spent(client, user_pk):
|
||||
gof.assert_called_once_with(user_pk, True)
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_outputs_endpoint_without_public_key(client):
|
||||
res = client.get(OUTPUTS_ENDPOINT)
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_outputs_endpoint_with_invalid_public_key(client):
|
||||
expected = {'message': {'public_key': 'Invalid base58 ed25519 key'}}
|
||||
res = client.get(OUTPUTS_ENDPOINT + '?public_key=abc')
|
||||
@ -68,7 +63,6 @@ def test_get_outputs_endpoint_with_invalid_public_key(client):
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_outputs_endpoint_with_invalid_spent(client, user_pk):
|
||||
expected = {'message': {'spent': 'Boolean value must be "true" or "false" (lowercase)'}}
|
||||
params = '?spent=tru&public_key={}'.format(user_pk)
|
||||
@ -77,6 +71,7 @@ def test_get_outputs_endpoint_with_invalid_spent(client, user_pk):
|
||||
assert res.status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.abci
|
||||
@pytest.mark.bdb
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_get_divisble_transactions_returns_500(b, client):
|
||||
@ -87,8 +82,7 @@ def test_get_divisble_transactions_returns_500(b, client):
|
||||
TX_ENDPOINT = '/api/v1/transactions'
|
||||
|
||||
def mine(tx_list):
|
||||
block = b.create_block(tx_list)
|
||||
b.write_block(block)
|
||||
b.store_bulk_transactions(tx_list)
|
||||
|
||||
alice_priv, alice_pub = crypto.generate_key_pair()
|
||||
bob_priv, bob_pub = crypto.generate_key_pair()
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
def test_valid_txid():
|
||||
from bigchaindb.web.views.parameters import valid_txid
|
||||
|
||||
@ -2,10 +2,6 @@
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
def test_settings():
|
||||
import bigchaindb
|
||||
|
||||
@ -23,7 +23,6 @@ def test_get_transaction_endpoint(client, posted_create_tx):
|
||||
assert res.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_get_transaction_returns_404_if_not_found(client):
|
||||
res = client.get(TX_ENDPOINT + '123')
|
||||
assert res.status_code == 404
|
||||
@ -361,7 +360,6 @@ def test_post_wrong_asset_division_transfer_returns_400(b, client, user_pk):
|
||||
assert res.json['message'] == expected_error_message
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_transactions_get_list_good(client):
|
||||
from functools import partial
|
||||
|
||||
@ -388,7 +386,6 @@ def test_transactions_get_list_good(client):
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
def test_transactions_get_list_bad(client):
|
||||
def should_not_be_called():
|
||||
assert False
|
||||
@ -405,7 +402,6 @@ def test_transactions_get_list_bad(client):
|
||||
assert client.get(url).status_code == 400
|
||||
|
||||
|
||||
@pytest.mark.tendermint
|
||||
@patch('requests.post')
|
||||
@pytest.mark.parametrize('mode', [
|
||||
('', 'broadcast_tx_async'),
|
||||
|
||||
@ -2,10 +2,6 @@
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
VALIDATORS_ENDPOINT = '/api/v1/validators/'
|
||||
|
||||
|
||||
@ -14,7 +10,7 @@ def test_get_validators_endpoint(b, client):
|
||||
'pub_key': {'data': '4E2685D9016126864733225BE00F005515200727FBAB1312FC78C8B76831255A',
|
||||
'type': 'ed25519'},
|
||||
'voting_power': 10}]
|
||||
b.store_validator_set(23, validator_set, 'election_id')
|
||||
b.store_validator_set(23, validator_set)
|
||||
|
||||
res = client.get(VALIDATORS_ENDPOINT)
|
||||
assert is_validator(res.json[0])
|
||||
|
||||
@ -10,8 +10,6 @@ from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
pytestmark = pytest.mark.tendermint
|
||||
|
||||
|
||||
class MockWebSocket:
|
||||
def __init__(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user