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