mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Replace bigchaindb_common pkg by bigchaindb.common
This commit is contained in:
parent
ff7cf0863f
commit
ea9dfaf1e5
@ -8,7 +8,7 @@ import logging
|
||||
import rethinkdb as r
|
||||
|
||||
from os.path import expanduser
|
||||
from bigchaindb_common.transaction import Transaction
|
||||
from bigchaindb.common.transaction import Transaction
|
||||
|
||||
from bigchaindb import Bigchain
|
||||
from bigchaindb.util import ProcessGroup
|
||||
|
@ -13,8 +13,8 @@ import builtins
|
||||
|
||||
import logstats
|
||||
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb_common.exceptions import (StartupError,
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.exceptions import (StartupError,
|
||||
DatabaseAlreadyExists,
|
||||
KeypairNotFoundException)
|
||||
import rethinkdb as r
|
||||
|
@ -3,7 +3,7 @@ for ``argparse.ArgumentParser``.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
from bigchaindb_common.exceptions import StartupError
|
||||
from bigchaindb.common.exceptions import StartupError
|
||||
import multiprocessing as mp
|
||||
import subprocess
|
||||
|
||||
@ -25,7 +25,7 @@ def start_rethinkdb():
|
||||
starting the db
|
||||
|
||||
Raises:
|
||||
``bigchaindb_common.exceptions.StartupError`` if RethinkDB cannot
|
||||
``bigchaindb.common.exceptions.StartupError`` if RethinkDB cannot
|
||||
be started.
|
||||
"""
|
||||
|
||||
|
@ -7,10 +7,10 @@ from cryptoconditions import (Fulfillment as CCFulfillment,
|
||||
PreimageSha256Fulfillment)
|
||||
from cryptoconditions.exceptions import ParsingError
|
||||
|
||||
from bigchaindb_common.crypto import SigningKey, hash_data
|
||||
from bigchaindb_common.exceptions import (KeypairMismatchException,
|
||||
from bigchaindb.common.crypto import SigningKey, hash_data
|
||||
from bigchaindb.common.exceptions import (KeypairMismatchException,
|
||||
InvalidHash, InvalidSignature)
|
||||
from bigchaindb_common.util import serialize, gen_timestamp
|
||||
from bigchaindb.common.util import serialize, gen_timestamp
|
||||
|
||||
|
||||
class Fulfillment(object):
|
||||
@ -21,7 +21,7 @@ class Fulfillment(object):
|
||||
to be signed with a private key.
|
||||
owners_before (:obj:`list` of :obj:`str`): A list of owners after a
|
||||
Transaction was confirmed.
|
||||
tx_input (:class:`~bigchaindb_common.transaction. TransactionLink`,
|
||||
tx_input (:class:`~bigchaindb.common.transaction. TransactionLink`,
|
||||
optional): A link representing the input of a `TRANSFER`
|
||||
Transaction.
|
||||
"""
|
||||
@ -34,7 +34,7 @@ class Fulfillment(object):
|
||||
Fulfillment to be signed with a private key.
|
||||
owners_before (:obj:`list` of :obj:`str`): A list of owners
|
||||
after a Transaction was confirmed.
|
||||
tx_input (:class:`~bigchaindb_common.transaction.
|
||||
tx_input (:class:`~bigchaindb.common.transaction.
|
||||
TransactionLink`, optional): A link representing the input
|
||||
of a `TRANSFER` Transaction.
|
||||
"""
|
||||
@ -110,7 +110,7 @@ class Fulfillment(object):
|
||||
ffill (dict): The Fulfillment to be transformed.
|
||||
|
||||
Returns:
|
||||
:class:`~bigchaindb_common.transaction.Fulfillment`
|
||||
:class:`~bigchaindb.common.transaction.Fulfillment`
|
||||
|
||||
Raises:
|
||||
InvalidSignature: If a Fulfillment's URI couldn't be parsed.
|
||||
@ -170,7 +170,7 @@ class TransactionLink(object):
|
||||
link (dict): The link to be transformed.
|
||||
|
||||
Returns:
|
||||
:class:`~bigchaindb_common.transaction.TransactionLink`
|
||||
:class:`~bigchaindb.common.transaction.TransactionLink`
|
||||
"""
|
||||
try:
|
||||
return cls(link['txid'], link['cid'])
|
||||
@ -299,8 +299,8 @@ class Condition(object):
|
||||
TypeError: If `owners_after` is an empty list.
|
||||
"""
|
||||
# TODO: We probably want to remove the tuple logic for weights here
|
||||
# again: https://github.com/bigchaindb/bigchaindb-common/issues/
|
||||
# 12#issuecomment-251665325
|
||||
# again:
|
||||
# github.com/bigchaindb/bigchaindb/issues/730#issuecomment-255144756
|
||||
if isinstance(owners_after, tuple):
|
||||
owners_after, threshold = owners_after
|
||||
else:
|
||||
@ -387,7 +387,7 @@ class Condition(object):
|
||||
cond (dict): The Condition to be transformed.
|
||||
|
||||
Returns:
|
||||
:class:`~bigchaindb_common.transaction.Condition`
|
||||
:class:`~bigchaindb.common.transaction.Condition`
|
||||
"""
|
||||
try:
|
||||
fulfillment = CCFulfillment.from_dict(cond['condition']['details'])
|
||||
@ -455,7 +455,7 @@ class Asset(object):
|
||||
asset (dict): The dictionary to be serialized.
|
||||
|
||||
Returns:
|
||||
:class:`~bigchaindb_common.transaction.Asset`
|
||||
:class:`~bigchaindb.common.transaction.Asset`
|
||||
"""
|
||||
return cls(asset.get('data'), asset['id'],
|
||||
asset.get('divisible', False),
|
||||
@ -516,7 +516,7 @@ class Metadata(object):
|
||||
data (dict): The dictionary to be serialized.
|
||||
|
||||
Returns:
|
||||
:class:`~bigchaindb_common.transaction.Metadata`
|
||||
:class:`~bigchaindb.common.transaction.Metadata`
|
||||
"""
|
||||
try:
|
||||
return cls(data['data'], data['id'])
|
||||
@ -552,12 +552,12 @@ class Transaction(object):
|
||||
|
||||
Attributes:
|
||||
operation (str): Defines the operation of the Transaction.
|
||||
fulfillments (:obj:`list` of :class:`~bigchaindb_common.
|
||||
fulfillments (:obj:`list` of :class:`~bigchaindb.common.
|
||||
transaction.Fulfillment`, optional): Define the assets to
|
||||
spend.
|
||||
conditions (:obj:`list` of :class:`~bigchaindb_common.
|
||||
conditions (:obj:`list` of :class:`~bigchaindb.common.
|
||||
transaction.Condition`, optional): Define the assets to lock.
|
||||
metadata (:class:`~bigchaindb_common.transaction.Metadata`):
|
||||
metadata (:class:`~bigchaindb.common.transaction.Metadata`):
|
||||
Metadata to be stored along with the Transaction.
|
||||
timestamp (int): Defines the time a Transaction was created.
|
||||
version (int): Defines the version number of a Transaction.
|
||||
@ -578,15 +578,15 @@ class Transaction(object):
|
||||
|
||||
Args:
|
||||
operation (str): Defines the operation of the Transaction.
|
||||
asset (:class:`~bigchaindb_common.transaction.Asset`): An Asset
|
||||
asset (:class:`~bigchaindb.common.transaction.Asset`): An Asset
|
||||
to be transferred or created in a Transaction.
|
||||
fulfillments (:obj:`list` of :class:`~bigchaindb_common.
|
||||
fulfillments (:obj:`list` of :class:`~bigchaindb.common.
|
||||
transaction.Fulfillment`, optional): Define the assets to
|
||||
spend.
|
||||
conditions (:obj:`list` of :class:`~bigchaindb_common.
|
||||
conditions (:obj:`list` of :class:`~bigchaindb.common.
|
||||
transaction.Condition`, optional): Define the assets to
|
||||
lock.
|
||||
metadata (:class:`~bigchaindb_common.transaction.Metadata`):
|
||||
metadata (:class:`~bigchaindb.common.transaction.Metadata`):
|
||||
Metadata to be stored along with the Transaction.
|
||||
timestamp (int): Defines the time a Transaction was created.
|
||||
version (int): Defines the version number of a Transaction.
|
||||
@ -661,7 +661,7 @@ class Transaction(object):
|
||||
represent the receivers of this Transaction.
|
||||
metadata (dict): Python dictionary to be stored along with the
|
||||
Transaction.
|
||||
asset (:class:`~bigchaindb_common.transaction.Asset`): An Asset
|
||||
asset (:class:`~bigchaindb.common.transaction.Asset`): An Asset
|
||||
to be created in this Transaction.
|
||||
secret (binarystr, optional): A secret string to create a hash-
|
||||
lock Condition.
|
||||
@ -669,7 +669,7 @@ class Transaction(object):
|
||||
valid.
|
||||
|
||||
Returns:
|
||||
:class:`~bigchaindb_common.transaction.Transaction`
|
||||
:class:`~bigchaindb.common.transaction.Transaction`
|
||||
"""
|
||||
if not isinstance(owners_before, list):
|
||||
raise TypeError('`owners_before` must be a list instance')
|
||||
@ -749,19 +749,19 @@ class Transaction(object):
|
||||
weight respectively. `inp2` is owned completely by `d`.
|
||||
|
||||
Args:
|
||||
inputs (:obj:`list` of :class:`~bigchaindb_common.transaction.
|
||||
inputs (:obj:`list` of :class:`~bigchaindb.common.transaction.
|
||||
Fulfillment`): Converted "output" Conditions, intended to
|
||||
be used as "input" Fulfillments in the transfer to
|
||||
generate.
|
||||
owners_after (:obj:`list` of :obj:`str`): A list of keys that
|
||||
represent the receivers of this Transaction.
|
||||
asset (:class:`~bigchaindb_common.transaction.Asset`): An Asset
|
||||
asset (:class:`~bigchaindb.common.transaction.Asset`): An Asset
|
||||
to be transferred in this Transaction.
|
||||
metadata (dict): Python dictionary to be stored along with the
|
||||
Transaction.
|
||||
|
||||
Returns:
|
||||
:class:`~bigchaindb_common.transaction.Transaction`
|
||||
:class:`~bigchaindb.common.transaction.Transaction`
|
||||
"""
|
||||
if not isinstance(inputs, list):
|
||||
raise TypeError('`inputs` must be a list instance')
|
||||
@ -809,7 +809,7 @@ class Transaction(object):
|
||||
Conditions should be returned as inputs.
|
||||
|
||||
Returns:
|
||||
:obj:`list` of :class:`~bigchaindb_common.transaction.
|
||||
:obj:`list` of :class:`~bigchaindb.common.transaction.
|
||||
Fulfillment`
|
||||
"""
|
||||
inputs = []
|
||||
@ -831,7 +831,7 @@ class Transaction(object):
|
||||
"""Adds a Fulfillment to a Transaction's list of Fulfillments.
|
||||
|
||||
Args:
|
||||
fulfillment (:class:`~bigchaindb_common.transaction.
|
||||
fulfillment (:class:`~bigchaindb.common.transaction.
|
||||
Fulfillment`): A Fulfillment to be added to the
|
||||
Transaction.
|
||||
"""
|
||||
@ -843,7 +843,7 @@ class Transaction(object):
|
||||
"""Adds a Condition to a Transaction's list of Conditions.
|
||||
|
||||
Args:
|
||||
condition (:class:`~bigchaindb_common.transaction.
|
||||
condition (:class:`~bigchaindb.common.transaction.
|
||||
Condition`): A Condition to be added to the
|
||||
Transaction.
|
||||
"""
|
||||
@ -869,7 +869,7 @@ class Transaction(object):
|
||||
Transaction.
|
||||
|
||||
Returns:
|
||||
:class:`~bigchaindb_common.transaction.Transaction`
|
||||
:class:`~bigchaindb.common.transaction.Transaction`
|
||||
"""
|
||||
# TODO: Singing should be possible with at least one of all private
|
||||
# keys supplied to this method.
|
||||
@ -920,7 +920,7 @@ class Transaction(object):
|
||||
- ThresholdSha256Fulfillment.
|
||||
|
||||
Args:
|
||||
fulfillment (:class:`~bigchaindb_common.transaction.
|
||||
fulfillment (:class:`~bigchaindb.common.transaction.
|
||||
Fulfillment`) The Fulfillment to be signed.
|
||||
index (int): The index (or `fid`) of the Fulfillment to be
|
||||
signed.
|
||||
@ -943,7 +943,7 @@ class Transaction(object):
|
||||
"""Signs a Ed25519Fulfillment.
|
||||
|
||||
Args:
|
||||
fulfillment (:class:`~bigchaindb_common.transaction.
|
||||
fulfillment (:class:`~bigchaindb.common.transaction.
|
||||
Fulfillment`) The Fulfillment to be signed.
|
||||
index (int): The index (or `fid`) of the Fulfillment to be
|
||||
signed.
|
||||
@ -972,7 +972,7 @@ class Transaction(object):
|
||||
"""Signs a ThresholdSha256Fulfillment.
|
||||
|
||||
Args:
|
||||
fulfillment (:class:`~bigchaindb_common.transaction.
|
||||
fulfillment (:class:`~bigchaindb.common.transaction.
|
||||
Fulfillment`) The Fulfillment to be signed.
|
||||
index (int): The index (or `fid`) of the Fulfillment to be
|
||||
signed.
|
||||
@ -1019,7 +1019,7 @@ class Transaction(object):
|
||||
evaluate parts of the validation-checks to `True`.
|
||||
|
||||
Args:
|
||||
input_conditions (:obj:`list` of :class:`~bigchaindb_common.
|
||||
input_conditions (:obj:`list` of :class:`~bigchaindb.common.
|
||||
transaction.Condition`): A list of Conditions to check the
|
||||
Fulfillments against.
|
||||
|
||||
@ -1094,7 +1094,7 @@ class Transaction(object):
|
||||
does not validate against `input_condition_uri`.
|
||||
|
||||
Args:
|
||||
fulfillment (:class:`~bigchaindb_common.transaction.
|
||||
fulfillment (:class:`~bigchaindb.common.transaction.
|
||||
Fulfillment`) The Fulfillment to be signed.
|
||||
operation (str): The type of Transaction.
|
||||
tx_serialized (str): The Transaction used as a message when
|
||||
@ -1218,7 +1218,7 @@ class Transaction(object):
|
||||
tx_body (dict): The Transaction to be transformed.
|
||||
|
||||
Returns:
|
||||
:class:`~bigchaindb_common.transaction.Transaction`
|
||||
:class:`~bigchaindb.common.transaction.Transaction`
|
||||
"""
|
||||
# NOTE: Remove reference to avoid side effects
|
||||
tx_body = deepcopy(tx_body)
|
||||
|
@ -17,7 +17,7 @@ import json
|
||||
import logging
|
||||
import collections
|
||||
|
||||
from bigchaindb_common import exceptions
|
||||
from bigchaindb.common import exceptions
|
||||
|
||||
import bigchaindb
|
||||
|
||||
|
@ -4,9 +4,9 @@ import collections
|
||||
from time import time
|
||||
|
||||
from itertools import compress
|
||||
from bigchaindb_common import crypto, exceptions
|
||||
from bigchaindb_common.util import gen_timestamp, serialize
|
||||
from bigchaindb_common.transaction import TransactionLink, Metadata
|
||||
from bigchaindb.common import crypto, exceptions
|
||||
from bigchaindb.common.util import gen_timestamp, serialize
|
||||
from bigchaindb.common.transaction import TransactionLink, Metadata
|
||||
|
||||
import rethinkdb as r
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
import time
|
||||
import logging
|
||||
|
||||
from bigchaindb_common import exceptions
|
||||
from bigchaindb.common import exceptions
|
||||
import rethinkdb as r
|
||||
|
||||
import bigchaindb
|
||||
|
@ -1,11 +1,11 @@
|
||||
from bigchaindb_common.crypto import hash_data, VerifyingKey, SigningKey
|
||||
from bigchaindb_common.exceptions import (InvalidHash, InvalidSignature,
|
||||
from bigchaindb.common.crypto import hash_data, VerifyingKey, SigningKey
|
||||
from bigchaindb.common.exceptions import (InvalidHash, InvalidSignature,
|
||||
OperationError, DoubleSpend,
|
||||
TransactionDoesNotExist,
|
||||
FulfillmentNotInValidBlock,
|
||||
AssetIdMismatch)
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb_common.util import gen_timestamp, serialize
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.util import gen_timestamp, serialize
|
||||
|
||||
|
||||
class Asset(Asset):
|
||||
|
@ -8,7 +8,7 @@ function.
|
||||
from collections import Counter
|
||||
|
||||
from multipipes import Pipeline, Node
|
||||
from bigchaindb_common import exceptions
|
||||
from bigchaindb.common import exceptions
|
||||
|
||||
from bigchaindb.consensus import BaseConsensusRules
|
||||
from bigchaindb.models import Transaction, Block
|
||||
|
@ -3,8 +3,8 @@ import threading
|
||||
import queue
|
||||
import multiprocessing as mp
|
||||
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb_common.util import serialize
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.util import serialize
|
||||
|
||||
|
||||
class ProcessGroup(object):
|
||||
|
@ -6,7 +6,7 @@ For more information please refer to the documentation on ReadTheDocs:
|
||||
from flask import current_app, request, Blueprint
|
||||
from flask_restful import Resource, Api
|
||||
|
||||
from bigchaindb_common.exceptions import InvalidHash, InvalidSignature
|
||||
from bigchaindb.common.exceptions import InvalidHash, InvalidSignature
|
||||
|
||||
import bigchaindb
|
||||
from bigchaindb.models import Transaction
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""A Python 3 script to write a file with a specified number
|
||||
of keypairs, using bigchaindb_common.crypto.generate_key_pair()
|
||||
of keypairs, using bigchaindb.common.crypto.generate_key_pair()
|
||||
The written file is always named keypairs.py and it should be
|
||||
interpreted as a Python 2 script.
|
||||
|
||||
@ -16,7 +16,7 @@ Using the list in other Python scripts:
|
||||
|
||||
import argparse
|
||||
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
|
||||
|
||||
# Parse the command-line arguments
|
||||
|
1
setup.py
1
setup.py
@ -103,7 +103,6 @@ setup(
|
||||
'requests~=2.9',
|
||||
'gunicorn~=19.0',
|
||||
'multipipes~=0.1.0',
|
||||
'bigchaindb-common==0.0.6',
|
||||
],
|
||||
setup_requires=['pytest-runner'],
|
||||
tests_require=tests_require,
|
||||
|
@ -76,7 +76,7 @@ def test_validate_bad_asset_creation(b, user_vk):
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_validate_transfer_asset_id_mismatch(b, user_vk, user_sk):
|
||||
from bigchaindb_common.exceptions import AssetIdMismatch
|
||||
from bigchaindb.common.exceptions import AssetIdMismatch
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
tx_create = b.get_owned_ids(user_vk).pop()
|
||||
@ -121,7 +121,7 @@ def test_get_asset_id_transfer_transaction(b, user_vk, user_sk):
|
||||
|
||||
def test_asset_id_mismatch(b, user_vk):
|
||||
from bigchaindb.models import Transaction, Asset
|
||||
from bigchaindb_common.exceptions import AssetIdMismatch
|
||||
from bigchaindb.common.exceptions import AssetIdMismatch
|
||||
|
||||
tx1 = Transaction.create([b.me], [user_vk])
|
||||
tx2 = Transaction.create([b.me], [user_vk])
|
||||
|
@ -85,37 +85,37 @@ def user2_Ed25519(user2_pub):
|
||||
|
||||
@pytest.fixture
|
||||
def user_ffill(user_Ed25519, user_pub):
|
||||
from bigchaindb_common.transaction import Fulfillment
|
||||
from bigchaindb.common.transaction import Fulfillment
|
||||
return Fulfillment(user_Ed25519, [user_pub])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user2_ffill(user2_Ed25519, user2_pub):
|
||||
from bigchaindb_common.transaction import Fulfillment
|
||||
from bigchaindb.common.transaction import Fulfillment
|
||||
return Fulfillment(user2_Ed25519, [user2_pub])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user_user2_threshold_cond(user_user2_threshold, user_pub, user2_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
return Condition(user_user2_threshold, [user_pub, user2_pub])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user_user2_threshold_ffill(user_user2_threshold, user_pub, user2_pub):
|
||||
from bigchaindb_common.transaction import Fulfillment
|
||||
from bigchaindb.common.transaction import Fulfillment
|
||||
return Fulfillment(user_user2_threshold, [user_pub, user2_pub])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user_cond(user_Ed25519, user_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
return Condition(user_Ed25519, [user_pub])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user2_cond(user2_Ed25519, user2_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
return Condition(user2_Ed25519, [user2_pub])
|
||||
|
||||
|
||||
@ -131,13 +131,13 @@ def data_id():
|
||||
|
||||
@pytest.fixture
|
||||
def metadata(data, data_id):
|
||||
from bigchaindb_common.transaction import Metadata
|
||||
from bigchaindb.common.transaction import Metadata
|
||||
return Metadata(data, data_id)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def utx(user_ffill, user_cond):
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
return Transaction(Transaction.CREATE, Asset(), [user_ffill], [user_cond])
|
||||
|
||||
|
||||
@ -148,7 +148,7 @@ def tx(utx, user_priv):
|
||||
|
||||
@pytest.fixture
|
||||
def transfer_utx(user_cond, user2_cond, utx):
|
||||
from bigchaindb_common.transaction import (Fulfillment, TransactionLink,
|
||||
from bigchaindb.common.transaction import (Fulfillment, TransactionLink,
|
||||
Transaction, Asset)
|
||||
user_cond = user_cond.to_dict()
|
||||
ffill = Fulfillment(utx.conditions[0].fulfillment,
|
||||
|
@ -2,7 +2,7 @@ from pytest import raises
|
||||
|
||||
|
||||
def test_asset_default_values():
|
||||
from bigchaindb_common.transaction import Asset
|
||||
from bigchaindb.common.transaction import Asset
|
||||
|
||||
asset = Asset()
|
||||
assert asset.data is None
|
||||
@ -13,14 +13,14 @@ def test_asset_default_values():
|
||||
|
||||
|
||||
def test_asset_creation_with_data(data):
|
||||
from bigchaindb_common.transaction import Asset
|
||||
from bigchaindb.common.transaction import Asset
|
||||
|
||||
asset = Asset(data)
|
||||
assert asset.data == data
|
||||
|
||||
|
||||
def test_asset_invalid_asset_initialization():
|
||||
from bigchaindb_common.transaction import Asset
|
||||
from bigchaindb.common.transaction import Asset
|
||||
|
||||
with raises(TypeError):
|
||||
Asset(data='some wrong type')
|
||||
@ -33,13 +33,13 @@ def test_asset_invalid_asset_initialization():
|
||||
|
||||
|
||||
def test_invalid_asset_comparison(data, data_id):
|
||||
from bigchaindb_common.transaction import Asset
|
||||
from bigchaindb.common.transaction import Asset
|
||||
|
||||
assert Asset(data, data_id) != 'invalid comparison'
|
||||
|
||||
|
||||
def test_asset_serialization(data, data_id):
|
||||
from bigchaindb_common.transaction import Asset
|
||||
from bigchaindb.common.transaction import Asset
|
||||
|
||||
expected = {
|
||||
'id': data_id,
|
||||
@ -53,7 +53,7 @@ def test_asset_serialization(data, data_id):
|
||||
|
||||
|
||||
def test_asset_deserialization(data, data_id):
|
||||
from bigchaindb_common.transaction import Asset
|
||||
from bigchaindb.common.transaction import Asset
|
||||
|
||||
asset_dict = {
|
||||
'id': data_id,
|
||||
@ -68,7 +68,7 @@ def test_asset_deserialization(data, data_id):
|
||||
|
||||
|
||||
def test_validate_asset():
|
||||
from bigchaindb_common.transaction import Asset
|
||||
from bigchaindb.common.transaction import Asset
|
||||
|
||||
with raises(TypeError):
|
||||
Asset(divisible=1)
|
||||
|
@ -2,7 +2,7 @@ from pytest import raises, mark
|
||||
|
||||
|
||||
def test_fulfillment_serialization(ffill_uri, user_pub):
|
||||
from bigchaindb_common.transaction import Fulfillment
|
||||
from bigchaindb.common.transaction import Fulfillment
|
||||
from cryptoconditions import Fulfillment as CCFulfillment
|
||||
|
||||
expected = {
|
||||
@ -15,7 +15,7 @@ def test_fulfillment_serialization(ffill_uri, user_pub):
|
||||
|
||||
|
||||
def test_fulfillment_deserialization_with_uri(ffill_uri, user_pub):
|
||||
from bigchaindb_common.transaction import Fulfillment
|
||||
from bigchaindb.common.transaction import Fulfillment
|
||||
from cryptoconditions import Fulfillment as CCFulfillment
|
||||
|
||||
expected = Fulfillment(CCFulfillment.from_uri(ffill_uri), [user_pub])
|
||||
@ -30,7 +30,7 @@ def test_fulfillment_deserialization_with_uri(ffill_uri, user_pub):
|
||||
|
||||
|
||||
def test_fulfillment_deserialization_with_invalid_fulfillment(user_pub):
|
||||
from bigchaindb_common.transaction import Fulfillment
|
||||
from bigchaindb.common.transaction import Fulfillment
|
||||
|
||||
ffill = {
|
||||
'owners_before': [user_pub],
|
||||
@ -42,8 +42,8 @@ def test_fulfillment_deserialization_with_invalid_fulfillment(user_pub):
|
||||
|
||||
|
||||
def test_fulfillment_deserialization_with_invalid_fulfillment_uri(user_pub):
|
||||
from bigchaindb_common.exceptions import InvalidSignature
|
||||
from bigchaindb_common.transaction import Fulfillment
|
||||
from bigchaindb.common.exceptions import InvalidSignature
|
||||
from bigchaindb.common.transaction import Fulfillment
|
||||
|
||||
ffill = {
|
||||
'owners_before': [user_pub],
|
||||
@ -56,7 +56,7 @@ def test_fulfillment_deserialization_with_invalid_fulfillment_uri(user_pub):
|
||||
|
||||
def test_fulfillment_deserialization_with_unsigned_fulfillment(ffill_uri,
|
||||
user_pub):
|
||||
from bigchaindb_common.transaction import Fulfillment
|
||||
from bigchaindb.common.transaction import Fulfillment
|
||||
from cryptoconditions import Fulfillment as CCFulfillment
|
||||
|
||||
expected = Fulfillment(CCFulfillment.from_uri(ffill_uri), [user_pub])
|
||||
@ -71,7 +71,7 @@ def test_fulfillment_deserialization_with_unsigned_fulfillment(ffill_uri,
|
||||
|
||||
|
||||
def test_condition_serialization(user_Ed25519, user_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
|
||||
expected = {
|
||||
'condition': {
|
||||
@ -88,7 +88,7 @@ def test_condition_serialization(user_Ed25519, user_pub):
|
||||
|
||||
|
||||
def test_condition_deserialization(user_Ed25519, user_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
|
||||
expected = Condition(user_Ed25519, [user_pub], 1)
|
||||
cond = {
|
||||
@ -105,7 +105,7 @@ def test_condition_deserialization(user_Ed25519, user_pub):
|
||||
|
||||
|
||||
def test_condition_hashlock_serialization():
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
from cryptoconditions import PreimageSha256Fulfillment
|
||||
|
||||
secret = b'wow much secret'
|
||||
@ -124,7 +124,7 @@ def test_condition_hashlock_serialization():
|
||||
|
||||
|
||||
def test_condition_hashlock_deserialization():
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
from cryptoconditions import PreimageSha256Fulfillment
|
||||
|
||||
secret = b'wow much secret'
|
||||
@ -144,7 +144,7 @@ def test_condition_hashlock_deserialization():
|
||||
|
||||
|
||||
def test_invalid_condition_initialization(cond_uri, user_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
|
||||
with raises(TypeError):
|
||||
Condition(cond_uri, user_pub)
|
||||
@ -152,7 +152,7 @@ def test_invalid_condition_initialization(cond_uri, user_pub):
|
||||
|
||||
def test_generate_conditions_split_half_recursive(user_pub, user2_pub,
|
||||
user3_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
from cryptoconditions import Ed25519Fulfillment, ThresholdSha256Fulfillment
|
||||
|
||||
expected_simple1 = Ed25519Fulfillment(public_key=user_pub)
|
||||
@ -173,7 +173,7 @@ def test_generate_conditions_split_half_recursive(user_pub, user2_pub,
|
||||
def test_generate_conditions_split_half_recursive_custom_threshold(user_pub,
|
||||
user2_pub,
|
||||
user3_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
from cryptoconditions import Ed25519Fulfillment, ThresholdSha256Fulfillment
|
||||
|
||||
expected_simple1 = Ed25519Fulfillment(public_key=user_pub)
|
||||
@ -194,7 +194,7 @@ def test_generate_conditions_split_half_recursive_custom_threshold(user_pub,
|
||||
|
||||
def test_generate_conditions_split_half_single_owner(user_pub, user2_pub,
|
||||
user3_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
from cryptoconditions import Ed25519Fulfillment, ThresholdSha256Fulfillment
|
||||
|
||||
expected_simple1 = Ed25519Fulfillment(public_key=user_pub)
|
||||
@ -213,7 +213,7 @@ def test_generate_conditions_split_half_single_owner(user_pub, user2_pub,
|
||||
|
||||
|
||||
def test_generate_conditions_flat_ownage(user_pub, user2_pub, user3_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
from cryptoconditions import Ed25519Fulfillment, ThresholdSha256Fulfillment
|
||||
|
||||
expected_simple1 = Ed25519Fulfillment(public_key=user_pub)
|
||||
@ -230,7 +230,7 @@ def test_generate_conditions_flat_ownage(user_pub, user2_pub, user3_pub):
|
||||
|
||||
|
||||
def test_generate_conditions_single_owner(user_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
from cryptoconditions import Ed25519Fulfillment
|
||||
|
||||
expected = Ed25519Fulfillment(public_key=user_pub)
|
||||
@ -240,7 +240,7 @@ def test_generate_conditions_single_owner(user_pub):
|
||||
|
||||
|
||||
def test_generate_conditions_single_owner_with_condition(user_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
from cryptoconditions import Ed25519Fulfillment
|
||||
|
||||
expected = Ed25519Fulfillment(public_key=user_pub)
|
||||
@ -253,7 +253,7 @@ def test_generate_conditions_single_owner_with_condition(user_pub):
|
||||
@mark.skip(reason='threshold(hashlock).to_dict() exposes secret')
|
||||
def test_generate_threshold_condition_with_hashlock(user_pub, user2_pub,
|
||||
user3_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
from cryptoconditions import (PreimageSha256Fulfillment,
|
||||
Ed25519Fulfillment,
|
||||
ThresholdSha256Fulfillment)
|
||||
@ -276,7 +276,7 @@ def test_generate_threshold_condition_with_hashlock(user_pub, user2_pub,
|
||||
|
||||
def test_generate_conditions_invalid_parameters(user_pub, user2_pub,
|
||||
user3_pub):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
|
||||
with raises(ValueError):
|
||||
Condition.generate([])
|
||||
@ -289,7 +289,7 @@ def test_generate_conditions_invalid_parameters(user_pub, user2_pub,
|
||||
|
||||
|
||||
def test_invalid_transaction_initialization():
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
with raises(ValueError):
|
||||
Transaction(operation='invalid operation', asset=Asset())
|
||||
@ -319,7 +319,7 @@ def test_invalid_transaction_initialization():
|
||||
|
||||
|
||||
def test_create_default_asset_on_tx_initialization():
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx = Transaction(Transaction.CREATE, None)
|
||||
expected = Asset()
|
||||
@ -331,7 +331,7 @@ def test_create_default_asset_on_tx_initialization():
|
||||
|
||||
|
||||
def test_transaction_serialization(user_ffill, user_cond, data, data_id):
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx_id = 'l0l'
|
||||
timestamp = '66666666666'
|
||||
@ -368,7 +368,7 @@ def test_transaction_serialization(user_ffill, user_cond, data, data_id):
|
||||
|
||||
|
||||
def test_transaction_deserialization(user_ffill, user_cond, data, data_id):
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
timestamp = '66666666666'
|
||||
|
||||
@ -403,8 +403,8 @@ def test_transaction_deserialization(user_ffill, user_cond, data, data_id):
|
||||
|
||||
|
||||
def test_tx_serialization_with_incorrect_hash(utx):
|
||||
from bigchaindb_common.transaction import Transaction
|
||||
from bigchaindb_common.exceptions import InvalidHash
|
||||
from bigchaindb.common.transaction import Transaction
|
||||
from bigchaindb.common.exceptions import InvalidHash
|
||||
|
||||
utx_dict = utx.to_dict()
|
||||
utx_dict['id'] = 'abc'
|
||||
@ -419,7 +419,7 @@ def test_tx_serialization_with_incorrect_hash(utx):
|
||||
|
||||
|
||||
def test_invalid_fulfillment_initialization(user_ffill, user_pub):
|
||||
from bigchaindb_common.transaction import Fulfillment
|
||||
from bigchaindb.common.transaction import Fulfillment
|
||||
|
||||
with raises(TypeError):
|
||||
Fulfillment(user_ffill, user_pub)
|
||||
@ -428,14 +428,14 @@ def test_invalid_fulfillment_initialization(user_ffill, user_pub):
|
||||
|
||||
|
||||
def test_invalid_metadata_initialization():
|
||||
from bigchaindb_common.transaction import Metadata
|
||||
from bigchaindb.common.transaction import Metadata
|
||||
|
||||
with raises(TypeError):
|
||||
Metadata([])
|
||||
|
||||
|
||||
def test_metadata_serialization(data, data_id):
|
||||
from bigchaindb_common.transaction import Metadata
|
||||
from bigchaindb.common.transaction import Metadata
|
||||
|
||||
expected = {
|
||||
'data': data,
|
||||
@ -447,7 +447,7 @@ def test_metadata_serialization(data, data_id):
|
||||
|
||||
|
||||
def test_metadata_deserialization(data, data_id):
|
||||
from bigchaindb_common.transaction import Metadata
|
||||
from bigchaindb.common.transaction import Metadata
|
||||
|
||||
expected = Metadata(data, data_id)
|
||||
metadata = Metadata.from_dict({'data': data, 'id': data_id})
|
||||
@ -456,7 +456,7 @@ def test_metadata_deserialization(data, data_id):
|
||||
|
||||
|
||||
def test_transaction_link_serialization():
|
||||
from bigchaindb_common.transaction import TransactionLink
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
tx_id = 'a transaction id'
|
||||
expected = {
|
||||
@ -469,7 +469,7 @@ def test_transaction_link_serialization():
|
||||
|
||||
|
||||
def test_transaction_link_serialization_with_empty_payload():
|
||||
from bigchaindb_common.transaction import TransactionLink
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
expected = None
|
||||
tx_link = TransactionLink()
|
||||
@ -478,7 +478,7 @@ def test_transaction_link_serialization_with_empty_payload():
|
||||
|
||||
|
||||
def test_transaction_link_deserialization():
|
||||
from bigchaindb_common.transaction import TransactionLink
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
tx_id = 'a transaction id'
|
||||
expected = TransactionLink(tx_id, 0)
|
||||
@ -492,7 +492,7 @@ def test_transaction_link_deserialization():
|
||||
|
||||
|
||||
def test_transaction_link_deserialization_with_empty_payload():
|
||||
from bigchaindb_common.transaction import TransactionLink
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
expected = TransactionLink()
|
||||
tx_link = TransactionLink.from_dict(None)
|
||||
@ -501,7 +501,7 @@ def test_transaction_link_deserialization_with_empty_payload():
|
||||
|
||||
|
||||
def test_cast_transaction_link_to_boolean():
|
||||
from bigchaindb_common.transaction import TransactionLink
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
assert bool(TransactionLink()) is False
|
||||
assert bool(TransactionLink('a', None)) is False
|
||||
@ -511,7 +511,7 @@ def test_cast_transaction_link_to_boolean():
|
||||
|
||||
|
||||
def test_add_fulfillment_to_tx(user_ffill):
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx = Transaction(Transaction.CREATE, Asset(), [], [])
|
||||
tx.add_fulfillment(user_ffill)
|
||||
@ -520,7 +520,7 @@ def test_add_fulfillment_to_tx(user_ffill):
|
||||
|
||||
|
||||
def test_add_fulfillment_to_tx_with_invalid_parameters():
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx = Transaction(Transaction.CREATE, Asset())
|
||||
with raises(TypeError):
|
||||
@ -528,7 +528,7 @@ def test_add_fulfillment_to_tx_with_invalid_parameters():
|
||||
|
||||
|
||||
def test_add_condition_to_tx(user_cond):
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx = Transaction(Transaction.CREATE, Asset())
|
||||
tx.add_condition(user_cond)
|
||||
@ -537,7 +537,7 @@ def test_add_condition_to_tx(user_cond):
|
||||
|
||||
|
||||
def test_add_condition_to_tx_with_invalid_parameters():
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx = Transaction(Transaction.CREATE, Asset(), [], [])
|
||||
with raises(TypeError):
|
||||
@ -553,8 +553,8 @@ def test_sign_with_invalid_parameters(utx, user_priv):
|
||||
|
||||
def test_validate_tx_simple_create_signature(user_ffill, user_cond, user_priv):
|
||||
from copy import deepcopy
|
||||
from bigchaindb_common.crypto import SigningKey
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.crypto import SigningKey
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx = Transaction(Transaction.CREATE, Asset(), [user_ffill], [user_cond])
|
||||
expected = deepcopy(user_cond)
|
||||
@ -568,7 +568,7 @@ def test_validate_tx_simple_create_signature(user_ffill, user_cond, user_priv):
|
||||
|
||||
def test_invoke_simple_signature_fulfillment_with_invalid_params(utx,
|
||||
user_ffill):
|
||||
from bigchaindb_common.exceptions import KeypairMismatchException
|
||||
from bigchaindb.common.exceptions import KeypairMismatchException
|
||||
|
||||
with raises(KeypairMismatchException):
|
||||
invalid_key_pair = {'wrong_pub_key': 'wrong_priv_key'}
|
||||
@ -580,7 +580,7 @@ def test_invoke_simple_signature_fulfillment_with_invalid_params(utx,
|
||||
|
||||
def test_sign_threshold_with_invalid_params(utx, user_user2_threshold_ffill,
|
||||
user3_pub, user3_priv):
|
||||
from bigchaindb_common.exceptions import KeypairMismatchException
|
||||
from bigchaindb.common.exceptions import KeypairMismatchException
|
||||
|
||||
with raises(KeypairMismatchException):
|
||||
utx._sign_threshold_signature_fulfillment(user_user2_threshold_ffill,
|
||||
@ -596,7 +596,7 @@ def test_sign_threshold_with_invalid_params(utx, user_user2_threshold_ffill,
|
||||
|
||||
|
||||
def test_validate_fulfillment_with_invalid_parameters(utx):
|
||||
from bigchaindb_common.transaction import Transaction
|
||||
from bigchaindb.common.transaction import Transaction
|
||||
|
||||
input_conditions = [cond.fulfillment.condition_uri for cond
|
||||
in utx.conditions]
|
||||
@ -611,8 +611,8 @@ def test_validate_fulfillment_with_invalid_parameters(utx):
|
||||
def test_validate_multiple_fulfillments(user_ffill, user_cond, user_priv):
|
||||
from copy import deepcopy
|
||||
|
||||
from bigchaindb_common.crypto import SigningKey
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.crypto import SigningKey
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx = Transaction(Transaction.CREATE, Asset(),
|
||||
[user_ffill, deepcopy(user_ffill)],
|
||||
@ -648,8 +648,8 @@ def test_validate_tx_threshold_create_signature(user_user2_threshold_ffill,
|
||||
user2_priv):
|
||||
from copy import deepcopy
|
||||
|
||||
from bigchaindb_common.crypto import SigningKey
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.crypto import SigningKey
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx = Transaction(Transaction.CREATE, Asset(), [user_user2_threshold_ffill],
|
||||
[user_user2_threshold_cond])
|
||||
@ -670,7 +670,7 @@ def test_multiple_fulfillment_validation_of_transfer_tx(user_ffill, user_cond,
|
||||
user2_priv, user3_pub,
|
||||
user3_priv):
|
||||
from copy import deepcopy
|
||||
from bigchaindb_common.transaction import (Transaction, TransactionLink,
|
||||
from bigchaindb.common.transaction import (Transaction, TransactionLink,
|
||||
Fulfillment, Condition, Asset)
|
||||
from cryptoconditions import Ed25519Fulfillment
|
||||
|
||||
@ -697,7 +697,7 @@ def test_validate_fulfillments_of_transfer_tx_with_invalid_params(transfer_tx,
|
||||
utx,
|
||||
user2_pub,
|
||||
user_priv):
|
||||
from bigchaindb_common.transaction import Condition
|
||||
from bigchaindb.common.transaction import Condition
|
||||
from cryptoconditions import Ed25519Fulfillment
|
||||
|
||||
invalid_cond = Condition(Ed25519Fulfillment.from_uri('cf:0:'), ['invalid'])
|
||||
@ -723,7 +723,7 @@ def test_validate_fulfillments_of_transfer_tx_with_invalid_params(transfer_tx,
|
||||
|
||||
def test_create_create_transaction_single_io(user_cond, user_pub, data,
|
||||
data_id):
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
expected = {
|
||||
'transaction': {
|
||||
@ -764,7 +764,7 @@ def test_create_create_transaction_single_io(user_cond, user_pub, data,
|
||||
|
||||
|
||||
def test_validate_single_io_create_transaction(user_pub, user_priv, data):
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx = Transaction.create([user_pub], [user_pub], data, Asset())
|
||||
tx = tx.sign([user_priv])
|
||||
@ -775,7 +775,7 @@ def test_validate_single_io_create_transaction(user_pub, user_priv, data):
|
||||
# TODO: Add digital assets
|
||||
def test_create_create_transaction_multiple_io(user_cond, user2_cond, user_pub,
|
||||
user2_pub):
|
||||
from bigchaindb_common.transaction import Transaction
|
||||
from bigchaindb.common.transaction import Transaction
|
||||
|
||||
expected = {
|
||||
'transaction': {
|
||||
@ -820,7 +820,7 @@ def test_create_create_transaction_multiple_io(user_cond, user2_cond, user_pub,
|
||||
# TODO: Add digital assets
|
||||
def test_validate_multiple_io_create_transaction(user_pub, user_priv,
|
||||
user2_pub, user2_priv):
|
||||
from bigchaindb_common.transaction import Transaction
|
||||
from bigchaindb.common.transaction import Transaction
|
||||
|
||||
tx = Transaction.create([user_pub, user2_pub], [user_pub, user2_pub],
|
||||
{'message': 'hello'})
|
||||
@ -832,7 +832,7 @@ def test_create_create_transaction_threshold(user_pub, user2_pub, user3_pub,
|
||||
user_user2_threshold_cond,
|
||||
user_user2_threshold_ffill, data,
|
||||
data_id):
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
expected = {
|
||||
'transaction': {
|
||||
@ -874,7 +874,7 @@ def test_create_create_transaction_threshold(user_pub, user2_pub, user3_pub,
|
||||
|
||||
def test_validate_threshold_create_transaction(user_pub, user_priv, user2_pub,
|
||||
data):
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx = Transaction.create([user_pub], [user_pub, user2_pub], data, Asset())
|
||||
tx = tx.sign([user_priv])
|
||||
@ -883,7 +883,7 @@ def test_validate_threshold_create_transaction(user_pub, user_priv, user2_pub,
|
||||
|
||||
def test_create_create_transaction_hashlock(user_pub, data, data_id):
|
||||
from cryptoconditions import PreimageSha256Fulfillment
|
||||
from bigchaindb_common.transaction import Transaction, Condition, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Condition, Asset
|
||||
|
||||
secret = b'much secret, wow'
|
||||
hashlock = PreimageSha256Fulfillment(preimage=secret).condition_uri
|
||||
@ -928,7 +928,7 @@ def test_create_create_transaction_hashlock(user_pub, data, data_id):
|
||||
|
||||
|
||||
def test_validate_hashlock_create_transaction(user_pub, user_priv, data):
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
tx = Transaction.create([user_pub], [], data, Asset(), b'much secret, wow')
|
||||
tx = tx.sign([user_priv])
|
||||
@ -936,7 +936,7 @@ def test_validate_hashlock_create_transaction(user_pub, user_priv, data):
|
||||
|
||||
|
||||
def test_create_create_transaction_with_invalid_parameters():
|
||||
from bigchaindb_common.transaction import Transaction
|
||||
from bigchaindb.common.transaction import Transaction
|
||||
|
||||
with raises(TypeError):
|
||||
Transaction.create('not a list')
|
||||
@ -965,9 +965,9 @@ def test_conditions_to_inputs(tx):
|
||||
def test_create_transfer_transaction_single_io(tx, user_pub, user2_pub,
|
||||
user2_cond, user_priv, data_id):
|
||||
from copy import deepcopy
|
||||
from bigchaindb_common.crypto import SigningKey
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb_common.util import serialize
|
||||
from bigchaindb.common.crypto import SigningKey
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.util import serialize
|
||||
|
||||
expected = {
|
||||
'transaction': {
|
||||
@ -1018,7 +1018,7 @@ def test_create_transfer_transaction_single_io(tx, user_pub, user2_pub,
|
||||
def test_create_transfer_transaction_multiple_io(user_pub, user_priv,
|
||||
user2_pub, user2_priv,
|
||||
user3_pub, user2_cond):
|
||||
from bigchaindb_common.transaction import Transaction
|
||||
from bigchaindb.common.transaction import Transaction
|
||||
|
||||
tx1 = Transaction.create([user_pub], [user_pub], {'message': 'hello'})
|
||||
tx1 = tx1.sign([user_priv])
|
||||
@ -1080,7 +1080,7 @@ def test_create_transfer_transaction_multiple_io(user_pub, user_priv,
|
||||
|
||||
|
||||
def test_create_transfer_with_invalid_parameters():
|
||||
from bigchaindb_common.transaction import Transaction, Asset
|
||||
from bigchaindb.common.transaction import Transaction, Asset
|
||||
|
||||
with raises(TypeError):
|
||||
Transaction.transfer({}, [], Asset())
|
||||
@ -1093,14 +1093,14 @@ def test_create_transfer_with_invalid_parameters():
|
||||
|
||||
|
||||
def test_cant_add_empty_condition():
|
||||
from bigchaindb_common.transaction import Transaction
|
||||
from bigchaindb.common.transaction import Transaction
|
||||
tx = Transaction(Transaction.CREATE, None)
|
||||
with raises(TypeError):
|
||||
tx.add_condition(None)
|
||||
|
||||
|
||||
def test_cant_add_empty_fulfillment():
|
||||
from bigchaindb_common.transaction import Transaction
|
||||
from bigchaindb.common.transaction import Transaction
|
||||
tx = Transaction(Transaction.CREATE, None)
|
||||
with raises(TypeError):
|
||||
tx.add_fulfillment(None)
|
||||
|
@ -11,7 +11,7 @@ import rethinkdb as r
|
||||
|
||||
from bigchaindb import Bigchain
|
||||
from bigchaindb.db import get_conn
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
|
||||
USER2_SK, USER2_VK = crypto.generate_key_pair()
|
||||
|
||||
@ -107,7 +107,7 @@ def cleanup_tables(request, node_config):
|
||||
@pytest.fixture
|
||||
def inputs(user_vk):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb_common.exceptions import GenesisBlockAlreadyExistsError
|
||||
from bigchaindb.common.exceptions import GenesisBlockAlreadyExistsError
|
||||
# 1. create the genesis block
|
||||
b = Bigchain()
|
||||
try:
|
||||
@ -144,7 +144,7 @@ def user2_vk():
|
||||
@pytest.fixture
|
||||
def inputs_shared(user_vk, user2_vk):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb_common.exceptions import GenesisBlockAlreadyExistsError
|
||||
from bigchaindb.common.exceptions import GenesisBlockAlreadyExistsError
|
||||
# 1. create the genesis block
|
||||
b = Bigchain()
|
||||
try:
|
||||
|
@ -30,9 +30,9 @@ def dummy_block():
|
||||
|
||||
class TestBigchainApi(object):
|
||||
def test_get_last_voted_block_cyclic_blockchain(self, b, monkeypatch):
|
||||
from bigchaindb_common.crypto import SigningKey
|
||||
from bigchaindb_common.exceptions import CyclicBlockchainError
|
||||
from bigchaindb_common.util import serialize
|
||||
from bigchaindb.common.crypto import SigningKey
|
||||
from bigchaindb.common.exceptions import CyclicBlockchainError
|
||||
from bigchaindb.common.util import serialize
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
b.create_genesis_block()
|
||||
@ -55,7 +55,7 @@ class TestBigchainApi(object):
|
||||
|
||||
def test_try_voting_while_constructing_cyclic_blockchain(self, b,
|
||||
monkeypatch):
|
||||
from bigchaindb_common.exceptions import CyclicBlockchainError
|
||||
from bigchaindb.common.exceptions import CyclicBlockchainError
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
b.create_genesis_block()
|
||||
@ -94,7 +94,7 @@ class TestBigchainApi(object):
|
||||
assert not matches
|
||||
|
||||
def test_get_spent_with_double_spend(self, b, monkeypatch):
|
||||
from bigchaindb_common.exceptions import DoubleSpend
|
||||
from bigchaindb.common.exceptions import DoubleSpend
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
b.create_genesis_block()
|
||||
@ -128,7 +128,7 @@ class TestBigchainApi(object):
|
||||
b.get_spent(tx.id, 0)
|
||||
|
||||
def test_get_block_status_for_tx_with_double_spend(self, b, monkeypatch):
|
||||
from bigchaindb_common.exceptions import DoubleSpend
|
||||
from bigchaindb.common.exceptions import DoubleSpend
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
b.create_genesis_block()
|
||||
@ -277,7 +277,7 @@ class TestBigchainApi(object):
|
||||
|
||||
def test_create_genesis_block_fails_if_table_not_empty(self, b):
|
||||
import rethinkdb as r
|
||||
from bigchaindb_common.exceptions import GenesisBlockAlreadyExistsError
|
||||
from bigchaindb.common.exceptions import GenesisBlockAlreadyExistsError
|
||||
from bigchaindb.util import is_genesis_block
|
||||
from bigchaindb.db.utils import get_conn
|
||||
|
||||
@ -333,7 +333,7 @@ class TestBigchainApi(object):
|
||||
assert prev_block_id == last_block['id']
|
||||
|
||||
def test_create_empty_block(self, b):
|
||||
from bigchaindb_common.exceptions import OperationError
|
||||
from bigchaindb.common.exceptions import OperationError
|
||||
|
||||
with pytest.raises(OperationError) as excinfo:
|
||||
b.create_block([])
|
||||
@ -433,7 +433,7 @@ class TestBigchainApi(object):
|
||||
|
||||
def test_more_votes_than_voters(self, b):
|
||||
import rethinkdb as r
|
||||
from bigchaindb_common.exceptions import MultipleVotesError
|
||||
from bigchaindb.common.exceptions import MultipleVotesError
|
||||
from bigchaindb.db.utils import get_conn
|
||||
|
||||
b.create_genesis_block()
|
||||
@ -453,7 +453,7 @@ class TestBigchainApi(object):
|
||||
|
||||
def test_multiple_votes_single_node(self, b):
|
||||
import rethinkdb as r
|
||||
from bigchaindb_common.exceptions import MultipleVotesError
|
||||
from bigchaindb.common.exceptions import MultipleVotesError
|
||||
from bigchaindb.db.utils import get_conn
|
||||
|
||||
genesis = b.create_genesis_block()
|
||||
@ -475,7 +475,7 @@ class TestBigchainApi(object):
|
||||
|
||||
def test_improper_vote_error(selfs, b):
|
||||
import rethinkdb as r
|
||||
from bigchaindb_common.exceptions import ImproperVoteError
|
||||
from bigchaindb.common.exceptions import ImproperVoteError
|
||||
from bigchaindb.db.utils import get_conn
|
||||
|
||||
b.create_genesis_block()
|
||||
@ -512,7 +512,7 @@ class TestBigchainApi(object):
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_assign_transaction_multiple_nodes(self, b, user_vk, user_sk):
|
||||
import rethinkdb as r
|
||||
from bigchaindb_common.crypto import generate_key_pair
|
||||
from bigchaindb.common.crypto import generate_key_pair
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.db.utils import get_conn
|
||||
|
||||
@ -539,8 +539,8 @@ class TestBigchainApi(object):
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_non_create_input_not_found(self, b, user_vk):
|
||||
from cryptoconditions import Ed25519Fulfillment
|
||||
from bigchaindb_common.exceptions import TransactionDoesNotExist
|
||||
from bigchaindb_common.transaction import (Fulfillment, Asset,
|
||||
from bigchaindb.common.exceptions import TransactionDoesNotExist
|
||||
from bigchaindb.common.transaction import (Fulfillment, Asset,
|
||||
TransactionLink)
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb import Bigchain
|
||||
@ -557,7 +557,7 @@ class TestBigchainApi(object):
|
||||
|
||||
class TestTransactionValidation(object):
|
||||
def test_create_operation_with_inputs(self, b, user_vk, create_tx):
|
||||
from bigchaindb_common.transaction import TransactionLink
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
# Manipulate fulfillment so that it has a `tx_input` defined even
|
||||
# though it shouldn't have one
|
||||
@ -575,8 +575,8 @@ class TestTransactionValidation(object):
|
||||
assert excinfo.value.args[0] == 'Only `CREATE` transactions can have null inputs'
|
||||
|
||||
def test_non_create_input_not_found(self, b, user_vk, signed_transfer_tx):
|
||||
from bigchaindb_common.exceptions import TransactionDoesNotExist
|
||||
from bigchaindb_common.transaction import TransactionLink
|
||||
from bigchaindb.common.exceptions import TransactionDoesNotExist
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
signed_transfer_tx.fulfillments[0].tx_input = TransactionLink('c', 0)
|
||||
with pytest.raises(TransactionDoesNotExist):
|
||||
@ -584,8 +584,8 @@ class TestTransactionValidation(object):
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_non_create_valid_input_wrong_owner(self, b, user_vk):
|
||||
from bigchaindb_common.crypto import generate_key_pair
|
||||
from bigchaindb_common.exceptions import InvalidSignature
|
||||
from bigchaindb.common.crypto import generate_key_pair
|
||||
from bigchaindb.common.exceptions import InvalidSignature
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
@ -602,7 +602,7 @@ class TestTransactionValidation(object):
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_non_create_double_spend(self, b, signed_create_tx,
|
||||
signed_transfer_tx):
|
||||
from bigchaindb_common.exceptions import DoubleSpend
|
||||
from bigchaindb.common.exceptions import DoubleSpend
|
||||
|
||||
block1 = b.create_block([signed_create_tx])
|
||||
b.write_block(block1)
|
||||
@ -652,7 +652,7 @@ class TestTransactionValidation(object):
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_fulfillment_not_in_valid_block(self, b, user_vk, user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb_common.exceptions import FulfillmentNotInValidBlock
|
||||
from bigchaindb.common.exceptions import FulfillmentNotInValidBlock
|
||||
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
input_tx = b.get_transaction(input_tx.txid)
|
||||
@ -681,9 +681,9 @@ class TestBlockValidation(object):
|
||||
@pytest.mark.skipif(reason='Separated tx validation from block creation.')
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_invalid_transactions_in_block(self, b, user_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb_common.exceptions import TransactionOwnerError
|
||||
from bigchaindb_common.util import gen_timestamp
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.exceptions import TransactionOwnerError
|
||||
from bigchaindb.common.util import gen_timestamp
|
||||
|
||||
from bigchaindb import util
|
||||
|
||||
@ -722,8 +722,8 @@ class TestBlockValidation(object):
|
||||
assert excinfo.value.args[0] == 'owner_before `a` does not own the input `{}`'.format(valid_input)
|
||||
|
||||
def test_invalid_signature(self, b):
|
||||
from bigchaindb_common.exceptions import InvalidSignature
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common.exceptions import InvalidSignature
|
||||
from bigchaindb.common import crypto
|
||||
|
||||
# create a valid block
|
||||
block = dummy_block()
|
||||
@ -736,8 +736,8 @@ class TestBlockValidation(object):
|
||||
b.validate_block(block)
|
||||
|
||||
def test_invalid_node_pubkey(self, b):
|
||||
from bigchaindb_common.exceptions import OperationError
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common.exceptions import OperationError
|
||||
from bigchaindb.common import crypto
|
||||
|
||||
# blocks can only be created by a federation node
|
||||
# create a valid block
|
||||
@ -761,7 +761,7 @@ class TestBlockValidation(object):
|
||||
class TestMultipleInputs(object):
|
||||
def test_transfer_single_owner_single_input(self, b, inputs, user_vk,
|
||||
user_sk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
|
||||
@ -781,7 +781,7 @@ class TestMultipleInputs(object):
|
||||
'multiple assets'))
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_transfer_single_owners_multiple_inputs(self, b, user_sk, user_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
@ -804,7 +804,7 @@ class TestMultipleInputs(object):
|
||||
def test_transfer_single_owners_single_input_from_multiple_outputs(self, b,
|
||||
user_sk,
|
||||
user_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
@ -843,7 +843,7 @@ class TestMultipleInputs(object):
|
||||
user_sk,
|
||||
user_vk,
|
||||
inputs):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
@ -866,7 +866,7 @@ class TestMultipleInputs(object):
|
||||
def test_single_owner_before_multiple_owners_after_multiple_inputs(self, b,
|
||||
user_sk,
|
||||
user_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
@ -897,7 +897,7 @@ class TestMultipleInputs(object):
|
||||
def test_multiple_owners_before_single_owner_after_single_input(self, b,
|
||||
user_sk,
|
||||
user_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
@ -930,7 +930,7 @@ class TestMultipleInputs(object):
|
||||
@pytest.mark.usefixtures('inputs_shared')
|
||||
def test_multiple_owners_before_single_owner_after_multiple_inputs(self, b,
|
||||
user_sk, user_vk, user2_vk, user2_sk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
# create a new users
|
||||
@ -951,7 +951,7 @@ class TestMultipleInputs(object):
|
||||
def test_multiple_owners_before_multiple_owners_after_single_input(self, b,
|
||||
user_sk,
|
||||
user_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
@ -985,7 +985,7 @@ class TestMultipleInputs(object):
|
||||
def test_multiple_owners_before_multiple_owners_after_multiple_inputs(self, b,
|
||||
user_sk, user_vk,
|
||||
user2_sk, user2_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
# create a new users
|
||||
@ -1004,8 +1004,8 @@ class TestMultipleInputs(object):
|
||||
assert len(tx.conditions) == len(inputs)
|
||||
|
||||
def test_get_owned_ids_single_tx_single_output(self, b, user_sk, user_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb_common.transaction import TransactionLink
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
@ -1033,8 +1033,8 @@ class TestMultipleInputs(object):
|
||||
def test_get_owned_ids_single_tx_single_output_invalid_block(self, b,
|
||||
user_sk,
|
||||
user_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb_common.transaction import TransactionLink
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
genesis = b.create_genesis_block()
|
||||
@ -1078,8 +1078,8 @@ class TestMultipleInputs(object):
|
||||
def test_get_owned_ids_single_tx_multiple_outputs(self, b, user_sk,
|
||||
user_vk):
|
||||
import random
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb_common.transaction import TransactionLink
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
@ -1115,8 +1115,8 @@ class TestMultipleInputs(object):
|
||||
TransactionLink(tx.id, 1)]
|
||||
|
||||
def test_get_owned_ids_multiple_owners(self, b, user_sk, user_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb_common.transaction import TransactionLink
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
@ -1145,7 +1145,7 @@ class TestMultipleInputs(object):
|
||||
assert owned_inputs_user1 == []
|
||||
|
||||
def test_get_spent_single_tx_single_output(self, b, user_sk, user_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
@ -1173,7 +1173,7 @@ class TestMultipleInputs(object):
|
||||
assert spent_inputs_user1 == tx
|
||||
|
||||
def test_get_spent_single_tx_single_output_invalid_block(self, b, user_sk, user_vk):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
genesis = b.create_genesis_block()
|
||||
@ -1219,7 +1219,7 @@ class TestMultipleInputs(object):
|
||||
'multiple assets'))
|
||||
def test_get_spent_single_tx_multiple_outputs(self, b, user_sk, user_vk):
|
||||
import random
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
# create a new users
|
||||
@ -1259,7 +1259,7 @@ class TestMultipleInputs(object):
|
||||
|
||||
def test_get_spent_multiple_owners(self, b, user_sk, user_vk):
|
||||
import random
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
|
@ -1,6 +1,6 @@
|
||||
import builtins
|
||||
|
||||
from bigchaindb_common import exceptions
|
||||
from bigchaindb.common import exceptions
|
||||
import pytest
|
||||
import rethinkdb as r
|
||||
|
||||
|
@ -2,7 +2,7 @@ import json
|
||||
from time import sleep
|
||||
|
||||
import cryptoconditions as cc
|
||||
from bigchaindb_common.util import gen_timestamp
|
||||
from bigchaindb.common.util import gen_timestamp
|
||||
|
||||
from bigchaindb import Bigchain, util, crypto, exceptions
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import time
|
||||
from unittest.mock import patch
|
||||
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
import rethinkdb as r
|
||||
from multipipes import Pipe, Pipeline
|
||||
|
||||
|
@ -19,8 +19,8 @@ def dummy_block(b):
|
||||
|
||||
|
||||
def test_vote_creation_valid(b):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb_common.util import serialize
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.util import serialize
|
||||
|
||||
# create valid block
|
||||
block = dummy_block(b)
|
||||
@ -38,8 +38,8 @@ def test_vote_creation_valid(b):
|
||||
|
||||
|
||||
def test_vote_creation_invalid(b):
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb_common.util import serialize
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.util import serialize
|
||||
|
||||
# create valid block
|
||||
block = dummy_block(b)
|
||||
@ -154,7 +154,7 @@ def test_vote_accumulates_transactions(b):
|
||||
|
||||
|
||||
def test_valid_block_voting_sequential(b, monkeypatch):
|
||||
from bigchaindb_common import crypto, util
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.pipelines import vote
|
||||
|
||||
monkeypatch.setattr('time.time', lambda: 1)
|
||||
@ -182,7 +182,7 @@ def test_valid_block_voting_sequential(b, monkeypatch):
|
||||
|
||||
|
||||
def test_valid_block_voting_multiprocessing(b, monkeypatch):
|
||||
from bigchaindb_common import crypto, util
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.pipelines import vote
|
||||
|
||||
inpipe = Pipe()
|
||||
@ -216,7 +216,7 @@ def test_valid_block_voting_multiprocessing(b, monkeypatch):
|
||||
|
||||
|
||||
def test_valid_block_voting_with_create_transaction(b, monkeypatch):
|
||||
from bigchaindb_common import crypto, util
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines import vote
|
||||
|
||||
@ -257,7 +257,7 @@ def test_valid_block_voting_with_create_transaction(b, monkeypatch):
|
||||
|
||||
|
||||
def test_valid_block_voting_with_transfer_transactions(monkeypatch, b):
|
||||
from bigchaindb_common import crypto, util
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines import vote
|
||||
|
||||
@ -325,7 +325,7 @@ def test_valid_block_voting_with_transfer_transactions(monkeypatch, b):
|
||||
|
||||
|
||||
def test_unsigned_tx_in_block_voting(monkeypatch, b, user_vk):
|
||||
from bigchaindb_common import crypto, util
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines import vote
|
||||
|
||||
@ -362,7 +362,7 @@ def test_unsigned_tx_in_block_voting(monkeypatch, b, user_vk):
|
||||
|
||||
|
||||
def test_invalid_id_tx_in_block_voting(monkeypatch, b, user_vk):
|
||||
from bigchaindb_common import crypto, util
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines import vote
|
||||
|
||||
@ -401,7 +401,7 @@ def test_invalid_id_tx_in_block_voting(monkeypatch, b, user_vk):
|
||||
|
||||
|
||||
def test_invalid_content_in_tx_in_block_voting(monkeypatch, b, user_vk):
|
||||
from bigchaindb_common import crypto, util
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines import vote
|
||||
|
||||
@ -440,7 +440,7 @@ def test_invalid_content_in_tx_in_block_voting(monkeypatch, b, user_vk):
|
||||
|
||||
|
||||
def test_invalid_block_voting(monkeypatch, b, user_vk):
|
||||
from bigchaindb_common import crypto, util
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.pipelines import vote
|
||||
|
||||
inpipe = Pipe()
|
||||
|
@ -22,7 +22,7 @@ def mock_write_config(monkeypatch):
|
||||
@pytest.fixture
|
||||
def mock_db_init_with_existing_db(monkeypatch):
|
||||
from bigchaindb import db
|
||||
from bigchaindb_common.exceptions import DatabaseAlreadyExists
|
||||
from bigchaindb.common.exceptions import DatabaseAlreadyExists
|
||||
|
||||
def mockreturn():
|
||||
raise DatabaseAlreadyExists
|
||||
@ -48,7 +48,7 @@ def mock_rethink_db_drop(monkeypatch):
|
||||
|
||||
@pytest.fixture
|
||||
def mock_generate_key_pair(monkeypatch):
|
||||
monkeypatch.setattr('bigchaindb_common.crypto.generate_key_pair', lambda: ('privkey', 'pubkey'))
|
||||
monkeypatch.setattr('bigchaindb.common.crypto.generate_key_pair', lambda: ('privkey', 'pubkey'))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -283,14 +283,14 @@ def test_start_rethinkdb_returns_a_process_when_successful(mock_popen):
|
||||
|
||||
@patch('subprocess.Popen')
|
||||
def test_start_rethinkdb_exits_when_cannot_start(mock_popen):
|
||||
from bigchaindb_common import exceptions
|
||||
from bigchaindb.common import exceptions
|
||||
from bigchaindb.commands import utils
|
||||
mock_popen.return_value = Mock(stdout=['Nopety nope'])
|
||||
with pytest.raises(exceptions.StartupError):
|
||||
utils.start_rethinkdb()
|
||||
|
||||
|
||||
@patch('bigchaindb_common.crypto.generate_key_pair',
|
||||
@patch('bigchaindb.common.crypto.generate_key_pair',
|
||||
return_value=('private_key', 'public_key'))
|
||||
def test_allow_temp_keypair_generates_one_on_the_fly(mock_gen_keypair,
|
||||
mock_processes_start,
|
||||
@ -307,7 +307,7 @@ def test_allow_temp_keypair_generates_one_on_the_fly(mock_gen_keypair,
|
||||
assert bigchaindb.config['keypair']['public'] == 'public_key'
|
||||
|
||||
|
||||
@patch('bigchaindb_common.crypto.generate_key_pair',
|
||||
@patch('bigchaindb.common.crypto.generate_key_pair',
|
||||
return_value=('private_key', 'public_key'))
|
||||
def test_allow_temp_keypair_doesnt_override_if_keypair_found(mock_gen_keypair,
|
||||
mock_processes_start,
|
||||
|
@ -42,7 +42,7 @@ def test_bigchain_instance_is_initialized_when_conf_provided():
|
||||
|
||||
def test_bigchain_instance_raises_when_not_configured(monkeypatch):
|
||||
from bigchaindb import config_utils
|
||||
from bigchaindb_common import exceptions
|
||||
from bigchaindb.common import exceptions
|
||||
assert 'CONFIGURED' not in bigchaindb.config
|
||||
|
||||
# We need to disable ``bigchaindb.config_utils.autoconfigure`` to avoid reading
|
||||
@ -204,7 +204,7 @@ def test_file_config():
|
||||
|
||||
def test_invalid_file_config():
|
||||
from bigchaindb.config_utils import file_config
|
||||
from bigchaindb_common import exceptions
|
||||
from bigchaindb.common import exceptions
|
||||
with patch('builtins.open', mock_open(read_data='{_INVALID_JSON_}')):
|
||||
with pytest.raises(exceptions.ConfigurationError):
|
||||
file_config()
|
||||
|
@ -37,8 +37,8 @@ class TestBlockModel(object):
|
||||
'not a list or None')
|
||||
|
||||
def test_block_serialization(self, b):
|
||||
from bigchaindb_common.crypto import hash_data
|
||||
from bigchaindb_common.util import gen_timestamp, serialize
|
||||
from bigchaindb.common.crypto import hash_data
|
||||
from bigchaindb.common.util import gen_timestamp, serialize
|
||||
from bigchaindb.models import Block, Transaction
|
||||
|
||||
transactions = [Transaction.create([b.me], [b.me])]
|
||||
@ -61,7 +61,7 @@ class TestBlockModel(object):
|
||||
assert block.to_dict() == expected
|
||||
|
||||
def test_block_invalid_serializaton(self):
|
||||
from bigchaindb_common.exceptions import OperationError
|
||||
from bigchaindb.common.exceptions import OperationError
|
||||
from bigchaindb.models import Block
|
||||
|
||||
block = Block([])
|
||||
@ -69,8 +69,8 @@ class TestBlockModel(object):
|
||||
block.to_dict()
|
||||
|
||||
def test_block_deserialization(self, b):
|
||||
from bigchaindb_common.crypto import hash_data
|
||||
from bigchaindb_common.util import gen_timestamp, serialize
|
||||
from bigchaindb.common.crypto import hash_data
|
||||
from bigchaindb.common.util import gen_timestamp, serialize
|
||||
from bigchaindb.models import Block, Transaction
|
||||
|
||||
transactions = [Transaction.create([b.me], [b.me])]
|
||||
@ -94,7 +94,7 @@ class TestBlockModel(object):
|
||||
assert expected == Block.from_dict(block_body)
|
||||
|
||||
def test_block_invalid_id_deserialization(self, b):
|
||||
from bigchaindb_common.exceptions import InvalidHash
|
||||
from bigchaindb.common.exceptions import InvalidHash
|
||||
from bigchaindb.models import Block
|
||||
|
||||
block = {
|
||||
@ -108,9 +108,9 @@ class TestBlockModel(object):
|
||||
Block.from_dict(block)
|
||||
|
||||
def test_block_invalid_signature_deserialization(self, b):
|
||||
from bigchaindb_common.crypto import hash_data
|
||||
from bigchaindb_common.exceptions import InvalidSignature
|
||||
from bigchaindb_common.util import gen_timestamp, serialize
|
||||
from bigchaindb.common.crypto import hash_data
|
||||
from bigchaindb.common.exceptions import InvalidSignature
|
||||
from bigchaindb.common.util import gen_timestamp, serialize
|
||||
from bigchaindb.models import Block, Transaction
|
||||
|
||||
transactions = [Transaction.create([b.me], [b.me])]
|
||||
@ -142,8 +142,8 @@ class TestBlockModel(object):
|
||||
assert Block(transactions) == Block(transactions)
|
||||
|
||||
def test_sign_block(self, b):
|
||||
from bigchaindb_common.crypto import SigningKey, VerifyingKey
|
||||
from bigchaindb_common.util import gen_timestamp, serialize
|
||||
from bigchaindb.common.crypto import SigningKey, VerifyingKey
|
||||
from bigchaindb.common.util import gen_timestamp, serialize
|
||||
from bigchaindb.models import Block, Transaction
|
||||
|
||||
transactions = [Transaction.create([b.me], [b.me])]
|
||||
|
@ -1,7 +1,7 @@
|
||||
import json
|
||||
|
||||
import pytest
|
||||
from bigchaindb_common import crypto
|
||||
from bigchaindb.common import crypto
|
||||
|
||||
|
||||
TX_ENDPOINT = '/api/v1/transactions/'
|
||||
|
Loading…
x
Reference in New Issue
Block a user