blackified the project

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
Jürgen Eckel 2023-01-26 00:17:31 +01:00
parent 0e79bbecca
commit be6afa8785
No known key found for this signature in database
3 changed files with 47 additions and 34 deletions

View File

@ -467,13 +467,14 @@ class Planetmint(object):
if tx.operation != Transaction.COMPOSE:
asset_id = tx.get_asset_id(input_txs)
if asset_id != Transaction.read_out_asset_id(tx):
raise AssetIdMismatch(("The asset id of the input does not" " match the asset id of the" " transaction"))
raise AssetIdMismatch(
("The asset id of the input does not" " match the asset id of the" " transaction")
)
else:
asset_ids = Transaction.get_asset_ids(input_txs)
if Transaction.read_out_asset_id(tx) in asset_ids:
raise AssetIdMismatch(("The asset ID of the compose must be different to all of its input asset IDs"))
def validate_inputs_distinct(self, tx):
# Validate that all inputs are distinct
links = [i.fulfills.to_uri() for i in tx.inputs]

View File

@ -68,6 +68,7 @@ def test_asset_id_mismatch(alice, user_pk):
with pytest.raises(AssetIdMismatch):
Transaction.get_asset_id([tx1, tx2])
def test_compose_valid_transactions(b, user_pk, user_sk, alice, signed_create_tx, _bdb):
from transactions.types.assets.compose import Compose
@ -80,6 +81,7 @@ def test_compose_valid_transactions(b, user_pk, user_sk, alice, signed_create_tx
compose_transaction.sign([user_sk])
assert b.validate_transaction(compose_transaction)
def test_create_valid_divisible_asset(b, user_pk, user_sk, _bdb):
tx = Create.generate([user_pk], [([user_pk], 2)])
tx_signed = tx.sign([user_sk])

View File

@ -32,6 +32,7 @@ from transactions.common.crypto import generate_key_pair
TX_ENDPOINT = "/api/v1/transactions/"
@pytest.mark.abci
def test_get_transaction_endpoint(client, posted_create_tx):
res = client.get(TX_ENDPOINT + posted_create_tx.id)
@ -473,9 +474,14 @@ def test_post_transaction_invalid_mode(client):
assert "400 BAD REQUEST" in response.status
assert 'Mode must be "async", "sync" or "commit"' == json.loads(response.data.decode("utf8"))["message"]["mode"]
def test_post_transaction_compose_valid_wo_abci(b, _bdb):
alice = generate_key_pair()
tx = Create.generate([alice.public_key], [([alice.public_key], 1)], assets=[{"data":"QmW5GVMW98D3mktSDfWHS8nX2UiCd8gP1uCiujnFX4yK97"}]).sign([alice.private_key])
tx = Create.generate(
[alice.public_key],
[([alice.public_key], 1)],
assets=[{"data": "QmW5GVMW98D3mktSDfWHS8nX2UiCd8gP1uCiujnFX4yK97"}],
).sign([alice.private_key])
validated = b.validate_transaction(tx)
b.store_bulk_transactions([validated])
@ -497,7 +503,11 @@ def test_post_transaction_compose_valid_wo_abci(b, _bdb):
def test_post_transaction_compose_valid(client, b):
mode = ("?mode=commit", BROADCAST_TX_COMMIT)
alice = generate_key_pair()
tx = Create.generate([alice.public_key], [([alice.public_key], 1)], assets=[{"data":"QmW5GVMW98D3mktSDfWHS8nX2UiCd8gP1uCiujnFX4yK97"}]).sign([alice.private_key])
tx = Create.generate(
[alice.public_key],
[([alice.public_key], 1)],
assets=[{"data": "QmW5GVMW98D3mktSDfWHS8nX2UiCd8gP1uCiujnFX4yK97"}],
).sign([alice.private_key])
mode_endpoint = TX_ENDPOINT + mode[0]
response = client.post(mode_endpoint, data=json.dumps(tx.to_dict()))
assert "202 ACCEPTED" in response.status