mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Replace all occurrences where vk
is used as a shortcut
for public key and replaced it with `pk`
This commit is contained in:
parent
c068f04a82
commit
3909538c62
@ -130,13 +130,13 @@ def verify_vote_signature(voters, signed_vote):
|
||||
"""
|
||||
|
||||
signature = signed_vote['signature']
|
||||
vk_base58 = signed_vote['node_pubkey']
|
||||
pk_base58 = signed_vote['node_pubkey']
|
||||
|
||||
# immediately return False if the voter is not in the block voter list
|
||||
if vk_base58 not in voters:
|
||||
if pk_base58 not in voters:
|
||||
return False
|
||||
|
||||
public_key = crypto.PublicKey(vk_base58)
|
||||
public_key = crypto.PublicKey(pk_base58)
|
||||
return public_key.verify(serialize(signed_vote['vote']).encode(), signature)
|
||||
|
||||
|
||||
|
@ -52,5 +52,5 @@ signature = sk.sign(tx_serialized)
|
||||
|
||||
# verify signature
|
||||
tx_serialized = bytes(serialize(tx))
|
||||
vk.verify(signature, tx_serialized)
|
||||
pk.verify(signature, tx_serialized)
|
||||
```
|
||||
|
@ -3,13 +3,13 @@ from ..db.conftest import inputs
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_asset_transfer(b, user_vk, user_sk):
|
||||
def test_asset_transfer(b, user_pk, user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
tx_input = b.get_owned_ids(user_vk).pop()
|
||||
tx_input = b.get_owned_ids(user_pk).pop()
|
||||
tx_create = b.get_transaction(tx_input.txid)
|
||||
|
||||
tx_transfer = Transaction.transfer(tx_create.to_inputs(), [user_vk],
|
||||
tx_transfer = Transaction.transfer(tx_create.to_inputs(), [user_pk],
|
||||
tx_create.asset)
|
||||
tx_transfer_signed = tx_transfer.sign([user_sk])
|
||||
|
||||
@ -17,32 +17,32 @@ def test_asset_transfer(b, user_vk, user_sk):
|
||||
assert tx_transfer_signed.asset.data_id == tx_create.asset.data_id
|
||||
|
||||
|
||||
def test_validate_bad_asset_creation(b, user_vk):
|
||||
def test_validate_bad_asset_creation(b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
# `divisible` needs to be a boolean
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx.asset.divisible = 1
|
||||
tx_signed = tx.sign([b.me_private])
|
||||
with pytest.raises(TypeError):
|
||||
tx_signed.validate(b)
|
||||
|
||||
# `refillable` needs to be a boolean
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx.asset.refillable = 1
|
||||
tx_signed = tx.sign([b.me_private])
|
||||
with pytest.raises(TypeError):
|
||||
b.validate_transaction(tx_signed)
|
||||
|
||||
# `updatable` needs to be a boolean
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx.asset.updatable = 1
|
||||
tx_signed = tx.sign([b.me_private])
|
||||
with pytest.raises(TypeError):
|
||||
b.validate_transaction(tx_signed)
|
||||
|
||||
# `data` needs to be a dictionary
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx.asset.data = 'a'
|
||||
tx_signed = tx.sign([b.me_private])
|
||||
with pytest.raises(TypeError):
|
||||
@ -50,14 +50,14 @@ def test_validate_bad_asset_creation(b, user_vk):
|
||||
|
||||
# TODO: Check where to test for the amount
|
||||
"""
|
||||
tx = b.create_transaction(b.me, user_vk, None, 'CREATE')
|
||||
tx = b.create_transaction(b.me, user_pk, None, 'CREATE')
|
||||
tx['transaction']['conditions'][0]['amount'] = 'a'
|
||||
tx['id'] = get_hash_data(tx['transaction'])
|
||||
tx_signed = b.sign_transaction(tx, b.me_private)
|
||||
with pytest.raises(TypeError):
|
||||
b.validate_transaction(tx_signed)
|
||||
|
||||
tx = b.create_transaction(b.me, user_vk, None, 'CREATE')
|
||||
tx = b.create_transaction(b.me, user_pk, None, 'CREATE')
|
||||
tx['transaction']['conditions'][0]['amount'] = 2
|
||||
tx['transaction']['asset'].update({'divisible': False})
|
||||
tx['id'] = get_hash_data(tx['transaction'])
|
||||
@ -65,7 +65,7 @@ def test_validate_bad_asset_creation(b, user_vk):
|
||||
with pytest.raises(AmountError):
|
||||
b.validate_transaction(tx_signed)
|
||||
|
||||
tx = b.create_transaction(b.me, user_vk, None, 'CREATE')
|
||||
tx = b.create_transaction(b.me, user_pk, None, 'CREATE')
|
||||
tx['transaction']['conditions'][0]['amount'] = 0
|
||||
tx['id'] = get_hash_data(tx['transaction'])
|
||||
tx_signed = b.sign_transaction(tx, b.me_private)
|
||||
@ -75,13 +75,13 @@ def test_validate_bad_asset_creation(b, user_vk):
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_validate_transfer_asset_id_mismatch(b, user_vk, user_sk):
|
||||
def test_validate_transfer_asset_id_mismatch(b, user_pk, user_sk):
|
||||
from bigchaindb.common.exceptions import AssetIdMismatch
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
tx_create = b.get_owned_ids(user_vk).pop()
|
||||
tx_create = b.get_owned_ids(user_pk).pop()
|
||||
tx_create = b.get_transaction(tx_create.txid)
|
||||
tx_transfer = Transaction.transfer(tx_create.to_inputs(), [user_vk],
|
||||
tx_transfer = Transaction.transfer(tx_create.to_inputs(), [user_pk],
|
||||
tx_create.asset)
|
||||
tx_transfer.asset.data_id = 'aaa'
|
||||
tx_transfer_signed = tx_transfer.sign([user_sk])
|
||||
@ -89,23 +89,23 @@ def test_validate_transfer_asset_id_mismatch(b, user_vk, user_sk):
|
||||
tx_transfer_signed.validate(b)
|
||||
|
||||
|
||||
def test_get_asset_id_create_transaction(b, user_vk):
|
||||
def test_get_asset_id_create_transaction(b, user_pk):
|
||||
from bigchaindb.models import Transaction, Asset
|
||||
|
||||
tx_create = Transaction.create([b.me], [user_vk])
|
||||
tx_create = Transaction.create([b.me], [user_pk])
|
||||
asset_id = Asset.get_asset_id(tx_create)
|
||||
|
||||
assert asset_id == tx_create.asset.data_id
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_get_asset_id_transfer_transaction(b, user_vk, user_sk):
|
||||
def test_get_asset_id_transfer_transaction(b, user_pk, user_sk):
|
||||
from bigchaindb.models import Transaction, Asset
|
||||
|
||||
tx_create = b.get_owned_ids(user_vk).pop()
|
||||
tx_create = b.get_owned_ids(user_pk).pop()
|
||||
tx_create = b.get_transaction(tx_create.txid)
|
||||
# create a transfer transaction
|
||||
tx_transfer = Transaction.transfer(tx_create.to_inputs(), [user_vk],
|
||||
tx_transfer = Transaction.transfer(tx_create.to_inputs(), [user_pk],
|
||||
tx_create.asset)
|
||||
tx_transfer_signed = tx_transfer.sign([user_sk])
|
||||
# create a block
|
||||
@ -119,22 +119,22 @@ def test_get_asset_id_transfer_transaction(b, user_vk, user_sk):
|
||||
assert asset_id == tx_transfer.asset.data_id
|
||||
|
||||
|
||||
def test_asset_id_mismatch(b, user_vk):
|
||||
def test_asset_id_mismatch(b, user_pk):
|
||||
from bigchaindb.models import Transaction, Asset
|
||||
from bigchaindb.common.exceptions import AssetIdMismatch
|
||||
|
||||
tx1 = Transaction.create([b.me], [user_vk])
|
||||
tx2 = Transaction.create([b.me], [user_vk])
|
||||
tx1 = Transaction.create([b.me], [user_pk])
|
||||
tx2 = Transaction.create([b.me], [user_pk])
|
||||
|
||||
with pytest.raises(AssetIdMismatch):
|
||||
Asset.get_asset_id([tx1, tx2])
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_get_txs_by_asset_id(b, user_vk, user_sk):
|
||||
def test_get_txs_by_asset_id(b, user_pk, user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
tx_create = b.get_owned_ids(user_vk).pop()
|
||||
tx_create = b.get_owned_ids(user_pk).pop()
|
||||
tx_create = b.get_transaction(tx_create.txid)
|
||||
asset_id = tx_create.asset.data_id
|
||||
txs = b.get_txs_by_asset_id(asset_id)
|
||||
@ -144,7 +144,7 @@ def test_get_txs_by_asset_id(b, user_vk, user_sk):
|
||||
assert txs[0].asset.data_id == asset_id
|
||||
|
||||
# create a transfer transaction
|
||||
tx_transfer = Transaction.transfer(tx_create.to_inputs(), [user_vk],
|
||||
tx_transfer = Transaction.transfer(tx_create.to_inputs(), [user_pk],
|
||||
tx_create.asset)
|
||||
tx_transfer_signed = tx_transfer.sign([user_sk])
|
||||
# create the block
|
||||
|
@ -58,7 +58,7 @@ def user_sk():
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user_vk():
|
||||
def user_pk():
|
||||
return USER_PUBLIC_KEY
|
||||
|
||||
|
||||
@ -70,9 +70,9 @@ def b(request, node_config):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_tx(b, user_vk):
|
||||
def create_tx(b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
return Transaction.create([b.me], [user_vk])
|
||||
return Transaction.create([b.me], [user_pk])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -81,8 +81,8 @@ def signed_create_tx(b, create_tx):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def signed_transfer_tx(signed_create_tx, user_vk, user_sk):
|
||||
def signed_transfer_tx(signed_create_tx, user_pk, user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
inputs = signed_create_tx.to_inputs()
|
||||
tx = Transaction.transfer(inputs, [user_vk], signed_create_tx.asset)
|
||||
tx = Transaction.transfer(inputs, [user_pk], signed_create_tx.asset)
|
||||
return tx.sign([user_sk])
|
||||
|
@ -14,7 +14,7 @@ from bigchaindb.db import get_conn, init_database
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.exceptions import DatabaseAlreadyExists
|
||||
|
||||
USER2_SK, USER2_VK = crypto.generate_key_pair()
|
||||
USER2_SK, USER2_PK = crypto.generate_key_pair()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@ -70,7 +70,7 @@ def cleanup_tables(request, node_config):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inputs(user_vk):
|
||||
def inputs(user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.common.exceptions import GenesisBlockAlreadyExistsError
|
||||
# 1. create the genesis block
|
||||
@ -84,7 +84,7 @@ def inputs(user_vk):
|
||||
prev_block_id = g.id
|
||||
for block in range(4):
|
||||
transactions = [
|
||||
Transaction.create([b.me], [user_vk]).sign([b.me_private])
|
||||
Transaction.create([b.me], [user_pk]).sign([b.me_private])
|
||||
for i in range(10)
|
||||
]
|
||||
block = b.create_block(transactions)
|
||||
@ -102,12 +102,12 @@ def user2_sk():
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user2_vk():
|
||||
return USER2_VK
|
||||
def user2_pk():
|
||||
return USER2_PK
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def inputs_shared(user_vk, user2_vk):
|
||||
def inputs_shared(user_pk, user2_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.common.exceptions import GenesisBlockAlreadyExistsError
|
||||
# 1. create the genesis block
|
||||
@ -122,7 +122,7 @@ def inputs_shared(user_vk, user2_vk):
|
||||
for block in range(4):
|
||||
transactions = [
|
||||
Transaction.create(
|
||||
[b.me], [user_vk, user2_vk], payload={'i': i}).sign([b.me_private])
|
||||
[b.me], [user_pk, user2_pk], payload={'i': i}).sign([b.me_private])
|
||||
for i in range(10)
|
||||
]
|
||||
block = b.create_block(transactions)
|
||||
|
@ -181,11 +181,11 @@ class TestBigchainApi(object):
|
||||
assert b.get_transaction(tx1.id) is None
|
||||
assert b.get_transaction(tx2.id) == tx2
|
||||
|
||||
def test_get_transactions_for_metadata(self, b, user_vk):
|
||||
def test_get_transactions_for_metadata(self, b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
metadata = {'msg': 'Hello BigchainDB!'}
|
||||
tx = Transaction.create([b.me], [user_vk], metadata=metadata)
|
||||
tx = Transaction.create([b.me], [user_pk], metadata=metadata)
|
||||
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
@ -194,18 +194,18 @@ class TestBigchainApi(object):
|
||||
assert len(matches) == 1
|
||||
assert matches[0].id == tx.id
|
||||
|
||||
def test_get_transactions_for_metadata(self, b, user_vk):
|
||||
def test_get_transactions_for_metadata(self, b, user_pk):
|
||||
matches = b.get_tx_by_metadata_id('missing')
|
||||
assert not matches
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_write_transaction(self, b, user_vk, user_sk):
|
||||
def test_write_transaction(self, b, user_pk, user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
input_tx = b.get_transaction(input_tx.txid)
|
||||
inputs = input_tx.to_inputs()
|
||||
tx = Transaction.transfer(inputs, [user_vk], input_tx.asset)
|
||||
tx = Transaction.transfer(inputs, [user_pk], input_tx.asset)
|
||||
tx = tx.sign([user_sk])
|
||||
response = b.write_transaction(tx)
|
||||
|
||||
@ -217,13 +217,13 @@ class TestBigchainApi(object):
|
||||
assert response['inserted'] == 1
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_read_transaction(self, b, user_vk, user_sk):
|
||||
def test_read_transaction(self, b, user_pk, user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
input_tx = b.get_transaction(input_tx.txid)
|
||||
inputs = input_tx.to_inputs()
|
||||
tx = Transaction.transfer(inputs, [user_vk], input_tx.asset)
|
||||
tx = Transaction.transfer(inputs, [user_pk], input_tx.asset)
|
||||
tx = tx.sign([user_sk])
|
||||
b.write_transaction(tx)
|
||||
|
||||
@ -237,13 +237,13 @@ class TestBigchainApi(object):
|
||||
assert status == b.TX_UNDECIDED
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_read_transaction_invalid_block(self, b, user_vk, user_sk):
|
||||
def test_read_transaction_invalid_block(self, b, user_pk, user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
input_tx = b.get_transaction(input_tx.txid)
|
||||
inputs = input_tx.to_inputs()
|
||||
tx = Transaction.transfer(inputs, [user_vk], input_tx.asset)
|
||||
tx = Transaction.transfer(inputs, [user_pk], input_tx.asset)
|
||||
tx = tx.sign([user_sk])
|
||||
# There's no need to b.write_transaction(tx) to the backlog
|
||||
|
||||
@ -261,13 +261,13 @@ class TestBigchainApi(object):
|
||||
assert response is None
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_read_transaction_invalid_block_and_backlog(self, b, user_vk, user_sk):
|
||||
def test_read_transaction_invalid_block_and_backlog(self, b, user_pk, user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
input_tx = b.get_transaction(input_tx.txid)
|
||||
inputs = input_tx.to_inputs()
|
||||
tx = Transaction.transfer(inputs, [user_vk], input_tx.asset)
|
||||
tx = Transaction.transfer(inputs, [user_pk], input_tx.asset)
|
||||
tx = tx.sign([user_sk])
|
||||
|
||||
# Make sure there's a copy of tx in the backlog
|
||||
@ -520,15 +520,15 @@ class TestBigchainApi(object):
|
||||
'vote from public key {me}'.format(block_id=block_1.id, me=b.me)
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_assign_transaction_one_node(self, b, user_vk, user_sk):
|
||||
def test_assign_transaction_one_node(self, b, user_pk, user_sk):
|
||||
import rethinkdb as r
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.db.utils import get_conn
|
||||
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
input_tx = b.get_transaction(input_tx.txid)
|
||||
inputs = input_tx.to_inputs()
|
||||
tx = Transaction.transfer(inputs, [user_vk], input_tx.asset)
|
||||
tx = Transaction.transfer(inputs, [user_pk], input_tx.asset)
|
||||
tx = tx.sign([user_sk])
|
||||
b.write_transaction(tx)
|
||||
|
||||
@ -539,7 +539,7 @@ class TestBigchainApi(object):
|
||||
assert response['assignee'] == b.me
|
||||
|
||||
@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_pk, user_sk):
|
||||
import rethinkdb as r
|
||||
from bigchaindb.common.crypto import generate_key_pair
|
||||
from bigchaindb.models import Transaction
|
||||
@ -551,10 +551,10 @@ class TestBigchainApi(object):
|
||||
|
||||
# test assignee for several transactions
|
||||
for _ in range(20):
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
input_tx = b.get_transaction(input_tx.txid)
|
||||
inputs = input_tx.to_inputs()
|
||||
tx = Transaction.transfer(inputs, [user_vk], input_tx.asset)
|
||||
tx = Transaction.transfer(inputs, [user_pk], input_tx.asset)
|
||||
tx = tx.sign([user_sk])
|
||||
b.write_transaction(tx)
|
||||
|
||||
@ -566,7 +566,7 @@ class TestBigchainApi(object):
|
||||
|
||||
|
||||
@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_pk):
|
||||
from cryptoconditions import Ed25519Fulfillment
|
||||
from bigchaindb.common.exceptions import TransactionDoesNotExist
|
||||
from bigchaindb.common.transaction import (Fulfillment, Asset,
|
||||
@ -575,17 +575,17 @@ class TestBigchainApi(object):
|
||||
from bigchaindb import Bigchain
|
||||
|
||||
# Create a fulfillment for a non existing transaction
|
||||
fulfillment = Fulfillment(Ed25519Fulfillment(public_key=user_vk),
|
||||
[user_vk],
|
||||
fulfillment = Fulfillment(Ed25519Fulfillment(public_key=user_pk),
|
||||
[user_pk],
|
||||
TransactionLink('somethingsomething', 0))
|
||||
tx = Transaction.transfer([fulfillment], [user_vk], Asset())
|
||||
tx = Transaction.transfer([fulfillment], [user_pk], Asset())
|
||||
|
||||
with pytest.raises(TransactionDoesNotExist) as excinfo:
|
||||
tx.validate(Bigchain())
|
||||
|
||||
|
||||
class TestTransactionValidation(object):
|
||||
def test_create_operation_with_inputs(self, b, user_vk, create_tx):
|
||||
def test_create_operation_with_inputs(self, b, user_pk, create_tx):
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
# Manipulate fulfillment so that it has a `tx_input` defined even
|
||||
@ -595,7 +595,7 @@ class TestTransactionValidation(object):
|
||||
b.validate_transaction(create_tx)
|
||||
assert excinfo.value.args[0] == 'A CREATE operation has no inputs'
|
||||
|
||||
def test_transfer_operation_no_inputs(self, b, user_vk,
|
||||
def test_transfer_operation_no_inputs(self, b, user_pk,
|
||||
signed_transfer_tx):
|
||||
signed_transfer_tx.fulfillments[0].tx_input = None
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
@ -603,7 +603,7 @@ class TestTransactionValidation(object):
|
||||
|
||||
assert excinfo.value.args[0] == 'Only `CREATE` transactions can have null inputs'
|
||||
|
||||
def test_non_create_input_not_found(self, b, user_vk, signed_transfer_tx):
|
||||
def test_non_create_input_not_found(self, b, user_pk, signed_transfer_tx):
|
||||
from bigchaindb.common.exceptions import TransactionDoesNotExist
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
|
||||
@ -612,15 +612,15 @@ class TestTransactionValidation(object):
|
||||
b.validate_transaction(signed_transfer_tx)
|
||||
|
||||
@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_pk):
|
||||
from bigchaindb.common.crypto import generate_key_pair
|
||||
from bigchaindb.common.exceptions import InvalidSignature
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
input_transaction = b.get_transaction(input_tx.txid)
|
||||
sk, vk = generate_key_pair()
|
||||
tx = Transaction.create([vk], [user_vk])
|
||||
sk, pk = generate_key_pair()
|
||||
tx = Transaction.create([pk], [user_pk])
|
||||
tx.operation = 'TRANSFER'
|
||||
tx.asset = input_transaction.asset
|
||||
tx.fulfillments[0].tx_input = input_tx
|
||||
@ -657,14 +657,14 @@ class TestTransactionValidation(object):
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_valid_non_create_transaction_after_block_creation(self, b,
|
||||
user_vk,
|
||||
user_pk,
|
||||
user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
input_tx = b.get_transaction(input_tx.txid)
|
||||
inputs = input_tx.to_inputs()
|
||||
transfer_tx = Transaction.transfer(inputs, [user_vk], input_tx.asset)
|
||||
transfer_tx = Transaction.transfer(inputs, [user_pk], input_tx.asset)
|
||||
transfer_tx = transfer_tx.sign([user_sk])
|
||||
|
||||
assert transfer_tx == b.validate_transaction(transfer_tx)
|
||||
@ -679,16 +679,16 @@ class TestTransactionValidation(object):
|
||||
assert transfer_tx == b.validate_transaction(transfer_tx)
|
||||
|
||||
@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_pk, user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.common.exceptions import FulfillmentNotInValidBlock
|
||||
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
input_tx = b.get_transaction(input_tx.txid)
|
||||
inputs = input_tx.to_inputs()
|
||||
|
||||
# create a transaction that's valid but not in a voted valid block
|
||||
transfer_tx = Transaction.transfer(inputs, [user_vk], input_tx.asset)
|
||||
transfer_tx = Transaction.transfer(inputs, [user_pk], input_tx.asset)
|
||||
transfer_tx = transfer_tx.sign([user_sk])
|
||||
|
||||
assert transfer_tx == b.validate_transaction(transfer_tx)
|
||||
@ -698,7 +698,7 @@ class TestTransactionValidation(object):
|
||||
b.write_block(block, durability='hard')
|
||||
|
||||
# create transaction with the undecided input
|
||||
tx_invalid = Transaction.transfer(transfer_tx.to_inputs(), [user_vk],
|
||||
tx_invalid = Transaction.transfer(transfer_tx.to_inputs(), [user_pk],
|
||||
transfer_tx.asset)
|
||||
tx_invalid = tx_invalid.sign([user_sk])
|
||||
|
||||
@ -709,7 +709,7 @@ class TestTransactionValidation(object):
|
||||
class TestBlockValidation(object):
|
||||
@pytest.mark.skipif(reason='Separated tx validation from block creation.')
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_invalid_transactions_in_block(self, b, user_vk):
|
||||
def test_invalid_transactions_in_block(self, b, user_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.exceptions import TransactionOwnerError
|
||||
from bigchaindb.common.util import gen_timestamp
|
||||
@ -717,7 +717,7 @@ class TestBlockValidation(object):
|
||||
from bigchaindb import util
|
||||
|
||||
# invalid transaction
|
||||
valid_input = b.get_owned_ids(user_vk).pop()
|
||||
valid_input = b.get_owned_ids(user_pk).pop()
|
||||
tx_invalid = b.create_transaction('a', 'b', valid_input, 'c')
|
||||
|
||||
block = b.create_block([tx_invalid])
|
||||
@ -773,10 +773,10 @@ class TestBlockValidation(object):
|
||||
block = dummy_block()
|
||||
|
||||
# create some temp keys
|
||||
tmp_sk, tmp_vk = crypto.generate_key_pair()
|
||||
tmp_sk, tmp_pk = crypto.generate_key_pair()
|
||||
|
||||
# change the block node_pubkey
|
||||
block.node_pubkey = tmp_vk
|
||||
block.node_pubkey = tmp_pk
|
||||
|
||||
# just to make sure lets re-hash the block and create a valid signature
|
||||
# from a non federation node
|
||||
@ -788,16 +788,16 @@ class TestBlockValidation(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_pk,
|
||||
user_sk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
|
||||
tx_link = b.get_owned_ids(user_vk).pop()
|
||||
tx_link = b.get_owned_ids(user_pk).pop()
|
||||
input_tx = b.get_transaction(tx_link.txid)
|
||||
inputs = input_tx.to_inputs()
|
||||
tx = Transaction.transfer(inputs, [user2_vk], input_tx.asset)
|
||||
tx = Transaction.transfer(inputs, [user2_pk], input_tx.asset)
|
||||
tx = tx.sign([user_sk])
|
||||
|
||||
# validate transaction
|
||||
@ -809,18 +809,18 @@ class TestMultipleInputs(object):
|
||||
'same asset. Remove this after implementing ',
|
||||
'multiple assets'))
|
||||
@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_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
|
||||
# get inputs
|
||||
owned_inputs = b.get_owned_ids(user_vk)
|
||||
owned_inputs = b.get_owned_ids(user_pk)
|
||||
input_txs = [b.get_transaction(tx_link.txid) for tx_link
|
||||
in owned_inputs]
|
||||
inputs = sum([input_tx.to_inputs() for input_tx in input_txs], [])
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user_vk]])
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user_pk]])
|
||||
tx = tx.sign([user_sk])
|
||||
assert b.validate_transaction(tx) == tx
|
||||
assert len(tx.fulfillments) == len(inputs)
|
||||
@ -832,18 +832,18 @@ class TestMultipleInputs(object):
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_transfer_single_owners_single_input_from_multiple_outputs(self, b,
|
||||
user_sk,
|
||||
user_vk):
|
||||
user_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
|
||||
# get inputs
|
||||
owned_inputs = b.get_owned_ids(user_vk)
|
||||
owned_inputs = b.get_owned_ids(user_pk)
|
||||
input_txs = [b.get_transaction(tx_link.txid) for tx_link
|
||||
in owned_inputs]
|
||||
inputs = sum([input_tx.to_inputs() for input_tx in input_txs], [])
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user2_vk]])
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user2_pk]])
|
||||
tx = tx.sign([user_sk])
|
||||
|
||||
# create block with the transaction
|
||||
@ -855,13 +855,13 @@ class TestMultipleInputs(object):
|
||||
b.write_vote(vote)
|
||||
|
||||
# get inputs from user2
|
||||
owned_inputs = b.get_owned_ids(user2_vk)
|
||||
owned_inputs = b.get_owned_ids(user2_pk)
|
||||
assert len(owned_inputs) == len(inputs)
|
||||
|
||||
# create a transaction with a single input from a multiple output transaction
|
||||
tx_link = owned_inputs.pop()
|
||||
inputs = b.get_transaction(tx_link.txid).to_inputs([0])
|
||||
tx = Transaction.transfer(inputs, [user_vk])
|
||||
tx = Transaction.transfer(inputs, [user_pk])
|
||||
tx = tx.sign([user2_sk])
|
||||
|
||||
assert b.is_valid_transaction(tx) == tx
|
||||
@ -870,18 +870,18 @@ class TestMultipleInputs(object):
|
||||
|
||||
def test_single_owner_before_multiple_owners_after_single_input(self, b,
|
||||
user_sk,
|
||||
user_vk,
|
||||
user_pk,
|
||||
inputs):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user3_sk, user3_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
user3_sk, user3_pk = crypto.generate_key_pair()
|
||||
|
||||
owned_inputs = b.get_owned_ids(user_vk)
|
||||
owned_inputs = b.get_owned_ids(user_pk)
|
||||
tx_link = owned_inputs.pop()
|
||||
input_tx = b.get_transaction(tx_link.txid)
|
||||
tx = Transaction.transfer(input_tx.to_inputs(), [[user2_vk, user3_vk]], input_tx.asset)
|
||||
tx = Transaction.transfer(input_tx.to_inputs(), [[user2_pk, user3_pk]], input_tx.asset)
|
||||
tx = tx.sign([user_sk])
|
||||
|
||||
assert b.is_valid_transaction(tx) == tx
|
||||
@ -894,19 +894,19 @@ class TestMultipleInputs(object):
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_single_owner_before_multiple_owners_after_multiple_inputs(self, b,
|
||||
user_sk,
|
||||
user_vk):
|
||||
user_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user3_sk, user3_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
user3_sk, user3_pk = crypto.generate_key_pair()
|
||||
|
||||
owned_inputs = b.get_owned_ids(user_vk)
|
||||
owned_inputs = b.get_owned_ids(user_pk)
|
||||
input_txs = [b.get_transaction(tx_link.txid) for tx_link
|
||||
in owned_inputs]
|
||||
inputs = sum([input_tx.to_inputs() for input_tx in input_txs], [])
|
||||
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user2_vk, user3_vk]])
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user2_pk, user3_pk]])
|
||||
tx = tx.sign([user_sk])
|
||||
|
||||
# create block with the transaction
|
||||
@ -925,14 +925,14 @@ class TestMultipleInputs(object):
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_multiple_owners_before_single_owner_after_single_input(self, b,
|
||||
user_sk,
|
||||
user_vk):
|
||||
user_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user3_sk, user3_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
user3_sk, user3_pk = crypto.generate_key_pair()
|
||||
|
||||
tx = Transaction.create([b.me], [user_vk, user2_vk])
|
||||
tx = Transaction.create([b.me], [user_pk, user2_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
@ -941,11 +941,11 @@ class TestMultipleInputs(object):
|
||||
vote = b.vote(block.id, b.get_last_voted_block().id, True)
|
||||
b.write_vote(vote)
|
||||
|
||||
owned_input = b.get_owned_ids(user_vk).pop()
|
||||
owned_input = b.get_owned_ids(user_pk).pop()
|
||||
input_tx = b.get_transaction(owned_input.txid)
|
||||
inputs = input_tx.to_inputs()
|
||||
|
||||
transfer_tx = Transaction.transfer(inputs, [user3_vk], input_tx.asset)
|
||||
transfer_tx = Transaction.transfer(inputs, [user3_pk], input_tx.asset)
|
||||
transfer_tx = transfer_tx.sign([user_sk, user2_sk])
|
||||
|
||||
# validate transaction
|
||||
@ -958,18 +958,18 @@ class TestMultipleInputs(object):
|
||||
'multiple assets'))
|
||||
@pytest.mark.usefixtures('inputs_shared')
|
||||
def test_multiple_owners_before_single_owner_after_multiple_inputs(self, b,
|
||||
user_sk, user_vk, user2_vk, user2_sk):
|
||||
user_sk, user_pk, user2_pk, user2_sk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
# create a new users
|
||||
user3_sk, user3_vk = crypto.generate_key_pair()
|
||||
user3_sk, user3_pk = crypto.generate_key_pair()
|
||||
|
||||
tx_links = b.get_owned_ids(user_vk)
|
||||
tx_links = b.get_owned_ids(user_pk)
|
||||
inputs = sum([b.get_transaction(tx_link.txid).to_inputs() for tx_link
|
||||
in tx_links], [])
|
||||
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user3_vk]])
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user3_pk]])
|
||||
tx = tx.sign([user_sk, user2_sk])
|
||||
|
||||
assert b.is_valid_transaction(tx) == tx
|
||||
@ -979,15 +979,15 @@ class TestMultipleInputs(object):
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_multiple_owners_before_multiple_owners_after_single_input(self, b,
|
||||
user_sk,
|
||||
user_vk):
|
||||
user_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user3_sk, user3_vk = crypto.generate_key_pair()
|
||||
user4_sk, user4_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
user3_sk, user3_pk = crypto.generate_key_pair()
|
||||
user4_sk, user4_pk = crypto.generate_key_pair()
|
||||
|
||||
tx = Transaction.create([b.me], [user_vk, user2_vk])
|
||||
tx = Transaction.create([b.me], [user_pk, user2_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
@ -997,10 +997,10 @@ class TestMultipleInputs(object):
|
||||
b.write_vote(vote)
|
||||
|
||||
# get input
|
||||
tx_link = b.get_owned_ids(user_vk).pop()
|
||||
tx_link = b.get_owned_ids(user_pk).pop()
|
||||
tx_input = b.get_transaction(tx_link.txid)
|
||||
|
||||
tx = Transaction.transfer(tx_input.to_inputs(), [[user3_vk, user4_vk]], tx_input.asset)
|
||||
tx = Transaction.transfer(tx_input.to_inputs(), [[user3_pk, user4_pk]], tx_input.asset)
|
||||
tx = tx.sign([user_sk, user2_sk])
|
||||
|
||||
assert b.is_valid_transaction(tx) == tx
|
||||
@ -1012,64 +1012,64 @@ class TestMultipleInputs(object):
|
||||
'multiple assets'))
|
||||
@pytest.mark.usefixtures('inputs_shared')
|
||||
def test_multiple_owners_before_multiple_owners_after_multiple_inputs(self, b,
|
||||
user_sk, user_vk,
|
||||
user2_sk, user2_vk):
|
||||
user_sk, user_pk,
|
||||
user2_sk, user2_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
# create a new users
|
||||
user3_sk, user3_vk = crypto.generate_key_pair()
|
||||
user4_sk, user4_vk = crypto.generate_key_pair()
|
||||
user3_sk, user3_pk = crypto.generate_key_pair()
|
||||
user4_sk, user4_pk = crypto.generate_key_pair()
|
||||
|
||||
tx_links = b.get_owned_ids(user_vk)
|
||||
tx_links = b.get_owned_ids(user_pk)
|
||||
inputs = sum([b.get_transaction(tx_link.txid).to_inputs() for tx_link
|
||||
in tx_links], [])
|
||||
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user3_vk, user4_vk]])
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user3_pk, user4_pk]])
|
||||
tx = tx.sign([user_sk, user2_sk])
|
||||
|
||||
assert b.is_valid_transaction(tx) == tx
|
||||
assert len(tx.fulfillments) == 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_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_vk)
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_pk)
|
||||
assert owned_inputs_user1 == [TransactionLink(tx.id, 0)]
|
||||
assert owned_inputs_user2 == []
|
||||
|
||||
tx = Transaction.transfer(tx.to_inputs(), [user2_vk], tx.asset)
|
||||
tx = Transaction.transfer(tx.to_inputs(), [user2_pk], tx.asset)
|
||||
tx = tx.sign([user_sk])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_vk)
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_pk)
|
||||
assert owned_inputs_user1 == []
|
||||
assert owned_inputs_user2 == [TransactionLink(tx.id, 0)]
|
||||
|
||||
def test_get_owned_ids_single_tx_single_output_invalid_block(self, b,
|
||||
user_sk,
|
||||
user_vk):
|
||||
user_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
genesis = b.create_genesis_block()
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
@ -1078,14 +1078,14 @@ class TestMultipleInputs(object):
|
||||
vote = b.vote(block.id, genesis.id, True)
|
||||
b.write_vote(vote)
|
||||
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_vk)
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_pk)
|
||||
assert owned_inputs_user1 == [TransactionLink(tx.id, 0)]
|
||||
assert owned_inputs_user2 == []
|
||||
|
||||
# NOTE: The transaction itself is valid, still will mark the block
|
||||
# as invalid to mock the behavior.
|
||||
tx_invalid = Transaction.transfer(tx.to_inputs(), [user2_vk], tx.asset)
|
||||
tx_invalid = Transaction.transfer(tx.to_inputs(), [user2_pk], tx.asset)
|
||||
tx_invalid = tx_invalid.sign([user_sk])
|
||||
block = b.create_block([tx_invalid])
|
||||
b.write_block(block, durability='hard')
|
||||
@ -1094,8 +1094,8 @@ class TestMultipleInputs(object):
|
||||
vote = b.vote(block.id, b.get_last_voted_block().id, False)
|
||||
b.write_vote(vote)
|
||||
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_vk)
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_pk)
|
||||
|
||||
# should be the same as before (note tx, not tx_invalid)
|
||||
assert owned_inputs_user1 == [TransactionLink(tx.id, 0)]
|
||||
@ -1105,26 +1105,26 @@ class TestMultipleInputs(object):
|
||||
'same asset. Remove this after implementing ',
|
||||
'multiple assets'))
|
||||
def test_get_owned_ids_single_tx_multiple_outputs(self, b, user_sk,
|
||||
user_vk):
|
||||
user_pk):
|
||||
import random
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
|
||||
transactions = []
|
||||
for i in range(2):
|
||||
payload = {'somedata': random.randint(0, 255)}
|
||||
tx = Transaction.create([b.me], [user_vk], payload)
|
||||
tx = Transaction.create([b.me], [user_pk], payload)
|
||||
tx = tx.sign([b.me_private])
|
||||
transactions.append(tx)
|
||||
block = b.create_block(transactions)
|
||||
b.write_block(block, durability='hard')
|
||||
|
||||
# get input
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_vk)
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_pk)
|
||||
|
||||
expected_owned_inputs_user1 = [TransactionLink(tx.id, 0) for tx
|
||||
in transactions]
|
||||
@ -1132,59 +1132,59 @@ class TestMultipleInputs(object):
|
||||
assert owned_inputs_user2 == []
|
||||
|
||||
inputs = sum([tx.to_inputs() for tx in transactions], [])
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user2_vk]])
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user2_pk]])
|
||||
tx = tx.sign([user_sk])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_vk)
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_pk)
|
||||
assert owned_inputs_user1 == []
|
||||
assert owned_inputs_user2 == [TransactionLink(tx.id, 0),
|
||||
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_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.common.transaction import TransactionLink
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user3_sk, user3_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
user3_sk, user3_pk = crypto.generate_key_pair()
|
||||
|
||||
tx = Transaction.create([b.me], [user_vk, user2_vk])
|
||||
tx = Transaction.create([b.me], [user_pk, user2_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_vk)
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_pk)
|
||||
expected_owned_inputs_user1 = [TransactionLink(tx.id, 0)]
|
||||
|
||||
assert owned_inputs_user1 == owned_inputs_user2
|
||||
assert owned_inputs_user1 == expected_owned_inputs_user1
|
||||
|
||||
tx = Transaction.transfer(tx.to_inputs(), [user3_vk], tx.asset)
|
||||
tx = Transaction.transfer(tx.to_inputs(), [user3_pk], tx.asset)
|
||||
tx = tx.sign([user_sk, user2_sk])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_vk)
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk)
|
||||
owned_inputs_user2 = b.get_owned_ids(user2_pk)
|
||||
assert owned_inputs_user1 == owned_inputs_user2
|
||||
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_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk).pop()
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk).pop()
|
||||
|
||||
# check spents
|
||||
input_txid = owned_inputs_user1.txid
|
||||
@ -1193,7 +1193,7 @@ class TestMultipleInputs(object):
|
||||
assert spent_inputs_user1 is None
|
||||
|
||||
# create a transaction and block
|
||||
tx = Transaction.transfer(tx.to_inputs(), [user2_vk], tx.asset)
|
||||
tx = Transaction.transfer(tx.to_inputs(), [user2_pk], tx.asset)
|
||||
tx = tx.sign([user_sk])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
@ -1201,16 +1201,16 @@ class TestMultipleInputs(object):
|
||||
spent_inputs_user1 = b.get_spent(input_txid, input_cid)
|
||||
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_pk):
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
genesis = b.create_genesis_block()
|
||||
|
||||
# create a new users
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
@ -1219,7 +1219,7 @@ class TestMultipleInputs(object):
|
||||
vote = b.vote(block.id, genesis.id, True)
|
||||
b.write_vote(vote)
|
||||
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk).pop()
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk).pop()
|
||||
|
||||
# check spents
|
||||
input_txid = owned_inputs_user1.txid
|
||||
@ -1228,7 +1228,7 @@ class TestMultipleInputs(object):
|
||||
assert spent_inputs_user1 is None
|
||||
|
||||
# create a transaction and block
|
||||
tx = Transaction.transfer(tx.to_inputs(), [user2_vk], tx.asset)
|
||||
tx = Transaction.transfer(tx.to_inputs(), [user2_pk], tx.asset)
|
||||
tx = tx.sign([user_sk])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
@ -1246,24 +1246,24 @@ class TestMultipleInputs(object):
|
||||
@pytest.mark.skipif(reason=('Multiple inputs are only allowed for the '
|
||||
'same asset. Remove this after implementing ',
|
||||
'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_pk):
|
||||
import random
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
# create a new users
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
|
||||
transactions = []
|
||||
for i in range(3):
|
||||
payload = {'somedata': random.randint(0, 255)}
|
||||
tx = Transaction.create([b.me], [user_vk], payload)
|
||||
tx = Transaction.create([b.me], [user_pk], payload)
|
||||
tx = tx.sign([b.me_private])
|
||||
transactions.append(tx)
|
||||
block = b.create_block(transactions)
|
||||
b.write_block(block, durability='hard')
|
||||
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk)
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk)
|
||||
|
||||
# check spents
|
||||
for input_tx in owned_inputs_user1:
|
||||
@ -1273,7 +1273,7 @@ class TestMultipleInputs(object):
|
||||
inputs = sum([tx.to_inputs() for tx in transactions[:2]], [])
|
||||
|
||||
# create a transaction and block
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user2_vk]])
|
||||
tx = Transaction.transfer(inputs, len(inputs) * [[user2_pk]])
|
||||
tx = tx.sign([user_sk])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
@ -1286,31 +1286,31 @@ class TestMultipleInputs(object):
|
||||
# spendable by BigchainDB
|
||||
assert b.get_spent(transactions[2].id, 0) is None
|
||||
|
||||
def test_get_spent_multiple_owners(self, b, user_sk, user_vk):
|
||||
def test_get_spent_multiple_owners(self, b, user_sk, user_pk):
|
||||
import random
|
||||
from bigchaindb.common import crypto
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user2_sk, user2_vk = crypto.generate_key_pair()
|
||||
user3_sk, user3_vk = crypto.generate_key_pair()
|
||||
user2_sk, user2_pk = crypto.generate_key_pair()
|
||||
user3_sk, user3_pk = crypto.generate_key_pair()
|
||||
|
||||
transactions = []
|
||||
for i in range(3):
|
||||
payload = {'somedata': random.randint(0, 255)}
|
||||
tx = Transaction.create([b.me], [user_vk, user2_vk], payload)
|
||||
tx = Transaction.create([b.me], [user_pk, user2_pk], payload)
|
||||
tx = tx.sign([b.me_private])
|
||||
transactions.append(tx)
|
||||
block = b.create_block(transactions)
|
||||
b.write_block(block, durability='hard')
|
||||
|
||||
owned_inputs_user1 = b.get_owned_ids(user_vk)
|
||||
owned_inputs_user1 = b.get_owned_ids(user_pk)
|
||||
|
||||
# check spents
|
||||
for input_tx in owned_inputs_user1:
|
||||
assert b.get_spent(input_tx.txid, input_tx.cid) is None
|
||||
|
||||
# create a transaction
|
||||
tx = Transaction.transfer(transactions[0].to_inputs(), [user3_vk], transactions[0].asset)
|
||||
tx = Transaction.transfer(transactions[0].to_inputs(), [user3_pk], transactions[0].asset)
|
||||
tx = tx.sign([user_sk, user2_sk])
|
||||
block = b.create_block([tx])
|
||||
b.write_block(block, durability='hard')
|
||||
|
@ -38,14 +38,14 @@ def test_validate_transaction(b, create_tx):
|
||||
assert block_maker.validate_tx(valid_tx.to_dict()) == valid_tx
|
||||
|
||||
|
||||
def test_create_block(b, user_vk):
|
||||
def test_create_block(b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines.block import BlockPipeline
|
||||
|
||||
block_maker = BlockPipeline()
|
||||
|
||||
for i in range(100):
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
block_maker.create(tx)
|
||||
|
||||
@ -55,7 +55,7 @@ def test_create_block(b, user_vk):
|
||||
assert len(block_doc.transactions) == 100
|
||||
|
||||
|
||||
def test_write_block(b, user_vk):
|
||||
def test_write_block(b, user_pk):
|
||||
from bigchaindb.models import Block, Transaction
|
||||
from bigchaindb.pipelines.block import BlockPipeline
|
||||
|
||||
@ -63,7 +63,7 @@ def test_write_block(b, user_vk):
|
||||
|
||||
txs = []
|
||||
for i in range(100):
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
txs.append(tx)
|
||||
|
||||
@ -75,14 +75,14 @@ def test_write_block(b, user_vk):
|
||||
assert expected == block_doc
|
||||
|
||||
|
||||
def test_duplicate_transaction(b, user_vk):
|
||||
def test_duplicate_transaction(b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines import block
|
||||
block_maker = block.BlockPipeline()
|
||||
|
||||
txs = []
|
||||
for i in range(10):
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
txs.append(tx)
|
||||
|
||||
@ -104,12 +104,12 @@ def test_duplicate_transaction(b, user_vk):
|
||||
assert b.connection.run(r.table('backlog').get(txs[0].id)) is None
|
||||
|
||||
|
||||
def test_delete_tx(b, user_vk):
|
||||
def test_delete_tx(b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines.block import BlockPipeline
|
||||
block_maker = BlockPipeline()
|
||||
for i in range(100):
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
block_maker.create(tx)
|
||||
# make sure the tx appears in the backlog
|
||||
@ -132,13 +132,13 @@ def test_delete_tx(b, user_vk):
|
||||
assert b.connection.run(r.table('backlog').get(tx['id'])) is None
|
||||
|
||||
|
||||
def test_prefeed(b, user_vk):
|
||||
def test_prefeed(b, user_pk):
|
||||
import random
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines.block import initial
|
||||
|
||||
for i in range(100):
|
||||
tx = Transaction.create([b.me], [user_vk], {'msg': random.random()})
|
||||
tx = Transaction.create([b.me], [user_pk], {'msg': random.random()})
|
||||
tx = tx.sign([b.me_private])
|
||||
b.write_transaction(tx)
|
||||
|
||||
@ -158,7 +158,7 @@ def test_start(create_pipeline):
|
||||
assert pipeline == create_pipeline.return_value
|
||||
|
||||
|
||||
def test_full_pipeline(b, user_vk):
|
||||
def test_full_pipeline(b, user_pk):
|
||||
import random
|
||||
from bigchaindb.models import Block, Transaction
|
||||
from bigchaindb.pipelines.block import create_pipeline, get_changefeed
|
||||
@ -167,7 +167,7 @@ def test_full_pipeline(b, user_vk):
|
||||
|
||||
count_assigned_to_me = 0
|
||||
for i in range(100):
|
||||
tx = Transaction.create([b.me], [user_vk], {'msg': random.random()})
|
||||
tx = Transaction.create([b.me], [user_pk], {'msg': random.random()})
|
||||
tx = tx.sign([b.me_private]).to_dict()
|
||||
assignee = random.choice([b.me, 'aaa', 'bbb', 'ccc'])
|
||||
tx['assignee'] = assignee
|
||||
|
@ -9,13 +9,13 @@ from bigchaindb import Bigchain
|
||||
from bigchaindb.pipelines import election
|
||||
|
||||
|
||||
def test_check_for_quorum_invalid(b, user_vk):
|
||||
def test_check_for_quorum_invalid(b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
e = election.Election()
|
||||
|
||||
# create blocks with transactions
|
||||
tx1 = Transaction.create([b.me], [user_vk])
|
||||
tx1 = Transaction.create([b.me], [user_pk])
|
||||
test_block = b.create_block([tx1])
|
||||
|
||||
# simulate a federation with four voters
|
||||
@ -39,12 +39,12 @@ def test_check_for_quorum_invalid(b, user_vk):
|
||||
assert e.check_for_quorum(votes[-1]) == test_block
|
||||
|
||||
|
||||
def test_check_for_quorum_invalid_prev_node(b, user_vk):
|
||||
def test_check_for_quorum_invalid_prev_node(b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
e = election.Election()
|
||||
|
||||
# create blocks with transactions
|
||||
tx1 = Transaction.create([b.me], [user_vk])
|
||||
tx1 = Transaction.create([b.me], [user_pk])
|
||||
test_block = b.create_block([tx1])
|
||||
|
||||
# simulate a federation with four voters
|
||||
@ -68,13 +68,13 @@ def test_check_for_quorum_invalid_prev_node(b, user_vk):
|
||||
assert e.check_for_quorum(votes[-1]) == test_block
|
||||
|
||||
|
||||
def test_check_for_quorum_valid(b, user_vk):
|
||||
def test_check_for_quorum_valid(b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
e = election.Election()
|
||||
|
||||
# create blocks with transactions
|
||||
tx1 = Transaction.create([b.me], [user_vk])
|
||||
tx1 = Transaction.create([b.me], [user_pk])
|
||||
test_block = b.create_block([tx1])
|
||||
|
||||
# simulate a federation with four voters
|
||||
@ -97,13 +97,13 @@ def test_check_for_quorum_valid(b, user_vk):
|
||||
assert e.check_for_quorum(votes[-1]) is None
|
||||
|
||||
|
||||
def test_check_requeue_transaction(b, user_vk):
|
||||
def test_check_requeue_transaction(b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
e = election.Election()
|
||||
|
||||
# create blocks with transactions
|
||||
tx1 = Transaction.create([b.me], [user_vk])
|
||||
tx1 = Transaction.create([b.me], [user_pk])
|
||||
test_block = b.create_block([tx1])
|
||||
|
||||
e.requeue_transactions(test_block)
|
||||
@ -122,7 +122,7 @@ def test_start(mock_start):
|
||||
mock_start.assert_called_with()
|
||||
|
||||
|
||||
def test_full_pipeline(b, user_vk):
|
||||
def test_full_pipeline(b, user_pk):
|
||||
import random
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
@ -131,7 +131,7 @@ def test_full_pipeline(b, user_vk):
|
||||
# write two blocks
|
||||
txs = []
|
||||
for i in range(100):
|
||||
tx = Transaction.create([b.me], [user_vk], {'msg': random.random()})
|
||||
tx = Transaction.create([b.me], [user_pk], {'msg': random.random()})
|
||||
tx = tx.sign([b.me_private])
|
||||
txs.append(tx)
|
||||
|
||||
@ -140,7 +140,7 @@ def test_full_pipeline(b, user_vk):
|
||||
|
||||
txs = []
|
||||
for i in range(100):
|
||||
tx = Transaction.create([b.me], [user_vk], {'msg': random.random()})
|
||||
tx = Transaction.create([b.me], [user_pk], {'msg': random.random()})
|
||||
tx = tx.sign([b.me_private])
|
||||
txs.append(tx)
|
||||
|
||||
|
@ -8,9 +8,9 @@ import time
|
||||
import os
|
||||
|
||||
|
||||
def test_get_stale(b, user_vk):
|
||||
def test_get_stale(b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
b.write_transaction(tx, durability='hard')
|
||||
|
||||
@ -24,10 +24,10 @@ def test_get_stale(b, user_vk):
|
||||
assert tx.to_dict() == _tx
|
||||
|
||||
|
||||
def test_reassign_transactions(b, user_vk):
|
||||
def test_reassign_transactions(b, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
# test with single node
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
b.write_transaction(tx, durability='hard')
|
||||
|
||||
@ -36,7 +36,7 @@ def test_reassign_transactions(b, user_vk):
|
||||
stm.reassign_transactions(tx.to_dict())
|
||||
|
||||
# test with federation
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
b.write_transaction(tx, durability='hard')
|
||||
|
||||
@ -51,7 +51,7 @@ def test_reassign_transactions(b, user_vk):
|
||||
assert reassigned_tx['assignee'] != tx['assignee']
|
||||
|
||||
# test with node not in federation
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private]).to_dict()
|
||||
tx.update({'assignee': 'lol'})
|
||||
tx.update({'assignment_timestamp': time.time()})
|
||||
@ -62,7 +62,7 @@ def test_reassign_transactions(b, user_vk):
|
||||
assert b.connection.run(r.table('backlog').get(tx['id']))['assignee'] != 'lol'
|
||||
|
||||
|
||||
def test_full_pipeline(monkeypatch, user_vk):
|
||||
def test_full_pipeline(monkeypatch, user_pk):
|
||||
from bigchaindb.models import Transaction
|
||||
CONFIG = {
|
||||
'database': {
|
||||
@ -85,7 +85,7 @@ def test_full_pipeline(monkeypatch, user_vk):
|
||||
monkeypatch.setattr('time.time', lambda: 1)
|
||||
|
||||
for i in range(100):
|
||||
tx = Transaction.create([b.me], [user_vk])
|
||||
tx = Transaction.create([b.me], [user_pk])
|
||||
tx = tx.sign([b.me_private])
|
||||
original_txc.append(tx.to_dict())
|
||||
|
||||
|
@ -324,7 +324,7 @@ def test_valid_block_voting_with_transfer_transactions(monkeypatch, b):
|
||||
vote2_doc['signature']) is True
|
||||
|
||||
|
||||
def test_unsigned_tx_in_block_voting(monkeypatch, b, user_vk):
|
||||
def test_unsigned_tx_in_block_voting(monkeypatch, b, user_pk):
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines import vote
|
||||
@ -361,7 +361,7 @@ def test_unsigned_tx_in_block_voting(monkeypatch, b, user_vk):
|
||||
vote_doc['signature']) is True
|
||||
|
||||
|
||||
def test_invalid_id_tx_in_block_voting(monkeypatch, b, user_vk):
|
||||
def test_invalid_id_tx_in_block_voting(monkeypatch, b, user_pk):
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines import vote
|
||||
@ -400,7 +400,7 @@ def test_invalid_id_tx_in_block_voting(monkeypatch, b, user_vk):
|
||||
vote_doc['signature']) is True
|
||||
|
||||
|
||||
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_pk):
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.models import Transaction
|
||||
from bigchaindb.pipelines import vote
|
||||
@ -439,7 +439,7 @@ def test_invalid_content_in_tx_in_block_voting(monkeypatch, b, user_vk):
|
||||
vote_doc['signature']) is True
|
||||
|
||||
|
||||
def test_invalid_block_voting(monkeypatch, b, user_vk):
|
||||
def test_invalid_block_voting(monkeypatch, b, user_pk):
|
||||
from bigchaindb.common import crypto, util
|
||||
from bigchaindb.pipelines import vote
|
||||
|
||||
|
@ -33,5 +33,5 @@ def app(request, node_config):
|
||||
# NOTE: In order to have a database setup as well as the `input` fixture,
|
||||
# we have to proxy `db.conftest.input` here.
|
||||
# TODO: If possible replace this function with something nicer.
|
||||
def inputs(user_vk):
|
||||
conftest.inputs(user_vk)
|
||||
def inputs(user_pk):
|
||||
conftest.inputs(user_pk)
|
||||
|
@ -8,8 +8,8 @@ TX_ENDPOINT = '/api/v1/transactions/'
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_get_transaction_endpoint(b, client, user_vk):
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
def test_get_transaction_endpoint(b, client, user_pk):
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
tx = b.get_transaction(input_tx.txid)
|
||||
res = client.get(TX_ENDPOINT + tx.id)
|
||||
assert tx.to_dict() == res.json
|
||||
@ -69,30 +69,30 @@ def test_post_create_transaction_with_invalid_signature(b, client):
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_post_transfer_transaction_endpoint(b, client, user_vk, user_sk):
|
||||
sk, vk = crypto.generate_key_pair()
|
||||
def test_post_transfer_transaction_endpoint(b, client, user_pk, user_sk):
|
||||
sk, pk = crypto.generate_key_pair()
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user_priv, user_pub = crypto.generate_key_pair()
|
||||
|
||||
input_valid = b.get_owned_ids(user_vk).pop()
|
||||
input_valid = b.get_owned_ids(user_pk).pop()
|
||||
create_tx = b.get_transaction(input_valid.txid)
|
||||
transfer_tx = Transaction.transfer(create_tx.to_inputs(), [user_pub], create_tx.asset)
|
||||
transfer_tx = transfer_tx.sign([user_sk])
|
||||
|
||||
res = client.post(TX_ENDPOINT, data=json.dumps(transfer_tx.to_dict()))
|
||||
|
||||
assert res.json['transaction']['fulfillments'][0]['owners_before'][0] == user_vk
|
||||
assert res.json['transaction']['fulfillments'][0]['owners_before'][0] == user_pk
|
||||
assert res.json['transaction']['conditions'][0]['owners_after'][0] == user_pub
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_post_invalid_transfer_transaction_returns_400(b, client, user_vk, user_sk):
|
||||
def test_post_invalid_transfer_transaction_returns_400(b, client, user_pk, user_sk):
|
||||
from bigchaindb.models import Transaction
|
||||
|
||||
user_priv, user_pub = crypto.generate_key_pair()
|
||||
|
||||
input_valid = b.get_owned_ids(user_vk).pop()
|
||||
input_valid = b.get_owned_ids(user_pk).pop()
|
||||
create_tx = b.get_transaction(input_valid.txid)
|
||||
transfer_tx = Transaction.transfer(create_tx.to_inputs(), [user_pub], create_tx.asset)
|
||||
|
||||
@ -101,8 +101,8 @@ def test_post_invalid_transfer_transaction_returns_400(b, client, user_vk, user_
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('inputs')
|
||||
def test_get_transaction_status_endpoint(b, client, user_vk):
|
||||
input_tx = b.get_owned_ids(user_vk).pop()
|
||||
def test_get_transaction_status_endpoint(b, client, user_pk):
|
||||
input_tx = b.get_owned_ids(user_pk).pop()
|
||||
tx, status = b.get_transaction(input_tx.txid, include_status=True)
|
||||
res = client.get(TX_ENDPOINT + input_tx.txid + "/status")
|
||||
assert status == res.json['status']
|
||||
|
Loading…
x
Reference in New Issue
Block a user