mirror of
https://github.com/planetmint/planetmint.git
synced 2025-03-30 15:08:31 +00:00
some additional tests
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
599f64f68c
commit
414b36f6cb
@ -81,6 +81,16 @@ 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_compose_invalid_transactions(b, user_pk, user_sk, alice, signed_create_tx, _bdb):
|
||||
validated = b.validate_transaction(signed_create_tx)
|
||||
#b.store_bulk_transactions([validated])
|
||||
|
||||
inputs = signed_create_tx.to_inputs()
|
||||
assets = [signed_create_tx.id, "QmW5GVMW98D3mktSDfWHS8nX2UiCd8gP1uCiujnFX4yK8n"]
|
||||
compose_transaction = Compose.generate(inputs=inputs, recipients=[([user_pk], 1)], assets=assets)
|
||||
compose_transaction.sign([user_sk])
|
||||
with pytest.raises(Exception):
|
||||
assert b.validate_transaction(compose_transaction)
|
||||
|
||||
def test_decompose_valid_transactions(b, user_pk, user_sk, alice, signed_create_tx, _bdb):
|
||||
validated = b.validate_transaction(signed_create_tx)
|
||||
|
@ -530,6 +530,28 @@ def test_post_transaction_compose_valid(client, b):
|
||||
assert "202 ACCEPTED" in response.status
|
||||
|
||||
|
||||
@pytest.mark.abci
|
||||
def test_post_transaction_compose_invalid(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_obj = tx
|
||||
tx = tx.to_dict()
|
||||
compose_asset_cid = "bafkreignwcoye67vn6edp23mj4llhpzzkgyuefu7xesjzjxcv2bz3p4nfm"
|
||||
inputs_ = tx_obj.to_inputs()
|
||||
|
||||
assets_ = [tx["id"], compose_asset_cid]
|
||||
compose_transaction = Compose.generate(inputs=inputs_, recipients=[([alice.public_key], 1)], assets=assets_)
|
||||
signed_tx = compose_transaction.sign([alice.private_key])
|
||||
|
||||
mode_endpoint = TX_ENDPOINT + "?mode=commit"
|
||||
response = client.post(mode_endpoint, data=json.dumps(signed_tx.to_dict()))
|
||||
assert "400 BAD REQUEST" in response.status
|
||||
|
||||
@pytest.mark.abci
|
||||
def test_post_transaction_decompose_valid(client, b):
|
||||
mode = ("?mode=commit", BROADCAST_TX_COMMIT)
|
||||
|
Loading…
x
Reference in New Issue
Block a user