algopy_testing.value_generators.avm
Module Contents
Section titled “Module Contents”Classes
Section titled “Classes”AVMValueGenerator | Factory for generating test data for AVM abstractions (uint64, bytes, string, |
|---|
class AVMValueGenerator
Section titled “class AVMValueGenerator”Factory for generating test data for AVM abstractions (uint64, bytes, string, accounts, assets and applications).
uint64(min_value: int = 0, max_value: int = MAX_UINT64) → algopy.UInt64
Section titled “uint64(min_value: int = 0, max_value: int = MAX_UINT64) → algopy.UInt64”Generate a random UInt64 value within a specified range.
- Parameters:
- min_value – Minimum value. Defaults to 0.
- max_value – Maximum value. Defaults to MAX_UINT64.
- Returns: The randomly generated UInt64 value.
- Raises: ValueError – If max_value exceeds MAX_UINT64 or min_value exceeds max_value.
biguint(min_value: int = 0) → algopy.BigUInt
Section titled “biguint(min_value: int = 0) → algopy.BigUInt”Generate a random BigUInt value within a specified range.
- Parameters: min_value – Minimum value. Defaults to 0.
- Returns: The randomly generated BigUInt value.
- Raises: ValueError – If min_value is negative.
string(length: int = MAX_BYTES_SIZE) → algopy.String
Section titled “string(length: int = MAX_BYTES_SIZE) → algopy.String”Generate a random string of a specified length.
- Parameters: length – int: (Default value = MAX_BYTES_SIZE)
- Returns: The randomly generated string.
account(address: str | None = None, opted_asset_balances: dict[algopy.Asset | algopy.UInt64 | int, algopy.UInt64 | int] | None = None, opted_apps: Sequence[algopy.Application | algopy.UInt64 | int] = (), **account_fields: Unpack[AccountFields]) → algopy.Account
Section titled “account(address: str | None = None, opted_asset_balances: dict[algopy.Asset | algopy.UInt64 | int, algopy.UInt64 | int] | None = None, opted_apps: Sequence[algopy.Application | algopy.UInt64 | int] = (), **account_fields: Unpack[AccountFields]) → algopy.Account”Initialize a new account with specified fields and balances.
asset(asset_id: int | None = None, **asset_fields: Unpack[AssetFields]) → algopy.Asset
Section titled “asset(asset_id: int | None = None, **asset_fields: Unpack[AssetFields]) → algopy.Asset”Generate and add a new asset with a unique ID.
application(id: int | None = None, logs: list[bytes] | None = None, **application_fields: Unpack[ApplicationFields]) → algopy.Application
Section titled “application(id: int | None = None, logs: list[bytes] | None = None, **application_fields: Unpack[ApplicationFields]) → algopy.Application”Generate and add a new application with a unique ID.
bytes(length: int | None = None) → algopy.Bytes
Section titled “bytes(length: int | None = None) → algopy.Bytes”Generate a random byte sequence of a specified length.
- Parameters: length – Length of the byte sequence. Defaults to MAX_BYTES_SIZE.
- Returns: The randomly generated byte sequence.
fixed_bytes(fixed_bytes_type: type[algopy.FixedBytes[_TBytesLength]]) → algopy.FixedBytes[_TBytesLength]
Section titled “fixed_bytes(fixed_bytes_type: type[algopy.FixedBytes[_TBytesLength]]) → algopy.FixedBytes[_TBytesLength]”Generate a random fixed byte sequence of a specified length.
- Parameters: fixed_bytes_type – The FixedBytes type with length parameter (e.g., FixedBytes[typing.Literal[10]]).
- Returns: The randomly generated fixed byte sequence.