diff --git a/docs/api.md b/docs/api.md index f868eda..d9de8d1 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1,14 +1,31 @@ # API Reference -```{autodoc2-summary} -:renderer: myst +## Contexts +```{autodoc2-summary} algopy_testing.AlgopyTestContext algopy_testing.LedgerContext algopy_testing.TransactionContext +``` + +## Value Generators + +```{autodoc2-summary} algopy_testing.AVMValueGenerator -algopy_testing.TxnValueGenerator algopy_testing.ARC4ValueGenerator +algopy_testing.TxnValueGenerator ``` -> TODO: 1.0 Restructure algopy_testing index file once refactoring changes are merged +## Inner transaction loaders + +```{autodoc2-summary} +algopy_testing.ITxnGroupLoader +algopy_testing.ITxnLoader +``` + +## Utils + +```{autodoc2-summary} +algopy_testing.algopy_testing_context +algopy_testing.arc4_prefix +``` diff --git a/docs/conf.py b/docs/conf.py index 47c6fe8..4c5a349 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -61,7 +61,11 @@ autodoc2_packages = [ { "path": "../src/algopy_testing", - "auto_mode": False, + "auto_mode": True, + }, + { + "path": "../src/_algopy_testing", + "auto_mode": True, }, ] autodoc2_render_plugin = "myst" diff --git a/docs/coverage.md b/docs/coverage.md index 8fc6e91..cba191f 100644 --- a/docs/coverage.md +++ b/docs/coverage.md @@ -1,8 +1,6 @@ # Coverage -See which `algorand-python` stubs are implemented by the `algorand-python-testing` library. See the [Concepts](testing-guide/concepts.md#types-of-algopy-stub-implementations) section for more details on the implementation categories. - -Based on the definitions provided and the implementation details in the `src` directory, here is the classification for the abstractions outlined in the table under the `Name` column: +See which `algorand-python` stubs are implemented by the `algorand-python-testing` library. See the [Concepts](testing-guide/concepts.md#types-of-algopy-stub-implementations) section for more details on the implementation categories. Refer to the [`algorand-python` stubs API](api.md) for the full list of the stubs for which the `algorand-python-testing` library provides implementations referenced in the table below. | Name | Implementation type | | ------------------------------------------- | ------------------- | @@ -159,4 +157,3 @@ Based on the definitions provided and the implementation details in the `src` di | algopy.op.EllipticCurve | Mockable | | algopy.op.VrfVerify | Mockable | | algopy.op.vrf_verify | Mockable | - diff --git a/examples/zk_whitelist/test_contract.py b/examples/zk_whitelist/test_contract.py index 91a12fd..1bd5b5b 100644 --- a/examples/zk_whitelist/test_contract.py +++ b/examples/zk_whitelist/test_contract.py @@ -3,8 +3,7 @@ import algopy import pytest -from algopy_testing import AlgopyTestContext, algopy_testing_context -from algopy_testing.utils import arc4_prefix +from algopy_testing import AlgopyTestContext, algopy_testing_context, arc4_prefix from .contract import ZkWhitelistContract diff --git a/src/_algopy_testing/__init__.py b/src/_algopy_testing/__init__.py new file mode 100644 index 0000000..fe88f22 --- /dev/null +++ b/src/_algopy_testing/__init__.py @@ -0,0 +1,68 @@ +from _algopy_testing import arc4, gtxn, itxn +from _algopy_testing._context_helpers.context_storage import algopy_testing_context +from _algopy_testing._context_helpers.ledger_context import LedgerContext +from _algopy_testing._context_helpers.txn_context import TransactionContext +from _algopy_testing._itxn_loader import ITxnGroupLoader, ITxnLoader +from _algopy_testing._value_generators.arc4 import ARC4ValueGenerator +from _algopy_testing._value_generators.avm import AVMValueGenerator +from _algopy_testing._value_generators.txn import TxnValueGenerator +from _algopy_testing.context import AlgopyTestContext +from _algopy_testing.decorators.subroutine import subroutine +from _algopy_testing.enums import OnCompleteAction, TransactionType +from _algopy_testing.models import ( + Account, + Application, + ARC4Contract, + Asset, + Contract, + LogicSig, + StateTotals, + TemplateVar, + logicsig, + uenumerate, + urange, +) +from _algopy_testing.primitives import BigUInt, Bytes, String, UInt64 +from _algopy_testing.state import Box, BoxMap, BoxRef, GlobalState, LocalState + +# TODO: clean up and ensure only algopy_testing namespace specific user facing abstractions +# are exposed Only keep the _value_generators, ledger_context, txn_context, +# context, and arc4_prexif from utils (make utils private) +__all__ = [ + "ARC4Contract", + "ARC4ValueGenerator", + "Account", + "AlgopyTestContext", + "Application", + "Asset", + "BigUInt", + "Box", + "BoxMap", + "BoxRef", + "Bytes", + "Contract", + "GlobalState", + "LocalState", + "LogicSig", + "ITxnLoader", + "TxnValueGenerator", + "ITxnGroupLoader", + "OnCompleteAction", + "StateTotals", + "String", + "TemplateVar", + "LedgerContext", + "TransactionContext", + "AVMValueGenerator", + "TxnValueGenerator", + "TransactionType", + "UInt64", + "algopy_testing_context", + "arc4", + "gtxn", + "itxn", + "logicsig", + "subroutine", + "uenumerate", + "urange", +] diff --git a/src/algopy_testing/_compiled.py b/src/_algopy_testing/_compiled.py similarity index 95% rename from src/algopy_testing/_compiled.py rename to src/_algopy_testing/_compiled.py index 1d5e532..3be3061 100644 --- a/src/algopy_testing/_compiled.py +++ b/src/_algopy_testing/_compiled.py @@ -4,7 +4,7 @@ import dataclasses import typing -from algopy_testing.utils import raise_mocked_function_error +from _algopy_testing.utils import raise_mocked_function_error if typing.TYPE_CHECKING: from collections.abc import Mapping diff --git a/src/_algopy_testing/_context_helpers/__init__.py b/src/_algopy_testing/_context_helpers/__init__.py new file mode 100644 index 0000000..aa47297 --- /dev/null +++ b/src/_algopy_testing/_context_helpers/__init__.py @@ -0,0 +1,13 @@ +from _algopy_testing._context_helpers.context_storage import ( + algopy_testing_context, + lazy_context, +) +from _algopy_testing._context_helpers.ledger_context import LedgerContext +from _algopy_testing._context_helpers.txn_context import TransactionContext + +__all__ = [ + "LedgerContext", + "TransactionContext", + "algopy_testing_context", + "lazy_context", +] diff --git a/src/algopy_testing/_context_helpers/context_storage.py b/src/_algopy_testing/_context_helpers/context_storage.py similarity index 80% rename from src/algopy_testing/_context_helpers/context_storage.py rename to src/_algopy_testing/_context_helpers/context_storage.py index 992ba53..9cbdc88 100644 --- a/src/algopy_testing/_context_helpers/context_storage.py +++ b/src/_algopy_testing/_context_helpers/context_storage.py @@ -9,13 +9,13 @@ import algopy - from algopy_testing._context_helpers.ledger_context import LedgerContext - from algopy_testing._context_helpers.txn_context import TransactionContext, TransactionGroup - from algopy_testing._value_generators import AlgopyValueGenerator - from algopy_testing.context import AlgopyTestContext - from algopy_testing.models.account import AccountContextData - from algopy_testing.models.application import ApplicationContextData - from algopy_testing.models.asset import AssetFields + from _algopy_testing._context_helpers.ledger_context import LedgerContext + from _algopy_testing._context_helpers.txn_context import TransactionContext, TransactionGroup + from _algopy_testing._value_generators import AlgopyValueGenerator + from _algopy_testing.context import AlgopyTestContext + from _algopy_testing.models.account import AccountContextData + from _algopy_testing.models.application import ApplicationContextData + from _algopy_testing.models.asset import AssetFields _var: ContextVar[AlgopyTestContext] = ContextVar("_var") @@ -97,7 +97,12 @@ def algopy_testing_context( *, default_sender: str | None = None, ) -> Generator[AlgopyTestContext, None, None]: - from algopy_testing.context import AlgopyTestContext + """Context manager for the AlgopyTestContext. + + Args: + default_sender: The default sender for the context. + """ + from _algopy_testing.context import AlgopyTestContext token = _var.set( AlgopyTestContext( diff --git a/src/algopy_testing/_context_helpers/ledger_context.py b/src/_algopy_testing/_context_helpers/ledger_context.py similarity index 94% rename from src/algopy_testing/_context_helpers/ledger_context.py rename to src/_algopy_testing/_context_helpers/ledger_context.py index 3e5828f..ba1e61b 100644 --- a/src/algopy_testing/_context_helpers/ledger_context.py +++ b/src/_algopy_testing/_context_helpers/ledger_context.py @@ -3,25 +3,25 @@ import typing from collections import defaultdict -from algopy_testing.constants import MAX_BOX_SIZE -from algopy_testing.models.account import Account -from algopy_testing.primitives.uint64 import UInt64 -from algopy_testing.utils import as_bytes, assert_address_is_valid, get_default_global_fields +from _algopy_testing.constants import MAX_BOX_SIZE +from _algopy_testing.models.account import Account +from _algopy_testing.primitives.uint64 import UInt64 +from _algopy_testing.utils import as_bytes, assert_address_is_valid, get_default_global_fields if typing.TYPE_CHECKING: import algopy - from algopy_testing.models.account import AccountFields - from algopy_testing.models.application import ApplicationContextData, ApplicationFields - from algopy_testing.models.asset import AssetFields - from algopy_testing.op.global_values import GlobalFields + from _algopy_testing.models.account import AccountFields + from _algopy_testing.models.application import ApplicationContextData, ApplicationFields + from _algopy_testing.models.asset import AssetFields + from _algopy_testing.op.global_values import GlobalFields class LedgerContext: """Context for managing the ledger state.""" def __init__(self) -> None: - from algopy_testing.models.account import AccountContextData, get_empty_account + from _algopy_testing.models.account import AccountContextData, get_empty_account self.account_data = defaultdict[str, AccountContextData](get_empty_account) self.app_data: dict[int, ApplicationContextData] = {} @@ -374,7 +374,7 @@ def patch_global_fields(self, **global_fields: typing.Unpack[GlobalFields]) -> N Raises: AttributeError: If invalid fields are provided. """ - from algopy_testing.op.global_values import GlobalFields + from _algopy_testing.op.global_values import GlobalFields invalid_keys = global_fields.keys() - GlobalFields.__annotations__.keys() @@ -436,8 +436,8 @@ def _get_app_id(app: algopy.UInt64 | algopy.Application | algopy.Contract | int) Raises: TypeError: If an invalid type is provided. """ - from algopy_testing.models import Application, Contract - from algopy_testing.primitives import UInt64 + from _algopy_testing.models import Application, Contract + from _algopy_testing.primitives import UInt64 if isinstance(app, Contract): app_id = app.__app_id__ diff --git a/src/algopy_testing/_context_helpers/txn_context.py b/src/_algopy_testing/_context_helpers/txn_context.py similarity index 94% rename from src/algopy_testing/_context_helpers/txn_context.py rename to src/_algopy_testing/_context_helpers/txn_context.py index ce46c53..ebaf2f8 100644 --- a/src/algopy_testing/_context_helpers/txn_context.py +++ b/src/_algopy_testing/_context_helpers/txn_context.py @@ -5,30 +5,30 @@ import algosdk -from algopy_testing._itxn_loader import ITxnGroupLoader -from algopy_testing.decorators.arc4 import ( +from _algopy_testing._itxn_loader import ITxnGroupLoader +from _algopy_testing.decorators.arc4 import ( check_routing_conditions, create_abimethod_txns, create_baremethod_txns, get_arc4_metadata, get_ordered_args, ) -from algopy_testing.enums import OnCompleteAction +from _algopy_testing.enums import OnCompleteAction if typing.TYPE_CHECKING: from collections.abc import Callable, Iterator, Sequence import algopy - from algopy_testing._itxn_loader import InnerTransactionResultType - from algopy_testing.models.txn_fields import ActiveTransactionFields + from _algopy_testing._itxn_loader import InnerTransactionResultType + from _algopy_testing.models.txn_fields import ActiveTransactionFields -from algopy_testing import gtxn -from algopy_testing._itxn_loader import ITxnLoader -from algopy_testing.gtxn import TransactionBase -from algopy_testing.itxn import InnerTransaction, submit_txns -from algopy_testing.models import Application -from algopy_testing.primitives import UInt64 +from _algopy_testing import gtxn +from _algopy_testing._itxn_loader import ITxnLoader +from _algopy_testing.gtxn import TransactionBase +from _algopy_testing.itxn import InnerTransaction, submit_txns +from _algopy_testing.models import Application +from _algopy_testing.primitives import UInt64 TReturn = typing.TypeVar("TReturn") TParamSpec = typing.ParamSpec("TParamSpec") @@ -56,6 +56,8 @@ def submit(self) -> TReturn: class TransactionContext: + """Context for managing transaction groups and active transactions.""" + def __init__(self) -> None: self._groups: list[TransactionGroup] = [] self._active_group: TransactionGroup | None = None @@ -91,7 +93,7 @@ def defer_app_call( ) -> DeferredAppCall[TReturn]: r"""Prepare an application call transaction group for a contract method without executing it.""" - from algopy_testing.models import ARC4Contract + from _algopy_testing.models import ARC4Contract arc4_metadata = get_arc4_metadata(method) # unwrap instance method diff --git a/src/algopy_testing/_itxn_loader.py b/src/_algopy_testing/_itxn_loader.py similarity index 98% rename from src/algopy_testing/_itxn_loader.py rename to src/_algopy_testing/_itxn_loader.py index c0726b8..9d26f05 100644 --- a/src/algopy_testing/_itxn_loader.py +++ b/src/_algopy_testing/_itxn_loader.py @@ -2,8 +2,8 @@ import typing -from algopy_testing import itxn -from algopy_testing.enums import TransactionType +from _algopy_testing import itxn +from _algopy_testing.enums import TransactionType if typing.TYPE_CHECKING: from collections.abc import Sequence diff --git a/src/algopy_testing/_mutable.py b/src/_algopy_testing/_mutable.py similarity index 100% rename from src/algopy_testing/_mutable.py rename to src/_algopy_testing/_mutable.py diff --git a/src/algopy_testing/_value_generators/__init__.py b/src/_algopy_testing/_value_generators/__init__.py similarity index 100% rename from src/algopy_testing/_value_generators/__init__.py rename to src/_algopy_testing/_value_generators/__init__.py diff --git a/src/algopy_testing/_value_generators/arc4.py b/src/_algopy_testing/_value_generators/arc4.py similarity index 96% rename from src/algopy_testing/_value_generators/arc4.py rename to src/_algopy_testing/_value_generators/arc4.py index 9ced824..bacca57 100644 --- a/src/algopy_testing/_value_generators/arc4.py +++ b/src/_algopy_testing/_value_generators/arc4.py @@ -6,9 +6,9 @@ import algosdk -from algopy_testing import arc4 -from algopy_testing.constants import MAX_UINT8, MAX_UINT16, MAX_UINT32, MAX_UINT64, MAX_UINT512 -from algopy_testing.utils import generate_random_int +from _algopy_testing import arc4 +from _algopy_testing.constants import MAX_UINT8, MAX_UINT16, MAX_UINT32, MAX_UINT64, MAX_UINT512 +from _algopy_testing.utils import generate_random_int if typing.TYPE_CHECKING: import algopy diff --git a/src/algopy_testing/_value_generators/avm.py b/src/_algopy_testing/_value_generators/avm.py similarity index 84% rename from src/algopy_testing/_value_generators/avm.py rename to src/_algopy_testing/_value_generators/avm.py index f627479..e4f03a7 100644 --- a/src/algopy_testing/_value_generators/avm.py +++ b/src/_algopy_testing/_value_generators/avm.py @@ -7,18 +7,18 @@ import algosdk -import algopy_testing -from algopy_testing._context_helpers import lazy_context -from algopy_testing.constants import ( +import _algopy_testing +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.constants import ( ALWAYS_APPROVE_TEAL_PROGRAM, MAX_BYTES_SIZE, MAX_UINT64, MAX_UINT512, ) -from algopy_testing.models.account import AccountFields -from algopy_testing.models.application import ApplicationContextData, ApplicationFields -from algopy_testing.models.asset import AssetFields -from algopy_testing.utils import generate_random_int +from _algopy_testing.models.account import AccountFields +from _algopy_testing.models.application import ApplicationContextData, ApplicationFields +from _algopy_testing.models.asset import AssetFields +from _algopy_testing.utils import generate_random_int if typing.TYPE_CHECKING: import algopy @@ -43,7 +43,7 @@ def uint64(self, min_value: int = 0, max_value: int = MAX_UINT64) -> algopy.UInt if min_value < 0 or max_value < 0: raise ValueError("min_value and max_value must be greater than or equal to 0") - return algopy_testing.UInt64(generate_random_int(min_value, max_value)) + return _algopy_testing.UInt64(generate_random_int(min_value, max_value)) def biguint(self, min_value: int = 0) -> algopy.BigUInt: """Generate a random BigUInt value within a specified range. @@ -55,7 +55,7 @@ def biguint(self, min_value: int = 0) -> algopy.BigUInt: if min_value < 0: raise ValueError("min_value must be greater than or equal to 0") - return algopy_testing.BigUInt(generate_random_int(min_value, MAX_UINT512)) + return _algopy_testing.BigUInt(generate_random_int(min_value, MAX_UINT512)) def bytes(self, length: int | None = None) -> algopy.Bytes: """Generate a random byte sequence of a specified length. @@ -64,7 +64,7 @@ def bytes(self, length: int | None = None) -> algopy.Bytes: :returns: The randomly generated byte sequence. """ length = length or MAX_BYTES_SIZE - return algopy_testing.Bytes(secrets.token_bytes(length)) + return _algopy_testing.Bytes(secrets.token_bytes(length)) def string(self, length: int = MAX_BYTES_SIZE) -> algopy.String: """Generate a random string of a specified length. @@ -72,7 +72,7 @@ def string(self, length: int = MAX_BYTES_SIZE) -> algopy.String: :param length: int: (Default value = MAX_BYTES_SIZE) :returns: The randomly generated string. """ - return algopy_testing.String( + return _algopy_testing.String( "".join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(length)) ) @@ -146,7 +146,6 @@ def application( # type: ignore[misc] **application_fields: typing.Unpack[ApplicationFields], ) -> algopy.Application: r"""Generate and add a new application with a unique ID.""" - import algopy_testing new_app_id = id if id is not None else lazy_context.ledger.get_next_app_id() @@ -159,20 +158,20 @@ def application( # type: ignore[misc] if key not in ApplicationFields.__annotations__: raise AttributeError(f"Invalid field '{key}' for Application") - new_app = algopy_testing.Application(new_app_id) + new_app = _algopy_testing.Application(new_app_id) # Set sensible defaults app_fields: ApplicationFields = { - "approval_program": algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM), - "clear_state_program": algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM), - "global_num_uint": algopy_testing.UInt64(0), - "global_num_bytes": algopy_testing.UInt64(0), - "local_num_uint": algopy_testing.UInt64(0), - "local_num_bytes": algopy_testing.UInt64(0), - "extra_program_pages": algopy_testing.UInt64(0), + "approval_program": _algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM), + "clear_state_program": _algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM), + "global_num_uint": _algopy_testing.UInt64(0), + "global_num_bytes": _algopy_testing.UInt64(0), + "local_num_uint": _algopy_testing.UInt64(0), + "local_num_bytes": _algopy_testing.UInt64(0), + "extra_program_pages": _algopy_testing.UInt64(0), "creator": lazy_context.value.default_sender, "address": address - or algopy_testing.Account(algosdk.logic.get_application_address(new_app_id)), + or _algopy_testing.Account(algosdk.logic.get_application_address(new_app_id)), } # Merge provided fields with defaults, prioritizing provided fields diff --git a/src/algopy_testing/_value_generators/txn.py b/src/_algopy_testing/_value_generators/txn.py similarity index 94% rename from src/algopy_testing/_value_generators/txn.py rename to src/_algopy_testing/_value_generators/txn.py index f56fe1b..685a62b 100644 --- a/src/algopy_testing/_value_generators/txn.py +++ b/src/_algopy_testing/_value_generators/txn.py @@ -2,15 +2,15 @@ import typing -from algopy_testing import gtxn -from algopy_testing._context_helpers import lazy_context -from algopy_testing.models.application import Application -from algopy_testing.models.txn_fields import get_txn_defaults +from _algopy_testing import gtxn +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.models.application import Application +from _algopy_testing.models.txn_fields import get_txn_defaults if typing.TYPE_CHECKING: import algopy - from algopy_testing.models.txn_fields import ( + from _algopy_testing.models.txn_fields import ( ApplicationCallFields, AssetConfigFields, AssetFreezeFields, diff --git a/src/algopy_testing/arc4.py b/src/_algopy_testing/arc4.py similarity index 99% rename from src/algopy_testing/arc4.py rename to src/_algopy_testing/arc4.py index 828c0a9..67c043a 100644 --- a/src/algopy_testing/arc4.py +++ b/src/_algopy_testing/arc4.py @@ -8,22 +8,22 @@ import algosdk from Cryptodome.Hash import SHA512 -from algopy_testing._mutable import ( +from _algopy_testing._mutable import ( MutableBytes, add_mutable_callback, set_item_on_mutate, ) -from algopy_testing.constants import ( +from _algopy_testing.constants import ( ARC4_RETURN_PREFIX, BITS_IN_BYTE, MAX_UINT64, UINT64_SIZE, UINT512_SIZE, ) -from algopy_testing.models.account import Account -from algopy_testing.primitives import Bytes -from algopy_testing.protocols import BytesBacked -from algopy_testing.utils import ( +from _algopy_testing.models.account import Account +from _algopy_testing.primitives import Bytes +from _algopy_testing.protocols import BytesBacked +from _algopy_testing.utils import ( as_bytes, as_int, as_int16, @@ -1150,7 +1150,6 @@ class ARC4Client: class _ABICall: - def __init__(self, func_name: str) -> None: self.func_name = func_name @@ -1175,7 +1174,7 @@ def __getitem__(self, return_type: type) -> typing.Any: def emit(event: str | Struct, /, *args: object) -> None: - from algopy_testing.utilities.log import log + from _algopy_testing.utilities.log import log if isinstance(event, str): arc4_args = tuple(_cast_arg_as_arc4(arg) for arg in args) diff --git a/src/algopy_testing/constants.py b/src/_algopy_testing/constants.py similarity index 100% rename from src/algopy_testing/constants.py rename to src/_algopy_testing/constants.py diff --git a/src/algopy_testing/context.py b/src/_algopy_testing/context.py similarity index 95% rename from src/algopy_testing/context.py rename to src/_algopy_testing/context.py index 2924271..d2f32a9 100644 --- a/src/algopy_testing/context.py +++ b/src/_algopy_testing/context.py @@ -4,8 +4,8 @@ import algosdk -from algopy_testing._context_helpers import LedgerContext, TransactionContext -from algopy_testing._value_generators import AlgopyValueGenerator +from _algopy_testing._context_helpers import LedgerContext, TransactionContext +from _algopy_testing._value_generators import AlgopyValueGenerator if typing.TYPE_CHECKING: from collections.abc import Sequence diff --git a/src/_algopy_testing/decorators/__init__.py b/src/_algopy_testing/decorators/__init__.py new file mode 100644 index 0000000..e42fc38 --- /dev/null +++ b/src/_algopy_testing/decorators/__init__.py @@ -0,0 +1,8 @@ +from _algopy_testing.decorators.arc4 import abimethod, baremethod +from _algopy_testing.decorators.subroutine import subroutine + +__all__ = [ + "abimethod", + "baremethod", + "subroutine", +] diff --git a/src/algopy_testing/decorators/arc4.py b/src/_algopy_testing/decorators/arc4.py similarity index 88% rename from src/algopy_testing/decorators/arc4.py rename to src/_algopy_testing/decorators/arc4.py index d823142..4e742d2 100644 --- a/src/algopy_testing/decorators/arc4.py +++ b/src/_algopy_testing/decorators/arc4.py @@ -8,11 +8,11 @@ import algosdk -import algopy_testing -from algopy_testing._context_helpers import lazy_context -from algopy_testing.constants import ALWAYS_APPROVE_TEAL_PROGRAM -from algopy_testing.enums import OnCompleteAction -from algopy_testing.primitives import BigUInt, Bytes, String, UInt64 +import _algopy_testing +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.constants import ALWAYS_APPROVE_TEAL_PROGRAM +from _algopy_testing.enums import OnCompleteAction +from _algopy_testing.primitives import BigUInt, Bytes, String, UInt64 _P = typing.ParamSpec("_P") _R = typing.TypeVar("_R") @@ -167,7 +167,7 @@ def abimethod( # noqa: PLR0913 @functools.wraps(fn) def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R: contract, *app_args = args - assert isinstance(contract, algopy_testing.ARC4Contract), "expected ARC4 contract" + assert isinstance(contract, _algopy_testing.ARC4Contract), "expected ARC4 contract" assert fn is not None, "expected function" app_id = contract.__app_id__ @@ -224,10 +224,10 @@ def create_abimethod_txns( # at some point could get the actual values by using puya to compile the contract # this should be opt-in behaviour, as that it would be too slow to always do txn_fields.setdefault( - "approval_program_pages", [algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM)] + "approval_program_pages", [_algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM)] ) txn_fields.setdefault( - "clear_state_program_pages", [algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM)] + "clear_state_program_pages", [_algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM)] ) app_txn = lazy_context.any.txn.application_call(**txn_fields) @@ -241,10 +241,10 @@ def create_baremethod_txns(app_id: int) -> list[algopy.gtxn.TransactionBase]: txn_fields.setdefault("app_id", contract_app) txn_fields.setdefault( - "approval_program_pages", [algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM)] + "approval_program_pages", [_algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM)] ) txn_fields.setdefault( - "clear_state_program_pages", [algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM)] + "clear_state_program_pages", [_algopy_testing.Bytes(ALWAYS_APPROVE_TEAL_PROGRAM)] ) txn_fields.setdefault("sender", lazy_context.value.default_sender) return [ @@ -269,26 +269,26 @@ def _extract_arrays_from_args( app: algopy.Application, sender: algopy.Account, ) -> _TxnArrays: - txns = list[algopy_testing.gtxn.TransactionBase]() + txns = list[_algopy_testing.gtxn.TransactionBase]() apps = [app] - assets = list[algopy_testing.Asset]() + assets = list[_algopy_testing.Asset]() accounts = [sender] app_args = [method_selector] for arg in args: match arg: - case algopy_testing.gtxn.TransactionBase() as txn: + case _algopy_testing.gtxn.TransactionBase() as txn: txns.append(txn) - case algopy_testing.Account() as acc: - app_args.append(algopy_testing.arc4.UInt8(len(accounts)).bytes) + case _algopy_testing.Account() as acc: + app_args.append(_algopy_testing.arc4.UInt8(len(accounts)).bytes) accounts.append(acc) - case algopy_testing.Asset() as asset: - app_args.append(algopy_testing.arc4.UInt8(len(assets)).bytes) + case _algopy_testing.Asset() as asset: + app_args.append(_algopy_testing.arc4.UInt8(len(assets)).bytes) assets.append(asset) - case algopy_testing.Application() as arg_app: - app_args.append(algopy_testing.arc4.UInt8(len(apps)).bytes) + case _algopy_testing.Application() as arg_app: + app_args.append(_algopy_testing.arc4.UInt8(len(apps)).bytes) apps.append(arg_app) case _ as maybe_native: - app_args.append(algopy_testing.arc4.native_value_to_arc4(maybe_native).bytes) + app_args.append(_algopy_testing.arc4.native_value_to_arc4(maybe_native).bytes) if len(app_args) > 16: # TODO:1.0 pack extra args into an ARC4 tuple raise NotImplementedError @@ -313,9 +313,9 @@ def _generate_arc4_signature_from_fn(fn: typing.Callable[_P, _R], arc4_name: str def _type_to_arc4(annotation: types.GenericAlias | type | None) -> str: # noqa: PLR0911, PLR0912 - from algopy_testing.arc4 import _ABIEncoded - from algopy_testing.gtxn import Transaction, TransactionBase - from algopy_testing.models import Account, Application, Asset + from _algopy_testing.arc4 import _ABIEncoded + from _algopy_testing.gtxn import Transaction, TransactionBase + from _algopy_testing.models import Account, Application, Asset if annotation is None: return "void" @@ -408,7 +408,7 @@ def baremethod( @functools.wraps(fn) def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R: contract, *app_args = args - assert isinstance(contract, algopy_testing.ARC4Contract), "expected ARC4 contract" + assert isinstance(contract, _algopy_testing.ARC4Contract), "expected ARC4 contract" assert fn is not None, "expected function" txns = create_baremethod_txns(contract.__app_id__) diff --git a/src/algopy_testing/decorators/subroutine.py b/src/_algopy_testing/decorators/subroutine.py similarity index 100% rename from src/algopy_testing/decorators/subroutine.py rename to src/_algopy_testing/decorators/subroutine.py diff --git a/src/algopy_testing/enums.py b/src/_algopy_testing/enums.py similarity index 98% rename from src/algopy_testing/enums.py rename to src/_algopy_testing/enums.py index db7adca..6d3a554 100644 --- a/src/algopy_testing/enums.py +++ b/src/_algopy_testing/enums.py @@ -4,7 +4,7 @@ from algosdk import constants -from algopy_testing.primitives import UInt64 +from _algopy_testing.primitives import UInt64 class _EnumLike(UInt64): diff --git a/src/algopy_testing/gtxn.py b/src/_algopy_testing/gtxn.py similarity index 90% rename from src/algopy_testing/gtxn.py rename to src/_algopy_testing/gtxn.py index 1324bdf..7b51d98 100644 --- a/src/algopy_testing/gtxn.py +++ b/src/_algopy_testing/gtxn.py @@ -2,13 +2,13 @@ import typing -from algopy_testing._context_helpers import lazy_context -from algopy_testing.constants import MAX_ITEMS_IN_LOG -from algopy_testing.enums import TransactionType -from algopy_testing.models import Application -from algopy_testing.models.txn_fields import TransactionFieldsGetter, combine_into_max_byte_pages -from algopy_testing.primitives import Bytes, UInt64 -from algopy_testing.utils import convert_native_to_stack, get_new_scratch_space +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.constants import MAX_ITEMS_IN_LOG +from _algopy_testing.enums import TransactionType +from _algopy_testing.models import Application +from _algopy_testing.models.txn_fields import TransactionFieldsGetter, combine_into_max_byte_pages +from _algopy_testing.primitives import Bytes, UInt64 +from _algopy_testing.utils import convert_native_to_stack, get_new_scratch_space if typing.TYPE_CHECKING: from collections.abc import Sequence diff --git a/src/algopy_testing/itxn.py b/src/_algopy_testing/itxn.py similarity index 96% rename from src/algopy_testing/itxn.py rename to src/_algopy_testing/itxn.py index c2877b4..49336ab 100644 --- a/src/algopy_testing/itxn.py +++ b/src/_algopy_testing/itxn.py @@ -6,10 +6,10 @@ import algosdk -from algopy_testing._context_helpers import lazy_context -from algopy_testing.enums import TransactionType -from algopy_testing.models import Account, Asset -from algopy_testing.models.txn_fields import ( +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.enums import TransactionType +from _algopy_testing.models import Account, Asset +from _algopy_testing.models.txn_fields import ( TransactionFieldsGetter, get_txn_defaults, narrow_field_type, @@ -117,7 +117,7 @@ def copy(self) -> typing.Self: def _check_fields(fields: dict[str, object]) -> None: - from algopy_testing.models.txn_fields import TransactionFields + from _algopy_testing.models.txn_fields import TransactionFields invalid_fields = fields.keys() - TransactionFields.__annotations__ if invalid_fields: diff --git a/src/_algopy_testing/models/__init__.py b/src/_algopy_testing/models/__init__.py new file mode 100644 index 0000000..6a57eac --- /dev/null +++ b/src/_algopy_testing/models/__init__.py @@ -0,0 +1,21 @@ +from _algopy_testing.models.account import Account +from _algopy_testing.models.application import Application +from _algopy_testing.models.asset import Asset +from _algopy_testing.models.contract import ARC4Contract, Contract, StateTotals +from _algopy_testing.models.logicsig import LogicSig, logicsig +from _algopy_testing.models.template_variable import TemplateVar +from _algopy_testing.models.unsigned_builtins import uenumerate, urange + +__all__ = [ + "ARC4Contract", + "Account", + "Application", + "Asset", + "Contract", + "LogicSig", + "StateTotals", + "TemplateVar", + "logicsig", + "uenumerate", + "urange", +] diff --git a/src/algopy_testing/models/account.py b/src/_algopy_testing/models/account.py similarity index 92% rename from src/algopy_testing/models/account.py rename to src/_algopy_testing/models/account.py index a906e5a..f3d141d 100644 --- a/src/algopy_testing/models/account.py +++ b/src/_algopy_testing/models/account.py @@ -5,10 +5,10 @@ import algosdk -from algopy_testing.constants import DEFAULT_ACCOUNT_MIN_BALANCE -from algopy_testing.primitives import Bytes, UInt64 -from algopy_testing.protocols import BytesBacked -from algopy_testing.utils import as_bytes +from _algopy_testing.constants import DEFAULT_ACCOUNT_MIN_BALANCE +from _algopy_testing.primitives import Bytes, UInt64 +from _algopy_testing.protocols import BytesBacked +from _algopy_testing.utils import as_bytes if typing.TYPE_CHECKING: import algopy @@ -80,7 +80,7 @@ def __init__(self, value: str | Bytes = algosdk.constants.ZERO_ADDRESS, /): @property def data(self) -> AccountContextData: - from algopy_testing._context_helpers import lazy_context + from _algopy_testing._context_helpers import lazy_context return lazy_context.ledger.account_data[self.public_key] @@ -93,7 +93,7 @@ def min_balance(self) -> algopy.UInt64: return self.data.fields["min_balance"] def is_opted_in(self, asset_or_app: algopy.Asset | algopy.Application, /) -> bool: - from algopy_testing.models import Application, Asset + from _algopy_testing.models import Application, Asset if isinstance(asset_or_app, Asset): return asset_or_app.id in self.data.opted_asset_balances diff --git a/src/algopy_testing/models/application.py b/src/_algopy_testing/models/application.py similarity index 91% rename from src/algopy_testing/models/application.py rename to src/_algopy_testing/models/application.py index 97e6e5f..7e8bb74 100644 --- a/src/algopy_testing/models/application.py +++ b/src/_algopy_testing/models/application.py @@ -3,16 +3,16 @@ import inspect import typing -from algopy_testing.primitives import UInt64 -from algopy_testing.protocols import UInt64Backed -from algopy_testing.utils import as_int64 +from _algopy_testing.primitives import UInt64 +from _algopy_testing.protocols import UInt64Backed +from _algopy_testing.utils import as_int64 if typing.TYPE_CHECKING: from collections.abc import Sequence import algopy - from algopy_testing.models.contract import Contract + from _algopy_testing.models.contract import Contract class ApplicationFields(typing.TypedDict, total=False): @@ -68,7 +68,7 @@ def from_int(cls, value: int, /) -> typing.Self: @property def fields(self) -> ApplicationFields: - from algopy_testing._context_helpers import lazy_context + from _algopy_testing._context_helpers import lazy_context if self._id == 0: raise ValueError("cannot access properties of an app with an id of 0") from None diff --git a/src/algopy_testing/models/asset.py b/src/_algopy_testing/models/asset.py similarity index 95% rename from src/algopy_testing/models/asset.py rename to src/_algopy_testing/models/asset.py index 77e22ce..15107e6 100644 --- a/src/algopy_testing/models/asset.py +++ b/src/_algopy_testing/models/asset.py @@ -2,7 +2,7 @@ import typing -from algopy_testing.protocols import UInt64Backed +from _algopy_testing.protocols import UInt64Backed if typing.TYPE_CHECKING: import algopy @@ -41,7 +41,7 @@ def from_int(cls, value: int, /) -> typing.Self: return cls(value) def balance(self, account: algopy.Account) -> algopy.UInt64: - from algopy_testing._context_helpers import lazy_context + from _algopy_testing._context_helpers import lazy_context account_data = lazy_context.get_account_data(account.public_key) @@ -66,7 +66,7 @@ def frozen(self, _account: algopy.Account) -> bool: ) def __getattr__(self, name: str) -> object: - from algopy_testing._context_helpers import lazy_context + from _algopy_testing._context_helpers import lazy_context if int(self.id) not in lazy_context.ledger.asset_data: # check if its not 0 (which means its not diff --git a/src/algopy_testing/models/contract.py b/src/_algopy_testing/models/contract.py similarity index 85% rename from src/algopy_testing/models/contract.py rename to src/_algopy_testing/models/contract.py index b1e4f89..70a8aa2 100644 --- a/src/algopy_testing/models/contract.py +++ b/src/_algopy_testing/models/contract.py @@ -4,13 +4,13 @@ import typing from dataclasses import dataclass -import algopy_testing -from algopy_testing._context_helpers import lazy_context -from algopy_testing._mutable import set_attr_on_mutate -from algopy_testing.decorators.arc4 import maybe_arc4_metadata -from algopy_testing.primitives import Bytes, UInt64 -from algopy_testing.protocols import BytesBacked, UInt64Backed -from algopy_testing.state.utils import deserialize, serialize +import _algopy_testing +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing._mutable import set_attr_on_mutate +from _algopy_testing.decorators.arc4 import maybe_arc4_metadata +from _algopy_testing.primitives import Bytes, UInt64 +from _algopy_testing.protocols import BytesBacked, UInt64Backed +from _algopy_testing.state.utils import deserialize, serialize if typing.TYPE_CHECKING: import algopy @@ -60,10 +60,10 @@ def __call__(cls, *args: typing.Any, **kwargs: dict[str, typing.Any]) -> object: state_totals = _get_state_totals(instance, cls_state_totals) context.ledger.update_app( app_id, - global_num_bytes=algopy_testing.UInt64(state_totals.global_bytes), - global_num_uint=algopy_testing.UInt64(state_totals.global_uints), - local_num_bytes=algopy_testing.UInt64(state_totals.local_bytes), - local_num_uint=algopy_testing.UInt64(state_totals.local_uints), + global_num_bytes=_algopy_testing.UInt64(state_totals.global_bytes), + global_num_uint=_algopy_testing.UInt64(state_totals.global_uints), + local_num_bytes=_algopy_testing.UInt64(state_totals.local_bytes), + local_num_uint=_algopy_testing.UInt64(state_totals.local_uints), creator=txn.sender, ) @@ -150,19 +150,19 @@ def set_is_creating(*args: typing.Any, **kwargs: dict[str, typing.Any]) -> typin return set_attr_on_mutate(self, name, value) def __setattr__(self, name: str, value: typing.Any) -> None: - name_bytes = algopy_testing.String(name).bytes + name_bytes = _algopy_testing.String(name).bytes match value: - case (algopy_testing.Box() | algopy_testing.BoxRef()) as box if not box._key: + case (_algopy_testing.Box() | _algopy_testing.BoxRef()) as box if not box._key: box._key = name_bytes - case algopy_testing.GlobalState() as state: + case _algopy_testing.GlobalState() as state: state.app_id = _get_self_or_active_app_id(self) if not state._key: state.set_key(name_bytes) - case algopy_testing.LocalState() as state: + case _algopy_testing.LocalState() as state: state.app_id = _get_self_or_active_app_id(self) if not state._key: state._key = name_bytes - case algopy_testing.BoxMap() as box_map if box_map._key_prefix is None: + case _algopy_testing.BoxMap() as box_map if box_map._key_prefix is None: box_map._key_prefix = name_bytes case Bytes() | UInt64() | BytesBacked() | UInt64Backed() | bool(): app_id = _get_self_or_active_app_id(self) @@ -195,8 +195,8 @@ def clear_state_program(self) -> algopy.UInt64 | bool: def _get_state_totals(contract: Contract, cls_state_totals: StateTotals) -> _StateTotals: - from algopy_testing.primitives import UInt64 - from algopy_testing.protocols import UInt64Backed + from _algopy_testing.primitives import UInt64 + from _algopy_testing.protocols import UInt64Backed global_bytes = global_uints = local_bytes = local_uints = 0 for type_ in get_global_states(contract).values(): @@ -240,7 +240,7 @@ def get_local_states(contract: Contract) -> dict[bytes, type]: local_states = { attribute._key.value: attribute.type_ for _, attribute in vars(contract).items() - if isinstance(attribute, algopy_testing.LocalState) + if isinstance(attribute, _algopy_testing.LocalState) } return local_states @@ -251,13 +251,13 @@ def get_global_states(contract: Contract) -> dict[bytes, type]: for key, attribute in vars(contract).items(): if isinstance( attribute, - algopy_testing.LocalState - | algopy_testing.Box - | algopy_testing.BoxMap - | algopy_testing.BoxRef, + _algopy_testing.LocalState + | _algopy_testing.Box + | _algopy_testing.BoxMap + | _algopy_testing.BoxRef, ) or callable(attribute): continue - if isinstance(attribute, algopy_testing.GlobalState): + if isinstance(attribute, _algopy_testing.GlobalState): global_states[attribute.key.value] = attribute.type_ elif isinstance(attribute, UInt64Backed | BytesBacked | UInt64 | Bytes | bool): global_states[key.encode()] = type(attribute) diff --git a/src/algopy_testing/models/logicsig.py b/src/_algopy_testing/models/logicsig.py similarity index 100% rename from src/algopy_testing/models/logicsig.py rename to src/_algopy_testing/models/logicsig.py diff --git a/src/algopy_testing/models/template_variable.py b/src/_algopy_testing/models/template_variable.py similarity index 90% rename from src/algopy_testing/models/template_variable.py rename to src/_algopy_testing/models/template_variable.py index 770ef18..f3d681c 100644 --- a/src/algopy_testing/models/template_variable.py +++ b/src/_algopy_testing/models/template_variable.py @@ -2,7 +2,7 @@ import typing -from algopy_testing._context_helpers.context_storage import lazy_context +from _algopy_testing._context_helpers.context_storage import lazy_context _T = typing.TypeVar("_T") diff --git a/src/algopy_testing/models/txn_fields.py b/src/_algopy_testing/models/txn_fields.py similarity index 96% rename from src/algopy_testing/models/txn_fields.py rename to src/_algopy_testing/models/txn_fields.py index 5a0f0c5..721f8e8 100644 --- a/src/algopy_testing/models/txn_fields.py +++ b/src/_algopy_testing/models/txn_fields.py @@ -3,12 +3,12 @@ import abc import typing -from algopy_testing._context_helpers import lazy_context -from algopy_testing.constants import MAX_BYTES_SIZE -from algopy_testing.enums import OnCompleteAction, TransactionType -from algopy_testing.models import Account, Application, Asset -from algopy_testing.primitives import Bytes, String, UInt64 -from algopy_testing.utils import generate_random_bytes32 +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.constants import MAX_BYTES_SIZE +from _algopy_testing.enums import OnCompleteAction, TransactionType +from _algopy_testing.models import Account, Application, Asset +from _algopy_testing.primitives import Bytes, String, UInt64 +from _algopy_testing.utils import generate_random_bytes32 if typing.TYPE_CHECKING: from collections.abc import Callable, Mapping, Sequence @@ -426,8 +426,8 @@ def _as_bytes(value: typing.Any) -> Bytes: def _as_bytes_allow_bytes_backed(value: typing.Any) -> Bytes: - from algopy_testing.arc4 import Struct - from algopy_testing.protocols import BytesBacked + from _algopy_testing.arc4 import Struct + from _algopy_testing.protocols import BytesBacked match value: case BytesBacked() as bb: diff --git a/src/algopy_testing/models/unsigned_builtins.py b/src/_algopy_testing/models/unsigned_builtins.py similarity index 94% rename from src/algopy_testing/models/unsigned_builtins.py rename to src/_algopy_testing/models/unsigned_builtins.py index 910dbbb..cbe57b2 100644 --- a/src/algopy_testing/models/unsigned_builtins.py +++ b/src/_algopy_testing/models/unsigned_builtins.py @@ -2,7 +2,7 @@ import typing -from algopy_testing.utils import as_int64 +from _algopy_testing.utils import as_int64 if typing.TYPE_CHECKING: from collections.abc import Iterable, Iterator, Reversible diff --git a/src/algopy_testing/op/__init__.py b/src/_algopy_testing/op/__init__.py similarity index 86% rename from src/algopy_testing/op/__init__.py rename to src/_algopy_testing/op/__init__.py index 98aef43..e8ad9f7 100644 --- a/src/algopy_testing/op/__init__.py +++ b/src/_algopy_testing/op/__init__.py @@ -1,5 +1,5 @@ -from algopy_testing.op.block import Block -from algopy_testing.op.crypto import ( +from _algopy_testing.op.block import Block +from _algopy_testing.op.crypto import ( EC, ECDSA, EllipticCurve, @@ -15,9 +15,9 @@ sha512_256, vrf_verify, ) -from algopy_testing.op.global_values import Global -from algopy_testing.op.itxn import GITxn, ITxn, ITxnCreate -from algopy_testing.op.misc import ( +from _algopy_testing.op.global_values import Global +from _algopy_testing.op.itxn import GITxn, ITxn, ITxnCreate +from _algopy_testing.op.misc import ( AcctParamsGet, AppGlobal, AppLocal, @@ -36,7 +36,7 @@ gload_uint64, min_balance, ) -from algopy_testing.op.pure import ( +from _algopy_testing.op.pure import ( Base64, JsonRef, addw, @@ -69,7 +69,7 @@ sqrt, substring, ) -from algopy_testing.op.txn import GTxn, Txn +from _algopy_testing.op.txn import GTxn, Txn __all__ = [ "AcctParamsGet", diff --git a/src/algopy_testing/op/block.py b/src/_algopy_testing/op/block.py similarity index 83% rename from src/algopy_testing/op/block.py rename to src/_algopy_testing/op/block.py index 96662e8..8e5c1dc 100644 --- a/src/algopy_testing/op/block.py +++ b/src/_algopy_testing/op/block.py @@ -2,9 +2,9 @@ from typing import TYPE_CHECKING -from algopy_testing import op -from algopy_testing._context_helpers import lazy_context -from algopy_testing.primitives import UInt64 +from _algopy_testing import op +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.primitives import UInt64 if TYPE_CHECKING: import algopy diff --git a/src/algopy_testing/op/constants.py b/src/_algopy_testing/op/constants.py similarity index 100% rename from src/algopy_testing/op/constants.py rename to src/_algopy_testing/op/constants.py diff --git a/src/algopy_testing/op/crypto.py b/src/_algopy_testing/op/crypto.py similarity index 94% rename from src/algopy_testing/op/crypto.py rename to src/_algopy_testing/op/crypto.py index a9d25c2..be10f45 100644 --- a/src/algopy_testing/op/crypto.py +++ b/src/_algopy_testing/op/crypto.py @@ -17,10 +17,10 @@ VerifyingKey, ) -from algopy_testing._context_helpers import lazy_context -from algopy_testing.enums import OnCompleteAction -from algopy_testing.primitives import Bytes, UInt64 -from algopy_testing.utils import as_bytes, raise_mocked_function_error +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.enums import OnCompleteAction +from _algopy_testing.primitives import Bytes, UInt64 +from _algopy_testing.utils import as_bytes, raise_mocked_function_error class ECDSA(enum.Enum): @@ -67,7 +67,7 @@ def ed25519verify_bare(a: Bytes | bytes, b: Bytes | bytes, c: Bytes | bytes, /) def ed25519verify(a: Bytes | bytes, b: Bytes | bytes, c: Bytes | bytes, /) -> bool: - from algopy_testing.utils import as_bytes + from _algopy_testing.utils import as_bytes txn = lazy_context.active_group.active_txn diff --git a/src/algopy_testing/op/global_values.py b/src/_algopy_testing/op/global_values.py similarity index 94% rename from src/algopy_testing/op/global_values.py rename to src/_algopy_testing/op/global_values.py index e7516b0..9443212 100644 --- a/src/algopy_testing/op/global_values.py +++ b/src/_algopy_testing/op/global_values.py @@ -6,9 +6,9 @@ import algosdk -from algopy_testing._context_helpers import lazy_context -from algopy_testing.models import Account -from algopy_testing.primitives import UInt64 +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.models import Account +from _algopy_testing.primitives import UInt64 if typing.TYPE_CHECKING: from collections.abc import Callable diff --git a/src/algopy_testing/op/itxn.py b/src/_algopy_testing/op/itxn.py similarity index 96% rename from src/algopy_testing/op/itxn.py rename to src/_algopy_testing/op/itxn.py index 9811142..14d9312 100644 --- a/src/algopy_testing/op/itxn.py +++ b/src/_algopy_testing/op/itxn.py @@ -2,8 +2,8 @@ import typing from collections.abc import Callable, Sequence -from algopy_testing._context_helpers import lazy_context -from algopy_testing.op.constants import OP_MEMBER_TO_TXN_MEMBER +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.op.constants import OP_MEMBER_TO_TXN_MEMBER class _ITxn: diff --git a/src/algopy_testing/op/misc.py b/src/_algopy_testing/op/misc.py similarity index 97% rename from src/algopy_testing/op/misc.py rename to src/_algopy_testing/op/misc.py index 1e85eaf..96374eb 100644 --- a/src/algopy_testing/op/misc.py +++ b/src/_algopy_testing/op/misc.py @@ -2,15 +2,15 @@ import typing -from algopy_testing._context_helpers import lazy_context -from algopy_testing.constants import ( +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.constants import ( MAX_BOX_SIZE, ) -from algopy_testing.enums import TransactionType -from algopy_testing.models import Account, Application, Asset -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.primitives.uint64 import UInt64 -from algopy_testing.utils import raise_mocked_function_error +from _algopy_testing.enums import TransactionType +from _algopy_testing.models import Account, Application, Asset +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.primitives.uint64 import UInt64 +from _algopy_testing.utils import raise_mocked_function_error if typing.TYPE_CHECKING: import algopy diff --git a/src/algopy_testing/op/pure.py b/src/_algopy_testing/op/pure.py similarity index 98% rename from src/algopy_testing/op/pure.py rename to src/_algopy_testing/op/pure.py index 5a41aba..11c9ae1 100644 --- a/src/algopy_testing/op/pure.py +++ b/src/_algopy_testing/op/pure.py @@ -6,9 +6,9 @@ import math import typing -from algopy_testing import BigUInt, Bytes, UInt64 -from algopy_testing.constants import BITS_IN_BYTE, MAX_BYTES_SIZE, MAX_UINT64 -from algopy_testing.utils import as_bytes, as_int, as_int8, as_int64, as_int512, int_to_bytes +from _algopy_testing import BigUInt, Bytes, UInt64 +from _algopy_testing.constants import BITS_IN_BYTE, MAX_BYTES_SIZE, MAX_UINT64 +from _algopy_testing.utils import as_bytes, as_int, as_int8, as_int64, as_int512, int_to_bytes def addw(a: UInt64 | int, b: UInt64 | int, /) -> tuple[UInt64, UInt64]: diff --git a/src/algopy_testing/op/txn.py b/src/_algopy_testing/op/txn.py similarity index 93% rename from src/algopy_testing/op/txn.py rename to src/_algopy_testing/op/txn.py index 94f328c..95e72f1 100644 --- a/src/algopy_testing/op/txn.py +++ b/src/_algopy_testing/op/txn.py @@ -2,8 +2,8 @@ import typing -from algopy_testing._context_helpers import lazy_context -from algopy_testing.op.constants import OP_MEMBER_TO_TXN_MEMBER +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.op.constants import OP_MEMBER_TO_TXN_MEMBER class _Txn: diff --git a/src/_algopy_testing/primitives/__init__.py b/src/_algopy_testing/primitives/__init__.py new file mode 100644 index 0000000..ee10525 --- /dev/null +++ b/src/_algopy_testing/primitives/__init__.py @@ -0,0 +1,6 @@ +from _algopy_testing.primitives.biguint import BigUInt +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.primitives.string import String +from _algopy_testing.primitives.uint64 import UInt64 + +__all__ = ["BigUInt", "Bytes", "String", "UInt64"] diff --git a/src/algopy_testing/primitives/biguint.py b/src/_algopy_testing/primitives/biguint.py similarity index 94% rename from src/algopy_testing/primitives/biguint.py rename to src/_algopy_testing/primitives/biguint.py index e8195fa..8a62582 100644 --- a/src/algopy_testing/primitives/biguint.py +++ b/src/_algopy_testing/primitives/biguint.py @@ -2,11 +2,11 @@ import functools -from algopy_testing.constants import UINT64_BYTES_LENGTH -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.primitives.uint64 import UInt64 -from algopy_testing.protocols import BytesBacked -from algopy_testing.utils import as_bytes, as_int, as_int512, check_type, int_to_bytes +from _algopy_testing.constants import UINT64_BYTES_LENGTH +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.primitives.uint64 import UInt64 +from _algopy_testing.protocols import BytesBacked +from _algopy_testing.utils import as_bytes, as_int, as_int512, check_type, int_to_bytes # TypeError, ValueError are used for operations that are compile time errors # ArithmeticError and subclasses are used for operations that would fail during AVM execution diff --git a/src/algopy_testing/primitives/bytes.py b/src/_algopy_testing/primitives/bytes.py similarity index 97% rename from src/algopy_testing/primitives/bytes.py rename to src/_algopy_testing/primitives/bytes.py index e7e82b1..18a6822 100644 --- a/src/algopy_testing/primitives/bytes.py +++ b/src/_algopy_testing/primitives/bytes.py @@ -10,9 +10,9 @@ from itertools import zip_longest -from algopy_testing.constants import MAX_BYTES_SIZE -from algopy_testing.primitives.uint64 import UInt64 -from algopy_testing.utils import as_bytes, as_int64, check_type +from _algopy_testing.constants import MAX_BYTES_SIZE +from _algopy_testing.primitives.uint64 import UInt64 +from _algopy_testing.utils import as_bytes, as_int64, check_type # TypeError, ValueError are used for operations that are compile time errors # ArithmeticError and subclasses are used for operations that would fail during AVM execution diff --git a/src/algopy_testing/primitives/string.py b/src/_algopy_testing/primitives/string.py similarity index 92% rename from src/algopy_testing/primitives/string.py rename to src/_algopy_testing/primitives/string.py index 1ca869f..c331412 100644 --- a/src/algopy_testing/primitives/string.py +++ b/src/_algopy_testing/primitives/string.py @@ -1,8 +1,8 @@ from __future__ import annotations -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.protocols import BytesBacked -from algopy_testing.utils import as_bytes, as_string, check_type +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.protocols import BytesBacked +from _algopy_testing.utils import as_bytes, as_string, check_type class String(BytesBacked): diff --git a/src/algopy_testing/primitives/uint64.py b/src/_algopy_testing/primitives/uint64.py similarity index 98% rename from src/algopy_testing/primitives/uint64.py rename to src/_algopy_testing/primitives/uint64.py index fd41471..a19b95b 100644 --- a/src/algopy_testing/primitives/uint64.py +++ b/src/_algopy_testing/primitives/uint64.py @@ -2,8 +2,8 @@ import functools -from algopy_testing.constants import MAX_UINT64 -from algopy_testing.utils import as_int64, check_type +from _algopy_testing.constants import MAX_UINT64 +from _algopy_testing.utils import as_int64, check_type # TypeError, ValueError are used for operations that are compile time errors # ArithmeticError and subclasses are used for operations that would fail during AVM execution diff --git a/src/algopy_testing/protocols.py b/src/_algopy_testing/protocols.py similarity index 100% rename from src/algopy_testing/protocols.py rename to src/_algopy_testing/protocols.py diff --git a/src/_algopy_testing/py.typed b/src/_algopy_testing/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/src/_algopy_testing/state/__init__.py b/src/_algopy_testing/state/__init__.py new file mode 100644 index 0000000..5ec3f48 --- /dev/null +++ b/src/_algopy_testing/state/__init__.py @@ -0,0 +1,5 @@ +from _algopy_testing.state.box import Box, BoxMap, BoxRef +from _algopy_testing.state.global_state import GlobalState +from _algopy_testing.state.local_state import LocalState + +__all__ = ["GlobalState", "LocalState", "Box", "BoxRef", "BoxMap"] diff --git a/src/algopy_testing/state/box.py b/src/_algopy_testing/state/box.py similarity index 85% rename from src/algopy_testing/state/box.py rename to src/_algopy_testing/state/box.py index 5efb5cb..6547521 100644 --- a/src/algopy_testing/state/box.py +++ b/src/_algopy_testing/state/box.py @@ -2,12 +2,12 @@ import typing -import algopy_testing -from algopy_testing._context_helpers import lazy_context -from algopy_testing._mutable import set_attr_on_mutate, set_item_on_mutate -from algopy_testing.constants import MAX_BOX_SIZE -from algopy_testing.state.utils import cast_from_bytes, cast_to_bytes -from algopy_testing.utils import as_bytes, as_string +import _algopy_testing +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing._mutable import set_attr_on_mutate, set_item_on_mutate +from _algopy_testing.constants import MAX_BOX_SIZE +from _algopy_testing.state.utils import cast_from_bytes, cast_to_bytes +from _algopy_testing.utils import as_bytes, as_string _TKey = typing.TypeVar("_TKey") _TValue = typing.TypeVar("_TValue") @@ -29,9 +29,9 @@ def __init__( self._type = type_ self._key = ( - algopy_testing.String(as_string(key)).bytes - if isinstance(key, str | algopy_testing.String) - else algopy_testing.Bytes(as_bytes(key)) + _algopy_testing.String(as_string(key)).bytes + if isinstance(key, str | _algopy_testing.String) + else _algopy_testing.Bytes(as_bytes(key)) ) self.app_id = lazy_context.active_app_id @@ -74,7 +74,7 @@ def maybe(self) -> tuple[_TValue, bool]: def length(self) -> algopy.UInt64: if not lazy_context.ledger.box_exists(self.app_id, self.key): raise RuntimeError("Box has not been created") - return algopy_testing.UInt64(len(lazy_context.ledger.get_box(self.app_id, self.key))) + return _algopy_testing.UInt64(len(lazy_context.ledger.get_box(self.app_id, self.key))) class BoxRef: @@ -86,9 +86,9 @@ class BoxRef: def __init__(self, /, *, key: bytes | str | algopy.Bytes | algopy.String = "") -> None: self._key = ( - algopy_testing.String(as_string(key)).bytes - if isinstance(key, str | algopy_testing.String) - else algopy_testing.Bytes(as_bytes(key)) + _algopy_testing.String(as_string(key)).bytes + if isinstance(key, str | _algopy_testing.String) + else _algopy_testing.Bytes(as_bytes(key)) ) self.app_id = lazy_context.active_app_id @@ -129,7 +129,7 @@ def extract( if (start_int + length_int) > len(box_content): raise ValueError("Index out of bounds") result = box_content[start_int : start_int + length_int] - return algopy_testing.Bytes(result) + return _algopy_testing.Bytes(result) def resize(self, new_size: algopy.UInt64 | int) -> None: new_size_int = int(new_size) @@ -166,7 +166,7 @@ def splice( start = int(start_index) delete_count = int(length) - insert_content = value.value if isinstance(value, algopy_testing.Bytes) else value + insert_content = value.value if isinstance(value, _algopy_testing.Bytes) else value if not box_exists: raise RuntimeError("Box has not been created") @@ -187,21 +187,25 @@ def splice( def get(self, *, default: algopy.Bytes | bytes) -> algopy.Bytes: box_content, box_exists = self._maybe() default_bytes = ( - default if isinstance(default, algopy_testing.Bytes) else algopy_testing.Bytes(default) + default + if isinstance(default, _algopy_testing.Bytes) + else _algopy_testing.Bytes(default) ) - return default_bytes if not box_exists else algopy_testing.Bytes(box_content) + return default_bytes if not box_exists else _algopy_testing.Bytes(box_content) def put(self, value: algopy.Bytes | bytes) -> None: box_content, box_exists = self._maybe() if box_exists and len(box_content) != len(value): raise ValueError("Box already exists with a different size") - content = value if isinstance(value, algopy_testing.Bytes) else algopy_testing.Bytes(value) + content = ( + value if isinstance(value, _algopy_testing.Bytes) else _algopy_testing.Bytes(value) + ) lazy_context.ledger.set_box(self.app_id, self.key, content) def maybe(self) -> tuple[algopy.Bytes, bool]: box_content, box_exists = self._maybe() - return algopy_testing.Bytes(box_content), box_exists + return _algopy_testing.Bytes(box_content), box_exists def _maybe(self) -> tuple[bytes, bool]: box_exists = lazy_context.ledger.box_exists(self.app_id, self.key) @@ -213,7 +217,7 @@ def length(self) -> algopy.UInt64: box_content, box_exists = self._maybe() if not box_exists: raise RuntimeError("Box has not been created") - return algopy_testing.UInt64(len(box_content)) + return _algopy_testing.UInt64(len(box_content)) class BoxMap(typing.Generic[_TKey, _TValue]): @@ -237,10 +241,10 @@ def __init__( match key_prefix: case None: self._key_prefix = None - case bytes(key) | algopy_testing.Bytes(value=key): - self._key_prefix = algopy_testing.Bytes(key) - case str(key_str) | algopy_testing.String(value=key_str): - self._key_prefix = algopy_testing.Bytes(key_str.encode("utf8")) + case bytes(key) | _algopy_testing.Bytes(value=key): + self._key_prefix = _algopy_testing.Bytes(key) + case str(key_str) | _algopy_testing.String(value=key_str): + self._key_prefix = _algopy_testing.Bytes(key_str.encode("utf8")) case _: typing.assert_never(key_prefix) self.app_id = lazy_context.active_app_id @@ -290,7 +294,7 @@ def length(self, key: _TKey) -> algopy.UInt64: if not box_exists: raise RuntimeError("Box has not been created") box_content_bytes = lazy_context.ledger.get_box(self.app_id, key_bytes) - return algopy_testing.UInt64(len(box_content_bytes)) + return _algopy_testing.UInt64(len(box_content_bytes)) def _full_key(self, key: _TKey) -> algopy.Bytes: return self.key_prefix + cast_to_bytes(key) diff --git a/src/algopy_testing/state/global_state.py b/src/_algopy_testing/state/global_state.py similarity index 94% rename from src/algopy_testing/state/global_state.py rename to src/_algopy_testing/state/global_state.py index 61aed43..6611340 100644 --- a/src/algopy_testing/state/global_state.py +++ b/src/_algopy_testing/state/global_state.py @@ -3,10 +3,10 @@ import typing from typing import overload -from algopy_testing._context_helpers import lazy_context -from algopy_testing._mutable import set_attr_on_mutate -from algopy_testing.primitives import Bytes, String -from algopy_testing.state.utils import deserialize, serialize +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing._mutable import set_attr_on_mutate +from _algopy_testing.primitives import Bytes, String +from _algopy_testing.state.utils import deserialize, serialize if typing.TYPE_CHECKING: import algopy diff --git a/src/algopy_testing/state/local_state.py b/src/_algopy_testing/state/local_state.py similarity index 91% rename from src/algopy_testing/state/local_state.py rename to src/_algopy_testing/state/local_state.py index 854d025..fd57fed 100644 --- a/src/algopy_testing/state/local_state.py +++ b/src/_algopy_testing/state/local_state.py @@ -2,11 +2,11 @@ import typing -from algopy_testing._context_helpers import lazy_context -from algopy_testing._mutable import set_item_on_mutate -from algopy_testing.models import Account -from algopy_testing.primitives import Bytes, String -from algopy_testing.state.utils import deserialize, serialize +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing._mutable import set_item_on_mutate +from _algopy_testing.models import Account +from _algopy_testing.primitives import Bytes, String +from _algopy_testing.state.utils import deserialize, serialize if typing.TYPE_CHECKING: import algopy diff --git a/src/algopy_testing/state/utils.py b/src/_algopy_testing/state/utils.py similarity index 89% rename from src/algopy_testing/state/utils.py rename to src/_algopy_testing/state/utils.py index 46775d2..58735d8 100644 --- a/src/algopy_testing/state/utils.py +++ b/src/_algopy_testing/state/utils.py @@ -2,10 +2,10 @@ import typing -from algopy_testing import arc4 -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.primitives.uint64 import UInt64 -from algopy_testing.protocols import BytesBacked, UInt64Backed +from _algopy_testing import arc4 +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.primitives.uint64 import UInt64 +from _algopy_testing.protocols import BytesBacked, UInt64Backed _TValue = typing.TypeVar("_TValue") SerializableValue = int | bytes @@ -48,7 +48,7 @@ def cast_from_bytes(typ: type[_TValue], value: bytes) -> _TValue: - UInt64Backed - BytesBacked """ - from algopy_testing.utils import as_int64 + from _algopy_testing.utils import as_int64 if issubclass(typ, bool | UInt64Backed | UInt64): if len(value) > 8: diff --git a/src/_algopy_testing/utilities/__init__.py b/src/_algopy_testing/utilities/__init__.py new file mode 100644 index 0000000..fc95cc4 --- /dev/null +++ b/src/_algopy_testing/utilities/__init__.py @@ -0,0 +1,4 @@ +from _algopy_testing.utilities.budget import OpUpFeeSource, ensure_budget +from _algopy_testing.utilities.log import log + +__all__ = ["OpUpFeeSource", "ensure_budget", "log"] diff --git a/src/algopy_testing/utilities/budget.py b/src/_algopy_testing/utilities/budget.py similarity index 93% rename from src/algopy_testing/utilities/budget.py rename to src/_algopy_testing/utilities/budget.py index 890fde4..ae5495c 100644 --- a/src/algopy_testing/utilities/budget.py +++ b/src/_algopy_testing/utilities/budget.py @@ -1,6 +1,6 @@ from __future__ import annotations -from algopy_testing import UInt64 +from _algopy_testing import UInt64 class OpUpFeeSource(UInt64): diff --git a/src/algopy_testing/utilities/log.py b/src/_algopy_testing/utilities/log.py similarity index 78% rename from src/algopy_testing/utilities/log.py rename to src/_algopy_testing/utilities/log.py index 3d9bbc9..3d0f1c1 100644 --- a/src/algopy_testing/utilities/log.py +++ b/src/_algopy_testing/utilities/log.py @@ -1,9 +1,9 @@ -from algopy_testing._context_helpers import lazy_context -from algopy_testing.constants import UINT64_BYTES_LENGTH -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.primitives.uint64 import UInt64 -from algopy_testing.protocols import BytesBacked -from algopy_testing.utils import int_to_bytes +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing.constants import UINT64_BYTES_LENGTH +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.primitives.uint64 import UInt64 +from _algopy_testing.protocols import BytesBacked +from _algopy_testing.utils import int_to_bytes def log( diff --git a/src/algopy_testing/utils.py b/src/_algopy_testing/utils.py similarity index 78% rename from src/algopy_testing/utils.py rename to src/_algopy_testing/utils.py index 38813e3..2813698 100644 --- a/src/algopy_testing/utils.py +++ b/src/_algopy_testing/utils.py @@ -6,8 +6,8 @@ import algosdk -import algopy_testing -from algopy_testing.constants import ( +import _algopy_testing +from _algopy_testing.constants import ( ARC4_RETURN_PREFIX, DEFAULT_ACCOUNT_MIN_BALANCE, DEFAULT_ASSET_CREATE_MIN_BALANCE, @@ -26,7 +26,7 @@ import algopy - from algopy_testing.op.global_values import GlobalFields + from _algopy_testing.op.global_values import GlobalFields def generate_random_int(min_value: int, max_value: int) -> int: @@ -38,23 +38,16 @@ def generate_random_bytes32() -> bytes: def as_int(value: object, *, max: int | None) -> int: # noqa: A002 - """Returns the underlying int value for any numeric type up to UInt512. - - Raises: - TypeError: If `value` is not a numeric type - ValueError: If not 0 <= `value` <= max - """ - match value: case int(int_value): pass - case algopy_testing.UInt64(value=int_value): + case _algopy_testing.UInt64(value=int_value): pass - case algopy_testing.BigUInt(value=int_value): + case _algopy_testing.BigUInt(value=int_value): pass - case algopy_testing.arc4.UIntN(native=native): + case _algopy_testing.arc4.UIntN(native=native): int_value = native.value - case algopy_testing.arc4.BigUIntN(native=native): + case _algopy_testing.arc4.BigUIntN(native=native): int_value = native.value case _: raise TypeError(f"value must be a numeric type, not {type(value).__name__!r}") @@ -82,17 +75,10 @@ def as_int512(value: object) -> int: def as_bytes(value: object, *, max_size: int = MAX_BYTES_SIZE) -> bytes: - """Returns the underlying bytes value for bytes or Bytes type up to 4096. - - Raises: - TypeError: If `value` is not a bytes type - ValueError: If not 0 <= `len(value)` <= max_size - """ - match value: case bytes(bytes_value): pass - case algopy_testing.Bytes(value=bytes_value): + case _algopy_testing.Bytes(value=bytes_value): pass case _: raise TypeError(f"value must be a bytes or Bytes type, not {type(value).__name__!r}") @@ -103,9 +89,9 @@ def as_bytes(value: object, *, max_size: int = MAX_BYTES_SIZE) -> bytes: def as_string(value: object) -> str: match value: - case str(string_value) | algopy_testing.String(value=string_value): + case str(string_value) | _algopy_testing.String(value=string_value): return string_value - case algopy_testing.arc4.String(native=native): + case _algopy_testing.arc4.String(native=native): return native.value case _: raise TypeError(f"value must be a string or String type, not {type(value).__name__!r}") @@ -124,9 +110,9 @@ def convert_native_to_stack( value: algopy.Bytes | algopy.UInt64 | bytes | int, ) -> algopy.Bytes | algopy.UInt64: if isinstance(value, int): - return algopy_testing.UInt64(value) + return _algopy_testing.UInt64(value) if isinstance(value, bytes): - return algopy_testing.Bytes(value) + return _algopy_testing.Bytes(value) return value @@ -141,7 +127,6 @@ def assert_address_is_valid(address: str) -> None: def get_default_global_fields() -> GlobalFields: - """Return the default global fields for the context.""" import algopy return { @@ -156,13 +141,13 @@ def get_default_global_fields() -> GlobalFields: def get_new_scratch_space() -> list[algopy.Bytes | algopy.UInt64]: - """Return a list of empty scratch slots for the AVM.""" import algopy return [algopy.UInt64(0)] * 256 def arc4_prefix(value: bytes) -> bytes: + """Return the value with the ARC4 prefix prepended.""" return ARC4_RETURN_PREFIX + value diff --git a/src/algopy/__init__.py b/src/algopy/__init__.py index 157a4ac..3eddee8 100644 --- a/src/algopy/__init__.py +++ b/src/algopy/__init__.py @@ -1,23 +1,23 @@ -from algopy_testing._compiled import ( +from _algopy_testing._compiled import ( CompiledContract, CompiledLogicSig, compile_contract, compile_logicsig, ) -from algopy_testing.decorators.subroutine import subroutine -from algopy_testing.enums import OnCompleteAction, TransactionType -from algopy_testing.models.account import Account -from algopy_testing.models.application import Application -from algopy_testing.models.asset import Asset -from algopy_testing.models.contract import ARC4Contract, Contract, StateTotals -from algopy_testing.models.logicsig import LogicSig, logicsig -from algopy_testing.models.template_variable import TemplateVar -from algopy_testing.models.unsigned_builtins import uenumerate, urange -from algopy_testing.op import Global, Txn -from algopy_testing.primitives import BigUInt, Bytes, String, UInt64 -from algopy_testing.protocols import BytesBacked -from algopy_testing.state import Box, BoxMap, BoxRef, GlobalState, LocalState -from algopy_testing.utilities import OpUpFeeSource, ensure_budget, log +from _algopy_testing.decorators.subroutine import subroutine +from _algopy_testing.enums import OnCompleteAction, TransactionType +from _algopy_testing.models.account import Account +from _algopy_testing.models.application import Application +from _algopy_testing.models.asset import Asset +from _algopy_testing.models.contract import ARC4Contract, Contract, StateTotals +from _algopy_testing.models.logicsig import LogicSig, logicsig +from _algopy_testing.models.template_variable import TemplateVar +from _algopy_testing.models.unsigned_builtins import uenumerate, urange +from _algopy_testing.op import Global, Txn +from _algopy_testing.primitives import BigUInt, Bytes, String, UInt64 +from _algopy_testing.protocols import BytesBacked +from _algopy_testing.state import Box, BoxMap, BoxRef, GlobalState, LocalState +from _algopy_testing.utilities import OpUpFeeSource, ensure_budget, log from . import arc4, gtxn, itxn, op diff --git a/src/algopy/arc4.py b/src/algopy/arc4.py index cfc84aa..0424137 100644 --- a/src/algopy/arc4.py +++ b/src/algopy/arc4.py @@ -1,5 +1,5 @@ -from algopy_testing.arc4 import * -from algopy_testing.decorators.arc4 import ( +from _algopy_testing.arc4 import * +from _algopy_testing.decorators.arc4 import ( abimethod as abimethod, baremethod as baremethod, ) diff --git a/src/algopy/gtxn.py b/src/algopy/gtxn.py index 5c73785..48ba60d 100644 --- a/src/algopy/gtxn.py +++ b/src/algopy/gtxn.py @@ -1 +1 @@ -from algopy_testing.gtxn import * +from _algopy_testing.gtxn import * diff --git a/src/algopy/itxn.py b/src/algopy/itxn.py index 7f3f4db..d29fb24 100644 --- a/src/algopy/itxn.py +++ b/src/algopy/itxn.py @@ -1 +1 @@ -from algopy_testing.itxn import * +from _algopy_testing.itxn import * diff --git a/src/algopy/op.py b/src/algopy/op.py index edf012d..1ee9e36 100644 --- a/src/algopy/op.py +++ b/src/algopy/op.py @@ -1 +1 @@ -from algopy_testing.op import * +from _algopy_testing.op import * diff --git a/src/algopy_testing/__init__.py b/src/algopy_testing/__init__.py index c18a6d6..8d02d3c 100644 --- a/src/algopy_testing/__init__.py +++ b/src/algopy_testing/__init__.py @@ -1,69 +1,25 @@ -from algopy_testing import arc4, gtxn, itxn -from algopy_testing._context_helpers.context_storage import algopy_testing_context -from algopy_testing._context_helpers.ledger_context import LedgerContext -from algopy_testing._context_helpers.txn_context import TransactionContext -from algopy_testing._itxn_loader import ITxnGroupLoader, ITxnLoader -from algopy_testing._value_generators.arc4 import ARC4ValueGenerator -from algopy_testing._value_generators.avm import AVMValueGenerator -from algopy_testing._value_generators.txn import TxnValueGenerator -from algopy_testing.context import AlgopyTestContext -from algopy_testing.decorators.subroutine import subroutine -from algopy_testing.enums import OnCompleteAction, TransactionType -from algopy_testing.models import ( - Account, - Application, - ARC4Contract, - Asset, - Contract, - LogicSig, - StateTotals, - TemplateVar, - logicsig, - uenumerate, - urange, -) -from algopy_testing.primitives import BigUInt, Bytes, String, UInt64 -from algopy_testing.state import Box, BoxMap, BoxRef, GlobalState, LocalState +from __future__ import annotations + +from _algopy_testing._context_helpers.context_storage import algopy_testing_context +from _algopy_testing._context_helpers.ledger_context import LedgerContext +from _algopy_testing._context_helpers.txn_context import TransactionContext +from _algopy_testing._itxn_loader import ITxnGroupLoader, ITxnLoader +from _algopy_testing._value_generators.arc4 import ARC4ValueGenerator +from _algopy_testing._value_generators.avm import AVMValueGenerator +from _algopy_testing._value_generators.txn import TxnValueGenerator +from _algopy_testing.context import AlgopyTestContext +from _algopy_testing.utils import arc4_prefix -# TODO: clean up and ensure only algopy_testing namespace specific user facing abstractions -# are exposed Only keep the _value_generators, ledger_context, txn_context, -# context, and arc4_prexif from utils (make utils private) __all__ = [ - "ARC4Contract", "ARC4ValueGenerator", - "Account", "AlgopyTestContext", - "Application", - "Asset", - "BigUInt", - "Box", - "BoxMap", - "BoxRef", - "Bytes", - "Contract", - "GlobalState", - "LocalState", - "LogicSig", "ITxnLoader", "TxnValueGenerator", "ITxnGroupLoader", - "OnCompleteAction", - "StateTotals", - "String", - "TemplateVar", "LedgerContext", "TransactionContext", "AVMValueGenerator", "TxnValueGenerator", - "TransactionType", - "UInt64", "algopy_testing_context", - "arc4", - "gtxn", - "itxn", - "logicsig", - "op", - "subroutine", - "uenumerate", - "urange", + "arc4_prefix", ] diff --git a/src/algopy_testing/_context_helpers/__init__.py b/src/algopy_testing/_context_helpers/__init__.py deleted file mode 100644 index 7ddc3b0..0000000 --- a/src/algopy_testing/_context_helpers/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -from algopy_testing._context_helpers.context_storage import ( - algopy_testing_context, - lazy_context, -) -from algopy_testing._context_helpers.ledger_context import LedgerContext -from algopy_testing._context_helpers.txn_context import TransactionContext - -__all__ = [ - "LedgerContext", - "TransactionContext", - "algopy_testing_context", - "lazy_context", -] diff --git a/src/algopy_testing/decorators/__init__.py b/src/algopy_testing/decorators/__init__.py deleted file mode 100644 index 35572df..0000000 --- a/src/algopy_testing/decorators/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from algopy_testing.decorators.arc4 import abimethod, baremethod -from algopy_testing.decorators.subroutine import subroutine - -__all__ = [ - "abimethod", - "baremethod", - "subroutine", -] diff --git a/src/algopy_testing/models/__init__.py b/src/algopy_testing/models/__init__.py deleted file mode 100644 index 57a5224..0000000 --- a/src/algopy_testing/models/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -from algopy_testing.models.account import Account -from algopy_testing.models.application import Application -from algopy_testing.models.asset import Asset -from algopy_testing.models.contract import ARC4Contract, Contract, StateTotals -from algopy_testing.models.logicsig import LogicSig, logicsig -from algopy_testing.models.template_variable import TemplateVar -from algopy_testing.models.unsigned_builtins import uenumerate, urange - -__all__ = [ - "ARC4Contract", - "Account", - "Application", - "Asset", - "Contract", - "LogicSig", - "StateTotals", - "TemplateVar", - "logicsig", - "uenumerate", - "urange", -] diff --git a/src/algopy_testing/primitives/__init__.py b/src/algopy_testing/primitives/__init__.py deleted file mode 100644 index 8fc7f89..0000000 --- a/src/algopy_testing/primitives/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -from algopy_testing.primitives.biguint import BigUInt -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.primitives.string import String -from algopy_testing.primitives.uint64 import UInt64 - -__all__ = ["BigUInt", "Bytes", "String", "UInt64"] diff --git a/src/algopy_testing/state/__init__.py b/src/algopy_testing/state/__init__.py deleted file mode 100644 index a10f6e3..0000000 --- a/src/algopy_testing/state/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from algopy_testing.state.box import Box, BoxMap, BoxRef -from algopy_testing.state.global_state import GlobalState -from algopy_testing.state.local_state import LocalState - -__all__ = ["GlobalState", "LocalState", "Box", "BoxRef", "BoxMap"] diff --git a/src/algopy_testing/utilities/__init__.py b/src/algopy_testing/utilities/__init__.py deleted file mode 100644 index 88725a2..0000000 --- a/src/algopy_testing/utilities/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -from algopy_testing.utilities.budget import OpUpFeeSource, ensure_budget -from algopy_testing.utilities.log import log - -__all__ = ["OpUpFeeSource", "ensure_budget", "log"] diff --git a/tests/arc4/test_abi_call.py b/tests/arc4/test_abi_call.py index 2ba1e0e..b5d8920 100644 --- a/tests/arc4/test_abi_call.py +++ b/tests/arc4/test_abi_call.py @@ -2,9 +2,9 @@ from collections.abc import Generator import pytest +from _algopy_testing import AlgopyTestContext, algopy_testing_context +from _algopy_testing.itxn import ApplicationCallInnerTransaction from algopy import ARC4Contract, arc4 -from algopy_testing import AlgopyTestContext, algopy_testing_context -from algopy_testing.itxn import ApplicationCallInnerTransaction from pytest_mock import MockerFixture diff --git a/tests/arc4/test_address.py b/tests/arc4/test_address.py index f7642e7..c80e3eb 100644 --- a/tests/arc4/test_address.py +++ b/tests/arc4/test_address.py @@ -1,8 +1,8 @@ -import algopy_testing.primitives as algopy +import _algopy_testing.primitives as algopy import algosdk import pytest -from algopy_testing import arc4 -from algopy_testing.models import Account +from _algopy_testing import arc4 +from _algopy_testing.models import Account _abi_address_type = algosdk.abi.ABIType.from_string("address") diff --git a/tests/arc4/test_arc4_method_signature.py b/tests/arc4/test_arc4_method_signature.py index fe5bac5..5604cc5 100644 --- a/tests/arc4/test_arc4_method_signature.py +++ b/tests/arc4/test_arc4_method_signature.py @@ -1,9 +1,9 @@ from collections.abc import Generator from pathlib import Path +import _algopy_testing import algokit_utils import algopy -import algopy_testing import algosdk import pytest from algokit_utils.beta.algorand_client import AlgorandClient, AssetCreateParams, PayParams @@ -30,13 +30,13 @@ def get_avm_result(algod_client: AlgodClient) -> AVMInvoker: @pytest.fixture() -def context() -> Generator[algopy_testing.AlgopyTestContext, None, None]: - with algopy_testing.algopy_testing_context() as ctx: +def context() -> Generator[_algopy_testing.AlgopyTestContext, None, None]: + with _algopy_testing.algopy_testing_context() as ctx: yield ctx @pytest.fixture() -def funded_account(algod_client: AlgodClient, context: algopy_testing.AlgopyTestContext) -> str: +def funded_account(algod_client: AlgodClient, context: _algopy_testing.AlgopyTestContext) -> str: pk, address = algosdk.account.generate_account() assert isinstance(address, str) algokit_utils.ensure_funded( @@ -53,7 +53,7 @@ def funded_account(algod_client: AlgodClient, context: algopy_testing.AlgopyTest @pytest.fixture() -def other_app_id(algod_client: AlgodClient, context: algopy_testing.AlgopyTestContext) -> int: +def other_app_id(algod_client: AlgodClient, context: _algopy_testing.AlgopyTestContext) -> int: second_invoker = create_avm_invoker(APP_SPEC, algod_client) client = second_invoker.client app_id = client.app_id @@ -65,7 +65,7 @@ def other_app_id(algod_client: AlgodClient, context: algopy_testing.AlgopyTestCo def test_app_args_is_correct_with_simple_args( get_avm_result: AVMInvoker, - context: algopy_testing.AlgopyTestContext, + context: _algopy_testing.AlgopyTestContext, ) -> None: # arrange contract = SignaturesContract() @@ -90,7 +90,7 @@ def test_app_args_is_correct_with_simple_args( def test_app_args_is_correct_with_alias( get_avm_result: AVMInvoker, - context: algopy_testing.AlgopyTestContext, + context: _algopy_testing.AlgopyTestContext, ) -> None: # arrange contract = SignaturesContract() @@ -113,7 +113,7 @@ def test_app_args_is_correct_with_alias( def test_app_args_is_correct_with_txn( - context: algopy_testing.AlgopyTestContext, + context: _algopy_testing.AlgopyTestContext, get_avm_result: AVMInvoker, localnet_creator_address: str, algorand: AlgorandClient, @@ -155,7 +155,7 @@ def test_app_args_is_correct_with_txn( def test_app_args_is_correct_with_asset( - context: algopy_testing.AlgopyTestContext, + context: _algopy_testing.AlgopyTestContext, localnet_creator_address: str, algorand: AlgorandClient, get_avm_result: AVMInvoker, @@ -191,7 +191,7 @@ def test_app_args_is_correct_with_asset( def test_app_args_is_correct_with_account( - context: algopy_testing.AlgopyTestContext, + context: _algopy_testing.AlgopyTestContext, funded_account: str, get_avm_result: AVMInvoker, ) -> None: @@ -224,7 +224,7 @@ def test_app_args_is_correct_with_account( def test_app_args_is_correct_with_application( - context: algopy_testing.AlgopyTestContext, + context: _algopy_testing.AlgopyTestContext, other_app_id: int, get_avm_result: AVMInvoker, ) -> None: @@ -269,7 +269,7 @@ def test_app_args_is_correct_with_application( def test_app_args_is_correct_with_complex( - context: algopy_testing.AlgopyTestContext, + context: _algopy_testing.AlgopyTestContext, funded_account: str, ) -> None: # arrange @@ -305,7 +305,7 @@ def test_app_args_is_correct_with_complex( def test_prepare_txns_with_complex( - context: algopy_testing.AlgopyTestContext, + context: _algopy_testing.AlgopyTestContext, get_avm_result: AVMInvoker, algorand: AlgorandClient, localnet_creator_address: str, diff --git a/tests/arc4/test_bool.py b/tests/arc4/test_bool.py index c3ef22b..19d8dc9 100644 --- a/tests/arc4/test_bool.py +++ b/tests/arc4/test_bool.py @@ -3,8 +3,8 @@ import algokit_utils import algopy import pytest -from algopy_testing import arc4 -from algopy_testing.constants import ARC4_RETURN_PREFIX +from _algopy_testing import arc4 +from _algopy_testing.constants import ARC4_RETURN_PREFIX from tests.common import AVMInvoker diff --git a/tests/arc4/test_dynamic_array.py b/tests/arc4/test_dynamic_array.py index 4ae74ef..0207db1 100644 --- a/tests/arc4/test_dynamic_array.py +++ b/tests/arc4/test_dynamic_array.py @@ -2,7 +2,7 @@ import typing import pytest -from algopy_testing import arc4 +from _algopy_testing import arc4 from algosdk import abi from tests.util import int_to_bytes diff --git a/tests/arc4/test_dynamic_bytes.py b/tests/arc4/test_dynamic_bytes.py index b66a457..9a27382 100644 --- a/tests/arc4/test_dynamic_bytes.py +++ b/tests/arc4/test_dynamic_bytes.py @@ -3,7 +3,7 @@ import algosdk import pytest -from algopy_testing import Bytes, arc4 +from _algopy_testing import Bytes, arc4 from tests.util import int_to_bytes diff --git a/tests/arc4/test_emit.py b/tests/arc4/test_emit.py index e112198..4f577d0 100644 --- a/tests/arc4/test_emit.py +++ b/tests/arc4/test_emit.py @@ -4,8 +4,8 @@ import algopy import pytest -from algopy_testing import AlgopyTestContext, algopy_testing_context, arc4 -from algopy_testing.constants import MAX_UINT64, MAX_UINT512 +from _algopy_testing import AlgopyTestContext, algopy_testing_context, arc4 +from _algopy_testing.constants import MAX_UINT64, MAX_UINT512 from tests.common import AVMInvoker diff --git a/tests/arc4/test_static_array.py b/tests/arc4/test_static_array.py index be5ef88..1bfcbe8 100644 --- a/tests/arc4/test_static_array.py +++ b/tests/arc4/test_static_array.py @@ -2,7 +2,7 @@ import typing import pytest -from algopy_testing import arc4 +from _algopy_testing import arc4 from algosdk import abi from tests.util import int_to_bytes diff --git a/tests/arc4/test_string.py b/tests/arc4/test_string.py index 7b68081..8d8796f 100644 --- a/tests/arc4/test_string.py +++ b/tests/arc4/test_string.py @@ -3,8 +3,8 @@ import algokit_utils import algopy import pytest -from algopy_testing import arc4 -from algopy_testing.constants import ARC4_RETURN_PREFIX, MAX_LOG_SIZE +from _algopy_testing import arc4 +from _algopy_testing.constants import ARC4_RETURN_PREFIX, MAX_LOG_SIZE from tests.common import AVMInvoker from tests.util import int_to_bytes diff --git a/tests/arc4/test_struct.py b/tests/arc4/test_struct.py index 496ba86..d8f07a8 100644 --- a/tests/arc4/test_struct.py +++ b/tests/arc4/test_struct.py @@ -1,7 +1,7 @@ import typing import pytest -from algopy_testing import arc4 +from _algopy_testing import arc4 from algosdk import abi from tests.util import int_to_bytes diff --git a/tests/arc4/test_tuple.py b/tests/arc4/test_tuple.py index 6ca6edc..05c7a23 100644 --- a/tests/arc4/test_tuple.py +++ b/tests/arc4/test_tuple.py @@ -1,7 +1,7 @@ import typing import pytest -from algopy_testing import arc4 +from _algopy_testing import arc4 from algosdk import abi from tests.util import int_to_bytes diff --git a/tests/arc4/test_ufixednxm.py b/tests/arc4/test_ufixednxm.py index 5d979b3..929ff53 100644 --- a/tests/arc4/test_ufixednxm.py +++ b/tests/arc4/test_ufixednxm.py @@ -2,9 +2,9 @@ import algokit_utils import pytest -from algopy_testing import arc4 -from algopy_testing.constants import ARC4_RETURN_PREFIX -from algopy_testing.primitives.bytes import Bytes +from _algopy_testing import arc4 +from _algopy_testing.constants import ARC4_RETURN_PREFIX +from _algopy_testing.primitives.bytes import Bytes from tests.common import AVMInvoker from tests.util import int_to_bytes diff --git a/tests/arc4/test_uintn.py b/tests/arc4/test_uintn.py index 42f758c..40e7161 100644 --- a/tests/arc4/test_uintn.py +++ b/tests/arc4/test_uintn.py @@ -3,9 +3,9 @@ import algokit_utils import pytest -from algopy_testing import arc4 -from algopy_testing.constants import ARC4_RETURN_PREFIX, MAX_UINT64, MAX_UINT512 -from algopy_testing.primitives.bytes import Bytes +from _algopy_testing import arc4 +from _algopy_testing.constants import ARC4_RETURN_PREFIX, MAX_UINT64, MAX_UINT512 +from _algopy_testing.primitives.bytes import Bytes from tests.common import AVMInvoker from tests.util import int_to_bytes diff --git a/tests/models/test_asset.py b/tests/models/test_asset.py index e275ffe..cf8877c 100644 --- a/tests/models/test_asset.py +++ b/tests/models/test_asset.py @@ -1,9 +1,9 @@ from collections.abc import Generator import pytest +from _algopy_testing import AlgopyTestContext, algopy_testing_context +from _algopy_testing.models.asset import Asset, AssetFields from algopy import Account, Bytes, UInt64 -from algopy_testing import AlgopyTestContext, algopy_testing_context -from algopy_testing.models.asset import Asset, AssetFields @pytest.fixture() diff --git a/tests/models/test_box.py b/tests/models/test_box.py index a8194c1..257b8e0 100644 --- a/tests/models/test_box.py +++ b/tests/models/test_box.py @@ -3,15 +3,15 @@ import algopy import pytest -from algopy_testing import algopy_testing_context, arc4 -from algopy_testing.context import AlgopyTestContext -from algopy_testing.op.pure import itob -from algopy_testing.primitives.biguint import BigUInt -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.primitives.string import String -from algopy_testing.primitives.uint64 import UInt64 -from algopy_testing.state.box import Box -from algopy_testing.utils import as_bytes, as_string +from _algopy_testing import algopy_testing_context, arc4 +from _algopy_testing.context import AlgopyTestContext +from _algopy_testing.op.pure import itob +from _algopy_testing.primitives.biguint import BigUInt +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.primitives.string import String +from _algopy_testing.primitives.uint64 import UInt64 +from _algopy_testing.state.box import Box +from _algopy_testing.utils import as_bytes, as_string from tests.artifacts.BoxContract.contract import BoxContract diff --git a/tests/models/test_box_map.py b/tests/models/test_box_map.py index f7ed52f..02e812f 100644 --- a/tests/models/test_box_map.py +++ b/tests/models/test_box_map.py @@ -3,14 +3,14 @@ import algopy import pytest -from algopy_testing import algopy_testing_context, arc4 -from algopy_testing.context import AlgopyTestContext -from algopy_testing.primitives.biguint import BigUInt -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.primitives.string import String -from algopy_testing.primitives.uint64 import UInt64 -from algopy_testing.state.box import BoxMap -from algopy_testing.utils import as_bytes, as_string +from _algopy_testing import algopy_testing_context, arc4 +from _algopy_testing.context import AlgopyTestContext +from _algopy_testing.primitives.biguint import BigUInt +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.primitives.string import String +from _algopy_testing.primitives.uint64 import UInt64 +from _algopy_testing.state.box import BoxMap +from _algopy_testing.utils import as_bytes, as_string BOX_NOT_CREATED_ERROR = "Box has not been created" diff --git a/tests/models/test_box_ref.py b/tests/models/test_box_ref.py index ee09f00..64cdfa0 100644 --- a/tests/models/test_box_ref.py +++ b/tests/models/test_box_ref.py @@ -2,13 +2,13 @@ import algopy import pytest -from algopy_testing import algopy_testing_context -from algopy_testing.constants import MAX_BOX_SIZE, MAX_BYTES_SIZE -from algopy_testing.context import AlgopyTestContext -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.primitives.string import String -from algopy_testing.state.box import BoxRef -from algopy_testing.utils import as_bytes, as_string +from _algopy_testing import algopy_testing_context +from _algopy_testing.constants import MAX_BOX_SIZE, MAX_BYTES_SIZE +from _algopy_testing.context import AlgopyTestContext +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.primitives.string import String +from _algopy_testing.state.box import BoxRef +from _algopy_testing.utils import as_bytes, as_string TEST_BOX_KEY = b"test_key" BOX_NOT_CREATED_ERROR = "Box has not been created" diff --git a/tests/models/test_uenumerate.py b/tests/models/test_uenumerate.py index 08d8c5c..bd1c4e8 100644 --- a/tests/models/test_uenumerate.py +++ b/tests/models/test_uenumerate.py @@ -2,8 +2,8 @@ import algopy import pytest -from algopy_testing.constants import MAX_UINT64 -from algopy_testing.models.unsigned_builtins import uenumerate, urange +from _algopy_testing.constants import MAX_UINT64 +from _algopy_testing.models.unsigned_builtins import uenumerate, urange @pytest.mark.parametrize( diff --git a/tests/models/test_urange.py b/tests/models/test_urange.py index 13007e3..a9e96e4 100644 --- a/tests/models/test_urange.py +++ b/tests/models/test_urange.py @@ -2,8 +2,8 @@ import algopy import pytest -from algopy_testing.constants import MAX_UINT64 -from algopy_testing.models.unsigned_builtins import urange +from _algopy_testing.constants import MAX_UINT64 +from _algopy_testing.models.unsigned_builtins import urange @pytest.mark.parametrize( diff --git a/tests/primitives/test_biguint.py b/tests/primitives/test_biguint.py index e8333b3..4d3c501 100644 --- a/tests/primitives/test_biguint.py +++ b/tests/primitives/test_biguint.py @@ -4,9 +4,9 @@ import algokit_utils import pytest -from algopy_testing.constants import MAX_UINT64, MAX_UINT512, UINT512_BYTES_LENGTH -from algopy_testing.primitives.biguint import BigUInt -from algopy_testing.primitives.uint64 import UInt64 +from _algopy_testing.constants import MAX_UINT64, MAX_UINT512, UINT512_BYTES_LENGTH +from _algopy_testing.primitives.biguint import BigUInt +from _algopy_testing.primitives.uint64 import UInt64 from tests.common import AVMInvoker from tests.util import int_to_bytes diff --git a/tests/primitives/test_bytes.py b/tests/primitives/test_bytes.py index 1ec1e4b..5b7cdef 100644 --- a/tests/primitives/test_bytes.py +++ b/tests/primitives/test_bytes.py @@ -2,8 +2,8 @@ import algokit_utils import pytest -from algopy_testing.constants import MAX_BYTES_SIZE -from algopy_testing.primitives.bytes import Bytes +from _algopy_testing.constants import MAX_BYTES_SIZE +from _algopy_testing.primitives.bytes import Bytes from tests.common import AVMInvoker from tests.util import get_sha256_hash, int_to_bytes diff --git a/tests/primitives/test_string.py b/tests/primitives/test_string.py index 37ac8bb..1f1ae65 100644 --- a/tests/primitives/test_string.py +++ b/tests/primitives/test_string.py @@ -1,6 +1,6 @@ import pytest +from _algopy_testing.constants import MAX_LOG_SIZE from algopy import String -from algopy_testing.constants import MAX_LOG_SIZE from tests.common import AVMInvoker diff --git a/tests/primitives/test_uint64.py b/tests/primitives/test_uint64.py index 09401cd..ee11f6d 100644 --- a/tests/primitives/test_uint64.py +++ b/tests/primitives/test_uint64.py @@ -4,8 +4,8 @@ import algokit_utils import pytest +from _algopy_testing.constants import MAX_UINT64, MAX_UINT512 from algopy import UInt64 -from algopy_testing.constants import MAX_UINT64, MAX_UINT512 from tests.common import AVMInvoker diff --git a/tests/state/test_global_state.py b/tests/state/test_global_state.py index 7160e02..7995c29 100644 --- a/tests/state/test_global_state.py +++ b/tests/state/test_global_state.py @@ -2,11 +2,11 @@ from typing import Any import pytest -from algopy_testing import arc4 -from algopy_testing._context_helpers.context_storage import algopy_testing_context -from algopy_testing.context import AlgopyTestContext -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.state.global_state import GlobalState +from _algopy_testing import arc4 +from _algopy_testing._context_helpers.context_storage import algopy_testing_context +from _algopy_testing.context import AlgopyTestContext +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.state.global_state import GlobalState @pytest.fixture() diff --git a/tests/state/test_local_state.py b/tests/state/test_local_state.py index 1dd91e9..999daf9 100644 --- a/tests/state/test_local_state.py +++ b/tests/state/test_local_state.py @@ -1,7 +1,7 @@ +import _algopy_testing import algopy -import algopy_testing import pytest -from algopy_testing._context_helpers.context_storage import algopy_testing_context +from _algopy_testing._context_helpers.context_storage import algopy_testing_context from tests.artifacts.StateOps.contract import LocalStateContract from tests.common import AVMInvoker @@ -43,7 +43,7 @@ def test_get_local_arc4_value( contract.opt_in() test_result = getattr(contract, method_name)(ctx.default_sender) assert isinstance(test_result, expected_type) - if isinstance(test_result, algopy_testing.arc4.Address): + if isinstance(test_result, _algopy_testing.arc4.Address): assert test_result.native.public_key == avm_result else: assert test_result.native == avm_result # type: ignore[attr-defined] diff --git a/tests/state/test_mutations.py b/tests/state/test_mutations.py index 59ac144..ea1f8dc 100644 --- a/tests/state/test_mutations.py +++ b/tests/state/test_mutations.py @@ -1,20 +1,20 @@ from collections.abc import Generator +import _algopy_testing import algopy -import algopy_testing import pytest from tests.artifacts.StateMutations.statemutations import StateMutations @pytest.fixture() -def context() -> Generator[algopy_testing.AlgopyTestContext, None, None]: - with algopy_testing.algopy_testing_context() as ctx: +def context() -> Generator[_algopy_testing.AlgopyTestContext, None, None]: + with _algopy_testing.algopy_testing_context() as ctx: yield ctx def test_state_mutations( - context: algopy_testing.AlgopyTestContext, + context: _algopy_testing.AlgopyTestContext, ) -> None: contract = StateMutations() diff --git a/tests/test_context.py b/tests/test_context.py index 288d1a5..b3ac9cd 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -1,13 +1,13 @@ import algopy.itxn import algosdk import pytest +from _algopy_testing import algopy_testing_context, arc4 +from _algopy_testing._context_helpers import lazy_context +from _algopy_testing._context_helpers.txn_context import TransactionGroup +from _algopy_testing.constants import MAX_UINT8, MAX_UINT16, MAX_UINT32, MAX_UINT64, MAX_UINT512 +from _algopy_testing.context import AlgopyTestContext +from _algopy_testing.itxn import PaymentInnerTransaction from algopy import Bytes, TransactionType, UInt64 -from algopy_testing import algopy_testing_context, arc4 -from algopy_testing._context_helpers import lazy_context -from algopy_testing._context_helpers.txn_context import TransactionGroup -from algopy_testing.constants import MAX_UINT8, MAX_UINT16, MAX_UINT32, MAX_UINT64, MAX_UINT512 -from algopy_testing.context import AlgopyTestContext -from algopy_testing.itxn import PaymentInnerTransaction from tests.artifacts.Arc4InnerTxns.contract import Arc4InnerTxnsContract from tests.artifacts.GlobalStateValidator.contract import GlobalStateValidator diff --git a/tests/test_miscellaneous_op.py b/tests/test_miscellaneous_op.py index c464844..60387bc 100644 --- a/tests/test_miscellaneous_op.py +++ b/tests/test_miscellaneous_op.py @@ -5,8 +5,8 @@ import algokit_utils import pytest +from _algopy_testing.constants import MAX_BYTES_SIZE, MAX_UINT64, MAX_UINT512 from algopy import BigUInt, UInt64, op -from algopy_testing.constants import MAX_BYTES_SIZE, MAX_UINT64, MAX_UINT512 from algosdk.v2client.algod import AlgodClient from tests.common import AVMInvoker, create_avm_invoker diff --git a/tests/test_op.py b/tests/test_op.py index 4146edb..1bd4dec 100644 --- a/tests/test_op.py +++ b/tests/test_op.py @@ -2,21 +2,21 @@ import typing from pathlib import Path +import _algopy_testing import algopy -import algopy_testing import algosdk import coincurve import ecdsa # type: ignore # noqa: PGH003 import ecdsa.util # type: ignore # noqa: PGH003 import nacl.signing import pytest +from _algopy_testing import algopy_testing_context, op +from _algopy_testing.context import AlgopyTestContext +from _algopy_testing.op.block import Block +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.primitives.uint64 import UInt64 +from _algopy_testing.utils import convert_native_to_stack from algokit_utils import LogicError, get_localnet_default_account -from algopy_testing import algopy_testing_context, op -from algopy_testing.context import AlgopyTestContext -from algopy_testing.op.block import Block -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.primitives.uint64 import UInt64 -from algopy_testing.utils import convert_native_to_stack from algosdk.v2client.algod import AlgodClient from Cryptodome.Hash import keccak from ecdsa import SECP256k1, SigningKey, curves @@ -401,7 +401,7 @@ def run_mocked_vrf_verify() -> tuple[Bytes, bool]: return op.vrf_verify(op.VrfVerify.VrfAlgorand, a, b, c) avm_result = run_real_vrf_verify() - mocker.patch("algopy_testing.op.vrf_verify", return_value=(avm_result[0], True)) + mocker.patch("_algopy_testing.op.vrf_verify", return_value=(avm_result[0], True)) mocked_result = run_mocked_vrf_verify() assert avm_result == mocked_result @@ -634,8 +634,8 @@ def test_acct_params_get( ], ) def test_app_local_put_get_and_delete( - context: algopy_testing.AlgopyTestContext, - localnet_creator: algopy_testing.Account, + context: _algopy_testing.AlgopyTestContext, + localnet_creator: _algopy_testing.Account, get_state_app_local_avm_opted_in: AVMInvoker, key: bytes, value: bytes | int, @@ -686,7 +686,7 @@ def test_app_local_put_get_and_delete( def test_app_local_ex_get( context: AlgopyTestContext, - localnet_creator: algopy_testing.Account, + localnet_creator: _algopy_testing.Account, get_state_app_local_avm_result: AVMInvoker, get_state_app_local_ex_avm_result: AVMInvoker, ) -> None: @@ -716,7 +716,7 @@ def test_app_local_ex_get( def test_app_local_ex_get_arc4( context: AlgopyTestContext, - localnet_creator: algopy_testing.Account, + localnet_creator: _algopy_testing.Account, get_state_app_local_avm_result: AVMInvoker, get_state_app_local_ex_avm_result: AVMInvoker, ) -> None: diff --git a/tests/utilities/test_log.py b/tests/utilities/test_log.py index 38f6d72..232eaad 100644 --- a/tests/utilities/test_log.py +++ b/tests/utilities/test_log.py @@ -4,9 +4,9 @@ import algopy import pytest -from algopy_testing import AlgopyTestContext, algopy_testing_context, arc4 -from algopy_testing.constants import MAX_UINT64, MAX_UINT512 -from algopy_testing.utilities.log import log +from _algopy_testing import AlgopyTestContext, algopy_testing_context, arc4 +from _algopy_testing.constants import MAX_UINT64, MAX_UINT512 +from _algopy_testing.utilities.log import log from tests.common import AVMInvoker diff --git a/tests/value_generators/test_avm.py b/tests/value_generators/test_avm.py index fdfd7f8..0331367 100644 --- a/tests/value_generators/test_avm.py +++ b/tests/value_generators/test_avm.py @@ -3,11 +3,11 @@ import algopy import algosdk import pytest -from algopy_testing import algopy_testing_context -from algopy_testing.constants import MAX_BYTES_SIZE, MAX_UINT64 -from algopy_testing.context import AlgopyTestContext -from algopy_testing.primitives.bytes import Bytes -from algopy_testing.primitives.string import String +from _algopy_testing import algopy_testing_context +from _algopy_testing.constants import MAX_BYTES_SIZE, MAX_UINT64 +from _algopy_testing.context import AlgopyTestContext +from _algopy_testing.primitives.bytes import Bytes +from _algopy_testing.primitives.string import String @pytest.fixture()