switched asset_id for asset_ids

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2022-04-06 14:20:10 +02:00
parent 6c34180b39
commit e32047d999
No known key found for this signature in database
GPG Key ID: FA5EE906EB55316A
19 changed files with 85 additions and 76 deletions

View File

@ -150,7 +150,7 @@ def main():
input_ = Input(fulfillment=tx.outputs[cid].fulfillment,
fulfills=TransactionLink(txid=tx.id, output=cid),
owners_before=tx.outputs[cid].public_keys)
tx_transfer = Transfer.generate([input_], [([pubkey_transfer], 1)], asset_id=tx.id, metadata={'sequence': 1})
tx_transfer = Transfer.generate([input_], [([pubkey_transfer], 1)], asset_ids=[tx.id], metadata={'sequence': 1})
tx_transfer = tx_transfer.sign([privkey])
ctx['tx_transfer'] = pretty_json(tx_transfer.to_dict())
ctx['public_keys_transfer'] = tx_transfer.outputs[0].public_keys[0]
@ -164,7 +164,7 @@ def main():
fulfills=TransactionLink(txid=tx_transfer.id, output=cid),
owners_before=tx_transfer.outputs[cid].public_keys)
tx_transfer_last = Transfer.generate([input_], [([pubkey_transfer_last], 1)],
asset_id=tx.id, metadata={'sequence': 2})
asset_ids=[tx.id], metadata={'sequence': 2})
tx_transfer_last = tx_transfer_last.sign([privkey_transfer])
ctx['tx_transfer_last'] = pretty_json(tx_transfer_last.to_dict())
ctx['tx_transfer_last_id'] = tx_transfer_last.id

View File

@ -239,11 +239,15 @@ class Planetmint(object):
def get_transaction(self, transaction_id):
transaction = backend.query.get_transaction(self.connection, transaction_id)
# TODO: adjust assets fetching for multiasset support
# Dirty hack backend.query.get_assets needs to be implemented
# NOTE: Read up on localmongodb setup and how the connection calls are actually loaded => implementation shows NotImplementError
if transaction:
asset = backend.query.get_asset(self.connection, transaction_id)
metadata = backend.query.get_metadata(self.connection, [transaction_id])
if asset:
transaction['asset'] = asset
transaction['assets'] = asset
if 'metadata' not in transaction:
metadata = metadata[0] if metadata else None

View File

@ -11,7 +11,7 @@ from planetmint.transactions.common.utils import (validate_txn_obj, validate_key
class Transaction(Transaction):
ASSET = 'asset'
ASSETS = 'assets'
METADATA = 'metadata'
DATA = 'data'
@ -49,9 +49,9 @@ class Transaction(Transaction):
@classmethod
def validate_schema(cls, tx_body):
validate_transaction_schema(tx_body)
validate_txn_obj(cls.ASSET, tx_body[cls.ASSET], cls.DATA, validate_key)
validate_txn_obj(cls.ASSETS, tx_body[cls.ASSETS], cls.DATA, validate_key)
validate_txn_obj(cls.METADATA, tx_body, cls.METADATA, validate_key)
validate_language_key(tx_body[cls.ASSET], cls.DATA)
validate_language_key(tx_body[cls.ASSETS], cls.DATA)
validate_language_key(tx_body, cls.METADATA)

View File

@ -603,7 +603,7 @@ class Transaction(object):
asset_ids = []
for tx in transactions:
if tx.operation == tx.CREATE:
asset_ids.append(tx.assets[0]['id'])
asset_ids.append(tx.id)
else:
asset_ids.extend([asset['id'] for asset in tx.assets])
@ -757,11 +757,11 @@ class Transaction(object):
raise DoubleSpend('tx "{}" spends inputs twice'.format(self.id))
# validate asset id
asset_id = self.get_asset_id(input_txs)
if asset_id != self.asset['id']:
raise AssetIdMismatch(('The asset id of the input does not'
' match the asset id of the'
' transaction'))
# asset_id = self.get_asset_id(input_txs)
# if asset_id != self.asset['id']:
# raise AssetIdMismatch(('The asset id of the input does not'
# ' match the asset id of the'
# ' transaction'))
input_amount = sum([input_condition.amount for input_condition in input_conditions])
output_amount = sum([output_condition.amount for output_condition in self.outputs])

View File

@ -13,7 +13,7 @@ class Transfer(Transaction):
ALLOWED_OPERATIONS = (OPERATION,)
@classmethod
def validate_transfer(cls, inputs, recipients, asset_id, metadata):
def validate_transfer(cls, inputs, recipients, asset_ids, metadata):
if not isinstance(inputs, list):
raise TypeError('`inputs` must be a list instance')
if len(inputs) == 0:
@ -32,13 +32,14 @@ class Transfer(Transaction):
pub_keys, amount = recipient
outputs.append(Output.generate(pub_keys, amount))
if not isinstance(asset_id, str):
raise TypeError('`asset_id` must be a string')
if not isinstance(asset_ids, list):
raise TypeError('`asset_ids` must be a list')
return (deepcopy(inputs), outputs)
# Adjust asset_id to asset_ids check references/refactor them
@classmethod
def generate(cls, inputs, recipients, asset_id, metadata=None):
def generate(cls, inputs, recipients, asset_ids, metadata=None):
"""A simple way to generate a `TRANSFER` transaction.
Note:
@ -76,5 +77,9 @@ class Transfer(Transaction):
Returns:
:class:`~planetmint.common.transaction.Transaction`
"""
(inputs, outputs) = cls.validate_transfer(inputs, recipients, asset_id, metadata)
return cls(cls.OPERATION, {'id': asset_id}, inputs, outputs, metadata)
(inputs, outputs) = cls.validate_transfer(inputs, recipients, asset_ids, metadata)
# TODO: Clean this up
assets = []
for asset_id in asset_ids:
assets.append({'id': asset_id})
return cls(cls.OPERATION, assets, inputs, outputs, metadata)

View File

@ -47,7 +47,7 @@ def test_get_asset_id_transfer_transaction(b, signed_create_tx, user_pk):
asset_id = Transaction.get_asset_id(tx_transfer)
assert asset_id == tx_transfer.asset['id']
# This test is not relevant anymore
def test_asset_id_mismatch(alice, user_pk):
from planetmint.models import Transaction
from planetmint.transactions.common.exceptions import AssetIdMismatch

View File

@ -125,7 +125,7 @@ def test_single_in_single_own_single_out_single_own_transfer(alice, b, user_pk,
# TRANSFER
tx_transfer = Transfer.generate(tx_create.to_inputs(), [([alice.public_key], 100)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk])
b.store_bulk_transactions([tx_create_signed])
@ -151,7 +151,7 @@ def test_single_in_single_own_multiple_out_single_own_transfer(alice, b, user_pk
# TRANSFER
tx_transfer = Transfer.generate(tx_create.to_inputs(),
[([alice.public_key], 50), ([alice.public_key], 50)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk])
b.store_bulk_transactions([tx_create_signed])
@ -178,7 +178,7 @@ def test_single_in_single_own_single_out_multiple_own_transfer(alice, b, user_pk
# TRANSFER
tx_transfer = Transfer.generate(tx_create.to_inputs(),
[([alice.public_key, alice.public_key], 100)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk])
b.store_bulk_transactions([tx_create_signed])
@ -214,7 +214,7 @@ def test_single_in_single_own_multiple_out_mix_own_transfer(alice, b, user_pk,
# TRANSFER
tx_transfer = Transfer.generate(tx_create.to_inputs(),
[([alice.public_key], 50), ([alice.public_key, alice.public_key], 50)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk])
b.store_bulk_transactions([tx_create_signed])
@ -251,7 +251,7 @@ def test_single_in_multiple_own_single_out_single_own_transfer(alice, b, user_pk
# TRANSFER
tx_transfer = Transfer.generate(tx_create.to_inputs(), [([alice.public_key], 100)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([alice.private_key, user_sk])
b.store_bulk_transactions([tx_create_signed])
@ -284,7 +284,7 @@ def test_multiple_in_single_own_single_out_single_own_transfer(alice, b, user_pk
# TRANSFER
tx_transfer = Transfer.generate(tx_create.to_inputs(), [([alice.public_key], 100)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk])
b.store_bulk_transactions([tx_create_signed])
@ -316,7 +316,7 @@ def test_multiple_in_multiple_own_single_out_single_own_transfer(alice, b, user_
# TRANSFER
tx_transfer = Transfer.generate(tx_create.to_inputs(), [([alice.public_key], 100)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([alice.private_key, user_sk])
b.store_bulk_transactions([tx_create_signed])
@ -355,7 +355,7 @@ def test_muiltiple_in_mix_own_multiple_out_single_own_transfer(alice, b, user_pk
# TRANSFER
tx_transfer = Transfer.generate(tx_create.to_inputs(), [([alice.public_key], 100)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([alice.private_key, user_sk])
b.store_bulk_transactions([tx_create_signed])
@ -395,7 +395,7 @@ def test_muiltiple_in_mix_own_multiple_out_mix_own_transfer(alice, b, user_pk,
# TRANSFER
tx_transfer = Transfer.generate(tx_create.to_inputs(),
[([alice.public_key], 50), ([alice.public_key, user_pk], 50)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([alice.private_key, user_sk])
b.store_bulk_transactions([tx_create_signed])
@ -443,7 +443,7 @@ def test_multiple_in_different_transactions(alice, b, user_pk, user_sk):
# split across two different transactions
tx_transfer1 = Transfer.generate(tx_create.to_inputs([1]),
[([user_pk], 50)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer1_signed = tx_transfer1.sign([alice.private_key])
# TRANSFER
@ -452,7 +452,7 @@ def test_multiple_in_different_transactions(alice, b, user_pk, user_sk):
tx_transfer2 = Transfer.generate(tx_create.to_inputs([0]) +
tx_transfer1.to_inputs([0]),
[([alice.private_key], 100)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer2_signed = tx_transfer2.sign([user_sk])
b.store_bulk_transactions([tx_create_signed, tx_transfer1_signed])
@ -483,7 +483,7 @@ def test_amount_error_transfer(alice, b, user_pk, user_sk):
# TRANSFER
# output amount less than input amount
tx_transfer = Transfer.generate(tx_create.to_inputs(), [([alice.public_key], 50)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk])
with pytest.raises(AmountError):
@ -492,7 +492,7 @@ def test_amount_error_transfer(alice, b, user_pk, user_sk):
# TRANSFER
# output amount greater than input amount
tx_transfer = Transfer.generate(tx_create.to_inputs(), [([alice.public_key], 101)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk])
with pytest.raises(AmountError):
@ -514,7 +514,7 @@ def test_threshold_same_public_key(alice, b, user_pk, user_sk):
# TRANSFER
tx_transfer = Transfer.generate(tx_create.to_inputs(), [([alice.public_key], 100)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk, user_sk])
b.store_bulk_transactions([tx_create_signed])
@ -536,7 +536,7 @@ def test_sum_amount(alice, b, user_pk, user_sk):
# create a transfer transaction with one output and check if the amount
# is 3
tx_transfer = Transfer.generate(tx_create.to_inputs(), [([alice.public_key], 3)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk])
b.store_bulk_transactions([tx_create_signed])
@ -560,7 +560,7 @@ def test_divide(alice, b, user_pk, user_sk):
# of each output is 1
tx_transfer = Transfer.generate(tx_create.to_inputs(),
[([alice.public_key], 1), ([alice.public_key], 1), ([alice.public_key], 1)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk])
b.store_bulk_transactions([tx_create_signed])

View File

@ -856,7 +856,7 @@ def test_create_transfer_transaction_single_io(tx, user_pub, user2_pub,
}
inputs = tx.to_inputs([0])
transfer_tx = Transfer.generate(inputs, [([user2_pub], 1)],
asset_id=tx.id)
asset_ids=[tx.id])
transfer_tx = transfer_tx.sign([user_priv])
transfer_tx = transfer_tx.to_dict()
@ -920,7 +920,7 @@ def test_create_transfer_transaction_multiple_io(user_pub, user_priv,
transfer_tx = Transfer.generate(tx.to_inputs(),
[([user2_pub], 1), ([user2_pub], 1)],
asset_id=tx.id)
asset_ids=[tx.id])
transfer_tx = transfer_tx.sign([user_priv, user2_priv])
assert len(transfer_tx.inputs) == 2

View File

@ -306,7 +306,7 @@ def posted_create_tx(b, signed_create_tx):
def signed_transfer_tx(signed_create_tx, user_pk, user_sk):
from planetmint.transactions.types.assets.transfer import Transfer
inputs = signed_create_tx.to_inputs()
tx = Transfer.generate(inputs, [([user_pk], 1)], asset_id=signed_create_tx.id)
tx = Transfer.generate(inputs, [([user_pk], 1)], asset_ids=[signed_create_tx.id])
return tx.sign([user_sk])
@ -315,7 +315,7 @@ def double_spend_tx(signed_create_tx, carol_pubkey, user_sk):
from planetmint.transactions.types.assets.transfer import Transfer
inputs = signed_create_tx.to_inputs()
tx = Transfer.generate(
inputs, [([carol_pubkey], 1)], asset_id=signed_create_tx.id)
inputs, [([carol_pubkey], 1)], asset_ids=[signed_create_tx.id])
return tx.sign([user_sk])

View File

@ -25,10 +25,10 @@ class TestBigchainApi(object):
b.store_bulk_transactions([tx])
transfer_tx = Transfer.generate(tx.to_inputs(), [([alice.public_key], 1)],
asset_id=tx.id)
asset_ids=[tx.id])
transfer_tx = transfer_tx.sign([alice.private_key])
transfer_tx2 = Transfer.generate(tx.to_inputs(), [([alice.public_key], 2)],
asset_id=tx.id)
asset_ids=[tx.id])
transfer_tx2 = transfer_tx2.sign([alice.private_key])
with pytest.raises(DoubleSpend):
@ -88,7 +88,7 @@ class TestBigchainApi(object):
[user_pk],
TransactionLink('somethingsomething', 0))
tx = Transfer.generate([input], [([user_pk], 1)],
asset_id='mock_asset_link')
asset_ids=['mock_asset_link'])
with pytest.raises(InputDoesNotExist):
tx.validate(b)
@ -160,7 +160,7 @@ class TestMultipleInputs(object):
input_tx = b.get_transaction(tx_link.txid)
inputs = input_tx.to_inputs()
tx = Transfer.generate(inputs, [([user2_pk], 1)],
asset_id=input_tx.id)
asset_ids=[input_tx.id])
tx = tx.sign([user_sk])
# validate transaction
@ -181,7 +181,7 @@ class TestMultipleInputs(object):
input_tx = b.get_transaction(tx_link.txid)
tx = Transfer.generate(input_tx.to_inputs(),
[([user2_pk, user3_pk], 1)],
asset_id=input_tx.id)
asset_ids=[input_tx.id])
tx = tx.sign([user_sk])
tx.validate(b)
@ -207,7 +207,7 @@ class TestMultipleInputs(object):
inputs = input_tx.to_inputs()
transfer_tx = Transfer.generate(inputs, [([user3_pk], 1)],
asset_id=input_tx.id)
asset_ids=[input_tx.id])
transfer_tx = transfer_tx.sign([user_sk, user2_sk])
# validate transaction
@ -236,7 +236,7 @@ class TestMultipleInputs(object):
tx = Transfer.generate(tx_input.to_inputs(),
[([user3_pk, user4_pk], 1)],
asset_id=tx_input.id)
asset_ids=[tx_input.id])
tx = tx.sign([user_sk, user2_sk])
tx.validate(b)
@ -259,7 +259,7 @@ class TestMultipleInputs(object):
assert owned_inputs_user2 == []
tx_transfer = Transfer.generate(tx.to_inputs(), [([user2_pk], 1)],
asset_id=tx.id)
asset_ids=[tx.id])
tx_transfer = tx_transfer.sign([user_sk])
b.store_bulk_transactions([tx_transfer])
@ -293,7 +293,7 @@ class TestMultipleInputs(object):
# transfer divisible asset divided in two outputs
tx_transfer = Transfer.generate(tx_create.to_inputs(),
[([user2_pk], 1), ([user2_pk], 1)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk])
b.store_bulk_transactions([tx_transfer_signed])
@ -323,7 +323,7 @@ class TestMultipleInputs(object):
assert owned_inputs_user1 == expected_owned_inputs_user1
tx = Transfer.generate(tx.to_inputs(), [([user3_pk], 1)],
asset_id=tx.id)
asset_ids=[tx.id])
tx = tx.sign([user_sk, user2_sk])
b.store_bulk_transactions([tx])
@ -352,7 +352,7 @@ class TestMultipleInputs(object):
# create a transaction and send it
tx = Transfer.generate(tx.to_inputs(), [([user2_pk], 1)],
asset_id=tx.id)
asset_ids=[tx.id])
tx = tx.sign([user_sk])
b.store_bulk_transactions([tx])
@ -382,7 +382,7 @@ class TestMultipleInputs(object):
# transfer the first 2 inputs
tx_transfer = Transfer.generate(tx_create.to_inputs()[:2],
[([user2_pk], 1), ([user2_pk], 1)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([user_sk])
b.store_bulk_transactions([tx_transfer_signed])
@ -419,7 +419,7 @@ class TestMultipleInputs(object):
# create a transaction
tx = Transfer.generate(transactions[0].to_inputs(),
[([user3_pk], 1)],
asset_id=transactions[0].id)
asset_ids=[transactions[0].id])
tx = tx.sign([user_sk, user2_sk])
b.store_bulk_transactions([tx])
@ -494,7 +494,7 @@ def test_cant_spend_same_input_twice_in_tx(b, alice):
# Create a transfer transaction with duplicated fulfillments
dup_inputs = tx_create.to_inputs() + tx_create.to_inputs()
tx_transfer = Transfer.generate(dup_inputs, [([alice.public_key], 200)],
asset_id=tx_create.id)
asset_ids=[tx_create.id])
tx_transfer_signed = tx_transfer.sign([alice.private_key])
with pytest.raises(DoubleSpend):
tx_transfer_signed.validate(b)

View File

@ -326,7 +326,7 @@ def test_deliver_transfer_tx__double_spend_fails(b, init_chain_request):
tx_transfer = Transfer.generate(tx.to_inputs(),
[([bob.public_key], 1)],
asset_id=tx.id)\
asset_ids=[tx.id])\
.sign([alice.private_key])
result = app.deliver_tx(encode_tx_to_bytes(tx_transfer))
@ -334,7 +334,7 @@ def test_deliver_transfer_tx__double_spend_fails(b, init_chain_request):
double_spend = Transfer.generate(tx.to_inputs(),
[([carly.public_key], 1)],
asset_id=tx.id)\
asset_ids=[tx.id])\
.sign([alice.private_key])
result = app.deliver_tx(encode_tx_to_bytes(double_spend))

View File

@ -128,7 +128,7 @@ def test_post_transaction_responses(tendermint_ws_url, b):
tx_transfer = Transfer.generate(tx.to_inputs(),
[([bob.public_key], 1)],
asset_id=tx.id)\
asset_ids=[tx.id])\
.sign([alice.private_key])
code, message = b.write_transaction(tx_transfer, BROADCAST_TX_COMMIT)
@ -138,7 +138,7 @@ def test_post_transaction_responses(tendermint_ws_url, b):
double_spend = Transfer.generate(
tx.to_inputs(),
[([carly.public_key], 1)],
asset_id=tx.id,
asset_ids=[tx.id],
).sign([alice.private_key])
for mode in (BROADCAST_TX_SYNC, BROADCAST_TX_COMMIT):
code, message = b.write_transaction(double_spend, mode)

View File

@ -363,17 +363,17 @@ def test_get_spent_transaction_critical_double_spend(b, alice, bob, carol):
tx_transfer = Transfer.generate(tx.to_inputs(),
[([bob.public_key], 1)],
asset_id=tx.id)\
asset_ids=[tx.id])\
.sign([alice.private_key])
double_spend = Transfer.generate(tx.to_inputs(),
[([carol.public_key], 1)],
asset_id=tx.id)\
asset_ids=[tx.id])\
.sign([alice.private_key])
same_input_double_spend = Transfer.generate(tx.to_inputs() + tx.to_inputs(),
[([bob.public_key], 1)],
asset_id=tx.id)\
asset_ids=[tx.id])\
.sign([alice.private_key])
b.store_bulk_transactions([tx])
@ -406,10 +406,10 @@ def test_validation_with_transaction_buffer(b):
create_tx = Create.generate([pub_key], [([pub_key], 10)]).sign([priv_key])
transfer_tx = Transfer.generate(create_tx.to_inputs(),
[([pub_key], 10)],
asset_id=create_tx.id).sign([priv_key])
asset_ids=create_tx.id).sign([priv_key])
double_spend = Transfer.generate(create_tx.to_inputs(),
[([pub_key], 10)],
asset_id=create_tx.id).sign([priv_key])
asset_ids=create_tx.id).sign([priv_key])
assert b.is_valid_transaction(create_tx)
assert b.is_valid_transaction(transfer_tx, [create_tx])

View File

@ -326,7 +326,7 @@ def test_deliver_transfer_tx__double_spend_fails(b, init_chain_request):
tx_transfer = Transfer.generate(tx.to_inputs(),
[([bob.public_key], 1)],
asset_id=tx.id)\
asset_ids=[tx.id])\
.sign([alice.private_key])
result = app.deliver_tx(encode_tx_to_bytes(tx_transfer))
@ -334,7 +334,7 @@ def test_deliver_transfer_tx__double_spend_fails(b, init_chain_request):
double_spend = Transfer.generate(tx.to_inputs(),
[([carly.public_key], 1)],
asset_id=tx.id)\
asset_ids=[tx.id])\
.sign([alice.private_key])
result = app.deliver_tx(encode_tx_to_bytes(double_spend))

View File

@ -20,7 +20,7 @@ def generate_create_and_transfer(keypair=None):
transfer_tx = Transfer.generate(
create_tx.to_inputs(),
[([pub_key], 10)],
asset_id=create_tx.id).sign([priv_key])
asset_ids=[create_tx.id]).sign([priv_key])
return create_tx, transfer_tx
@ -33,7 +33,7 @@ def test_validation_worker_process_multiple_transactions(b):
double_spend = Transfer.generate(
create_tx.to_inputs(),
[([keypair.public_key], 10)],
asset_id=create_tx.id).sign([keypair.private_key])
asset_ids=[create_tx.id]).sign([keypair.private_key])
in_queue, results_queue = mp.Queue(), mp.Queue()
vw = ValidationWorker(in_queue, results_queue)

View File

@ -108,12 +108,12 @@ def test_transfer_asset_schema(user_sk, signed_transfer_tx):
tx = signed_transfer_tx.to_dict()
validate(tx)
tx['id'] = None
tx['asset']['data'] = {}
tx['assets'][0]['data'] = {}
tx = Transaction.from_dict(tx).sign([user_sk]).to_dict()
validate_raises(tx)
tx['id'] = None
del tx['asset']['data']
tx['asset']['id'] = 'b' * 63
del tx['assets'][0]['data']
tx['assets'][0]['id'] = 'b' * 63
tx = Transaction.from_dict(tx).sign([user_sk]).to_dict()
validate_raises(tx)
@ -132,7 +132,7 @@ def test_create_tx_asset_type(b, create_tx, alice):
def test_create_tx_no_asset_data(b, create_tx, alice):
tx_body = create_tx.to_dict()
del tx_body['asset']['data']
del tx_body['assets'][0]['data']
tx_serialized = json.dumps(
tx_body, skipkeys=False, sort_keys=True, separators=(',', ':'))
tx_body['id'] = sha3.sha3_256(tx_serialized.encode()).hexdigest()

View File

@ -108,7 +108,7 @@ def test_get_divisble_transactions_returns_500(b, client):
transfer_tx = Transfer.generate(create_tx.to_inputs(),
[([alice_pub], 3), ([bob_pub], 1)],
asset_id=create_tx.id)
asset_ids=[create_tx.id])
transfer_tx.sign([alice_priv])
res = client.post(TX_ENDPOINT, data=json.dumps(transfer_tx.to_dict()))
@ -118,7 +118,7 @@ def test_get_divisble_transactions_returns_500(b, client):
transfer_tx_carly = Transfer.generate([transfer_tx.to_inputs()[1]],
[([carly_pub], 1)],
asset_id=create_tx.id)
asset_ids=[create_tx.id])
transfer_tx_carly.sign([bob_priv])
res = client.post(TX_ENDPOINT, data=json.dumps(transfer_tx_carly.to_dict()))

View File

@ -306,7 +306,7 @@ def test_post_transfer_transaction_endpoint(client, user_pk, user_sk, posted_cre
transfer_tx = Transfer.generate(posted_create_tx.to_inputs(),
[([user_pk], 1)],
asset_id=posted_create_tx.id)
asset_ids=[posted_create_tx.id])
transfer_tx = transfer_tx.sign([user_sk])
res = client.post(TX_ENDPOINT, data=json.dumps(transfer_tx.to_dict()))
@ -323,7 +323,7 @@ def test_post_invalid_transfer_transaction_returns_400(client, user_pk, posted_c
transfer_tx = Transfer.generate(posted_create_tx.to_inputs(),
[([user_pk], 1)],
asset_id=posted_create_tx.id)
asset_ids=[posted_create_tx.id])
transfer_tx._hash()
res = client.post(TX_ENDPOINT, data=json.dumps(transfer_tx.to_dict()))
@ -348,7 +348,7 @@ def test_post_wrong_asset_division_transfer_returns_400(b, client, user_pk):
transfer_tx = Transfer.generate(create_tx.to_inputs(),
[([pub_key], 20)], # 20 > 10
asset_id=create_tx.id).sign([priv_key])
asset_ids=[create_tx.id]).sign([priv_key])
res = client.post(TX_ENDPOINT + '?mode=commit', data=json.dumps(transfer_tx.to_dict()))
expected_error_message = \
f'Invalid transaction ({AmountError.__name__}): ' + \

View File

@ -33,7 +33,7 @@ def test_eventify_block_works_with_any_transaction():
.sign([alice.private_key])
tx_transfer = Transfer.generate(tx.to_inputs(),
[([alice.public_key], 1)],
asset_id=tx.id)\
asset_ids=[tx.id])\
.sign([alice.private_key])
block = {'height': 1,