mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-26 07:25:44 +00:00
blackified the project
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
0e79bbecca
commit
be6afa8785
@ -467,13 +467,14 @@ class Planetmint(object):
|
|||||||
if tx.operation != Transaction.COMPOSE:
|
if tx.operation != Transaction.COMPOSE:
|
||||||
asset_id = tx.get_asset_id(input_txs)
|
asset_id = tx.get_asset_id(input_txs)
|
||||||
if asset_id != Transaction.read_out_asset_id(tx):
|
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:
|
else:
|
||||||
asset_ids = Transaction.get_asset_ids(input_txs)
|
asset_ids = Transaction.get_asset_ids(input_txs)
|
||||||
if Transaction.read_out_asset_id(tx) in asset_ids:
|
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"))
|
raise AssetIdMismatch(("The asset ID of the compose must be different to all of its input asset IDs"))
|
||||||
|
|
||||||
|
|
||||||
def validate_inputs_distinct(self, tx):
|
def validate_inputs_distinct(self, tx):
|
||||||
# Validate that all inputs are distinct
|
# Validate that all inputs are distinct
|
||||||
links = [i.fulfills.to_uri() for i in tx.inputs]
|
links = [i.fulfills.to_uri() for i in tx.inputs]
|
||||||
|
|||||||
@ -68,6 +68,7 @@ def test_asset_id_mismatch(alice, user_pk):
|
|||||||
with pytest.raises(AssetIdMismatch):
|
with pytest.raises(AssetIdMismatch):
|
||||||
Transaction.get_asset_id([tx1, tx2])
|
Transaction.get_asset_id([tx1, tx2])
|
||||||
|
|
||||||
|
|
||||||
def test_compose_valid_transactions(b, user_pk, user_sk, alice, signed_create_tx, _bdb):
|
def test_compose_valid_transactions(b, user_pk, user_sk, alice, signed_create_tx, _bdb):
|
||||||
from transactions.types.assets.compose import Compose
|
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])
|
compose_transaction.sign([user_sk])
|
||||||
assert b.validate_transaction(compose_transaction)
|
assert b.validate_transaction(compose_transaction)
|
||||||
|
|
||||||
|
|
||||||
def test_create_valid_divisible_asset(b, user_pk, user_sk, _bdb):
|
def test_create_valid_divisible_asset(b, user_pk, user_sk, _bdb):
|
||||||
tx = Create.generate([user_pk], [([user_pk], 2)])
|
tx = Create.generate([user_pk], [([user_pk], 2)])
|
||||||
tx_signed = tx.sign([user_sk])
|
tx_signed = tx.sign([user_sk])
|
||||||
|
|||||||
@ -32,6 +32,7 @@ from transactions.common.crypto import generate_key_pair
|
|||||||
|
|
||||||
TX_ENDPOINT = "/api/v1/transactions/"
|
TX_ENDPOINT = "/api/v1/transactions/"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.abci
|
@pytest.mark.abci
|
||||||
def test_get_transaction_endpoint(client, posted_create_tx):
|
def test_get_transaction_endpoint(client, posted_create_tx):
|
||||||
res = client.get(TX_ENDPOINT + posted_create_tx.id)
|
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 "400 BAD REQUEST" in response.status
|
||||||
assert 'Mode must be "async", "sync" or "commit"' == json.loads(response.data.decode("utf8"))["message"]["mode"]
|
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):
|
def test_post_transaction_compose_valid_wo_abci(b, _bdb):
|
||||||
alice = generate_key_pair()
|
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)
|
validated = b.validate_transaction(tx)
|
||||||
b.store_bulk_transactions([validated])
|
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):
|
def test_post_transaction_compose_valid(client, b):
|
||||||
mode = ("?mode=commit", BROADCAST_TX_COMMIT)
|
mode = ("?mode=commit", BROADCAST_TX_COMMIT)
|
||||||
alice = generate_key_pair()
|
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]
|
mode_endpoint = TX_ENDPOINT + mode[0]
|
||||||
response = client.post(mode_endpoint, data=json.dumps(tx.to_dict()))
|
response = client.post(mode_endpoint, data=json.dumps(tx.to_dict()))
|
||||||
assert "202 ACCEPTED" in response.status
|
assert "202 ACCEPTED" in response.status
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user