test(python): better dependency checking in tox

pull/2352/head
matejcik 2 years ago
parent 455884932e
commit 5977cca202

@ -15,15 +15,19 @@
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. # If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
import pytest import pytest
from stellar_sdk import (
Account, try:
Asset, from stellar_sdk import (
Network, Account,
TransactionBuilder, Asset,
TrustLineEntryFlag, Network,
MuxedAccount, TransactionBuilder,
) TrustLineEntryFlag,
from stellar_sdk.strkey import StrKey MuxedAccount,
)
from stellar_sdk.strkey import StrKey
except ImportError:
pytest.skip("stellar_sdk not installed", allow_module_level=True)
from trezorlib import messages, stellar from trezorlib import messages, stellar
@ -140,8 +144,7 @@ def test_multiple_operations():
operation2_source = "GBHWKBPP3O4H2BUUKSFXE4PK5WHLQYVZIZUNUJ4AU5VUZZEVBDMXISAS" operation2_source = "GBHWKBPP3O4H2BUUKSFXE4PK5WHLQYVZIZUNUJ4AU5VUZZEVBDMXISAS"
envelope = ( envelope = (
tx tx.append_manage_data_op(
.append_manage_data_op(
data_name=data_name, data_value=data_value, source=operation1_source data_name=data_name, data_value=data_value, source=operation1_source
) )
.append_payment_op( .append_payment_op(
@ -186,15 +189,11 @@ def test_create_account():
starting_balance = "100.0333" starting_balance = "100.0333"
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_create_account_op(
tx destination=destination,
.append_create_account_op( starting_balance=starting_balance,
destination=destination, source=operation_source,
starting_balance=starting_balance, ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -212,17 +211,13 @@ def test_payment_native_asset():
asset_issuer = None asset_issuer = None
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_payment_op(
tx destination=destination,
.append_payment_op( amount=amount,
destination=destination, asset_code=asset_code,
amount=amount, asset_issuer=asset_issuer,
asset_code=asset_code, source=operation_source,
asset_issuer=asset_issuer, ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -243,17 +238,13 @@ def test_payment_alpha4_asset():
asset_issuer = "GCSJ7MFIIGIRMAS4R3VT5FIFIAOXNMGDI5HPYTWS5X7HH74FSJ6STSGF" asset_issuer = "GCSJ7MFIIGIRMAS4R3VT5FIFIAOXNMGDI5HPYTWS5X7HH74FSJ6STSGF"
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_payment_op(
tx destination=destination,
.append_payment_op( amount=amount,
destination=destination, asset_code=asset_code,
amount=amount, asset_issuer=asset_issuer,
asset_code=asset_code, source=operation_source,
asset_issuer=asset_issuer, ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -274,17 +265,13 @@ def test_payment_alpha12_asset():
asset_issuer = "GCSJ7MFIIGIRMAS4R3VT5FIFIAOXNMGDI5HPYTWS5X7HH74FSJ6STSGF" asset_issuer = "GCSJ7MFIIGIRMAS4R3VT5FIFIAOXNMGDI5HPYTWS5X7HH74FSJ6STSGF"
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_payment_op(
tx destination=destination,
.append_payment_op( amount=amount,
destination=destination, asset_code=asset_code,
amount=amount, asset_issuer=asset_issuer,
asset_code=asset_code, source=operation_source,
asset_issuer=asset_issuer, ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -314,21 +301,17 @@ def test_path_payment_strict_receive():
"BANANA", "GC7EKO37HNSKQ3V6RZ274EO7SFOWASQRHLX3OR5FIZK6UMV6LIEDXHGZ" "BANANA", "GC7EKO37HNSKQ3V6RZ274EO7SFOWASQRHLX3OR5FIZK6UMV6LIEDXHGZ"
) )
envelope = ( envelope = tx.append_path_payment_strict_receive_op(
tx destination=destination,
.append_path_payment_strict_receive_op( send_code=send_code,
destination=destination, send_issuer=send_issuer,
send_code=send_code, send_max=send_max,
send_issuer=send_issuer, dest_code=dest_code,
send_max=send_max, dest_issuer=dest_issuer,
dest_code=dest_code, dest_amount=dest_amount,
dest_issuer=dest_issuer, path=[path_asset1, path_asset2],
dest_amount=dest_amount, source=operation_source,
path=[path_asset1, path_asset2], ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -361,19 +344,15 @@ def test_manage_sell_offer_new_offer():
buying_issuer = "GCSJ7MFIIGIRMAS4R3VT5FIFIAOXNMGDI5HPYTWS5X7HH74FSJ6STSGF" buying_issuer = "GCSJ7MFIIGIRMAS4R3VT5FIFIAOXNMGDI5HPYTWS5X7HH74FSJ6STSGF"
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_manage_sell_offer_op(
tx selling_code=selling_code,
.append_manage_sell_offer_op( selling_issuer=selling_issuer,
selling_code=selling_code, buying_code=buying_code,
selling_issuer=selling_issuer, buying_issuer=buying_issuer,
buying_code=buying_code, amount=amount,
buying_issuer=buying_issuer, price=price,
amount=amount, source=operation_source,
price=price, ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -400,20 +379,16 @@ def test_manage_sell_offer_update_offer():
offer_id = 12345 offer_id = 12345
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_manage_sell_offer_op(
tx selling_code=selling_code,
.append_manage_sell_offer_op( selling_issuer=selling_issuer,
selling_code=selling_code, buying_code=buying_code,
selling_issuer=selling_issuer, buying_issuer=buying_issuer,
buying_code=buying_code, amount=amount,
buying_issuer=buying_issuer, price=price,
amount=amount, offer_id=offer_id,
price=price, source=operation_source,
offer_id=offer_id, ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -439,19 +414,15 @@ def test_create_passive_sell_offer():
buying_issuer = "GCSJ7MFIIGIRMAS4R3VT5FIFIAOXNMGDI5HPYTWS5X7HH74FSJ6STSGF" buying_issuer = "GCSJ7MFIIGIRMAS4R3VT5FIFIAOXNMGDI5HPYTWS5X7HH74FSJ6STSGF"
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_create_passive_sell_offer_op(
tx selling_code=selling_code,
.append_create_passive_sell_offer_op( selling_issuer=selling_issuer,
selling_code=selling_code, buying_code=buying_code,
selling_issuer=selling_issuer, buying_issuer=buying_issuer,
buying_code=buying_code, amount=amount,
buying_issuer=buying_issuer, price=price,
amount=amount, source=operation_source,
price=price, ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -478,21 +449,17 @@ def test_set_options():
high_threshold = 30 high_threshold = 30
home_domain = "example.com" home_domain = "example.com"
envelope = ( envelope = tx.append_set_options_op(
tx inflation_dest=inflation_dest,
.append_set_options_op( clear_flags=clear_flags,
inflation_dest=inflation_dest, set_flags=set_flags,
clear_flags=clear_flags, master_weight=master_weight,
set_flags=set_flags, low_threshold=low_threshold,
master_weight=master_weight, med_threshold=med_threshold,
low_threshold=low_threshold, high_threshold=high_threshold,
med_threshold=med_threshold, home_domain=home_domain,
high_threshold=high_threshold, source=operation_source,
home_domain=home_domain, ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -517,13 +484,9 @@ def test_set_options_ed25519_signer():
weight = 10 weight = 10
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_ed25519_public_key_signer(
tx account_id=signer, weight=weight, source=operation_source
.append_ed25519_public_key_signer( ).build()
account_id=signer, weight=weight, source=operation_source
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -550,13 +513,9 @@ def test_set_options_pre_auth_tx_signer():
weight = 30 weight = 30
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_pre_auth_tx_signer(
tx pre_auth_tx_hash=signer, weight=weight, source=operation_source
.append_pre_auth_tx_signer( ).build()
pre_auth_tx_hash=signer, weight=weight, source=operation_source
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -574,11 +533,9 @@ def test_set_options_hashx_signer():
weight = 20 weight = 20
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_hashx_signer(
tx sha256_hash=signer, weight=weight, source=operation_source
.append_hashx_signer(sha256_hash=signer, weight=weight, source=operation_source) ).build()
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -595,16 +552,12 @@ def test_change_trust():
limit = "1000" limit = "1000"
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_change_trust_op(
tx asset_code=asset_code,
.append_change_trust_op( asset_issuer=asset_issuer,
asset_code=asset_code, limit=limit,
asset_issuer=asset_issuer, source=operation_source,
limit=limit, ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -622,16 +575,12 @@ def test_allow_trust():
trustor = "GCSJ7MFIIGIRMAS4R3VT5FIFIAOXNMGDI5HPYTWS5X7HH74FSJ6STSGF" trustor = "GCSJ7MFIIGIRMAS4R3VT5FIFIAOXNMGDI5HPYTWS5X7HH74FSJ6STSGF"
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_allow_trust_op(
tx trustor=trustor,
.append_allow_trust_op( asset_code=asset_code,
trustor=trustor, authorize=TrustLineEntryFlag.AUTHORIZED_FLAG,
asset_code=asset_code, source=operation_source,
authorize=TrustLineEntryFlag.AUTHORIZED_FLAG, ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -648,11 +597,9 @@ def test_account_merge():
destination = "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6" destination = "GDNSSYSCSSJ76FER5WEEXME5G4MTCUBKDRQSKOYP36KUKVDB2VCMERS6"
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_account_merge_op(
tx destination=destination, source=operation_source
.append_account_merge_op(destination=destination, source=operation_source) ).build()
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -667,13 +614,9 @@ def test_manage_data():
data_value = b"Hello, Stellar" data_value = b"Hello, Stellar"
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_manage_data_op(
tx data_name=data_name, data_value=data_value, source=operation_source
.append_manage_data_op( ).build()
data_name=data_name, data_value=data_value, source=operation_source
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -689,13 +632,9 @@ def test_manage_data_remove_data_entity():
data_value = None # remove data entity data_value = None # remove data entity
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_manage_data_op(
tx data_name=data_name, data_value=data_value, source=operation_source
.append_manage_data_op( ).build()
data_name=data_name, data_value=data_value, source=operation_source
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -710,11 +649,9 @@ def test_bump_sequence():
bump_to = 143487250972278900 bump_to = 143487250972278900
operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V" operation_source = "GAEB4MRKRCONK4J7MVQXAHTNDPAECUCCCNE7YC5CKM34U3OJ673A4D6V"
envelope = ( envelope = tx.append_bump_sequence_op(
tx bump_to=bump_to, source=operation_source
.append_bump_sequence_op(bump_to=bump_to, source=operation_source) ).build()
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1
@ -810,21 +747,17 @@ def test_path_payment_strict_send():
"BANANA", "GC7EKO37HNSKQ3V6RZ274EO7SFOWASQRHLX3OR5FIZK6UMV6LIEDXHGZ" "BANANA", "GC7EKO37HNSKQ3V6RZ274EO7SFOWASQRHLX3OR5FIZK6UMV6LIEDXHGZ"
) )
envelope = ( envelope = tx.append_path_payment_strict_send_op(
tx destination=destination,
.append_path_payment_strict_send_op( send_code=send_code,
destination=destination, send_issuer=send_issuer,
send_code=send_code, send_amount=send_amount,
send_issuer=send_issuer, dest_code=dest_code,
send_amount=send_amount, dest_issuer=dest_issuer,
dest_code=dest_code, dest_min=dest_min,
dest_issuer=dest_issuer, path=[path_asset1, path_asset2],
dest_min=dest_min, source=operation_source,
path=[path_asset1, path_asset2], ).build()
source=operation_source,
)
.build()
)
tx, operations = stellar.from_envelope(envelope) tx, operations = stellar.from_envelope(envelope)
assert len(operations) == 1 assert len(operations) == 1

@ -6,20 +6,15 @@
# as building that from source takes a very long time) # as building that from source takes a very long time)
[tox] [tox]
envlist = envlist = py{36,37,38,39,310}-{minimal,default,full}
py36,
py37,
py38,
py39,
py310
[testenv] [testenv]
deps = deps =
-rrequirements.txt -rrequirements.txt
-rrequirements-optional.txt !minimal: pytest>=3.6
pytest>=3.6 !minimal: pytest-random-order
pytest-random-order !minimal: importlib-metadata!=0.21
importlib-metadata!=0.21 full: -rrequirements-optional.txt
commands = commands =
# Generate local files # Generate local files
python setup.py build python setup.py build
@ -28,4 +23,4 @@ commands =
# Smoke-test trezorctl # Smoke-test trezorctl
trezorctl --help trezorctl --help
# Run test suite # Run test suite
pytest --random-order tests !minimal: pytest --random-order tests

Loading…
Cancel
Save