Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add test case to confirm group simulate and send matches #146

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions tests/applications/test_app_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
from algokit_utils.applications.app_spec.arc56 import Arc56Contract, Network
from algokit_utils.errors.logic_error import LogicError
from algokit_utils.models.account import SigningAccount
from algokit_utils.models.amount import AlgoAmount
from algokit_utils.models.amount import AlgoAmount, micro_algo
from algokit_utils.models.state import BoxReference
from algokit_utils.transactions.transaction_composer import AppCreateParams, PaymentParams
from algokit_utils.transactions.transaction_composer import AppCallMethodCallParams, AppCreateParams, PaymentParams


@pytest.fixture
Expand Down Expand Up @@ -279,6 +279,48 @@ def test_clone_inheriting_app_name_based_on_default_handling(
assert cloned_app_client.app_name == hello_world_arc32_app_spec.contract.name == app_client.app_name


def test_group_simulate_matches_send(
funded_account: SigningAccount,
test_app_client: AppClient,
) -> None:
app_call1_params = AppCallMethodCallParams(
sender=funded_account.address,
app_id=test_app_client.app_id,
method=algosdk.abi.Method.from_signature("set_global(uint64,uint64,string,byte[4])void"),
args=[1, 2, "asdf", bytes([1, 2, 3, 4])],
)
payment_params = PaymentParams(
sender=funded_account.address, receiver=funded_account.address, amount=micro_algo(10000)
)
app_call2_params = AppCallMethodCallParams(
sender=funded_account.address,
app_id=test_app_client.app_id,
method=algosdk.abi.Method.from_signature("call_abi(string)string"),
args=["test"],
)

simulate_result = (
test_app_client.algorand.new_group()
.add_app_call_method_call(app_call1_params)
.add_payment(payment_params)
.add_app_call_method_call(app_call2_params)
.simulate(skip_signatures=True)
)

send_result = (
test_app_client.algorand.new_group()
.add_app_call_method_call(app_call1_params)
.add_payment(payment_params)
.add_app_call_method_call(app_call2_params)
.send()
)

assert len(simulate_result.transactions) == len(send_result.transactions)
assert len(simulate_result.returns) == len(send_result.returns)
assert simulate_result.returns[0].value == send_result.returns[0].value
assert simulate_result.returns[1].value == send_result.returns[1].value


def test_normalise_app_spec(
raw_hello_world_arc32_app_spec: str,
hello_world_arc32_app_spec: ApplicationSpecification,
Expand Down
Loading