Skip to content

Commit 3283c7b

Browse files
committed
test: add test for an error due to a rejection
1 parent d7d4b36 commit 3283c7b

File tree

3 files changed

+67
-37
lines changed

3 files changed

+67
-37
lines changed

tests/applications/test_app_client.py

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pytest
99
from algosdk.atomic_transaction_composer import TransactionSigner, TransactionWithSigner
1010

11+
from algokit_utils import SendParams
1112
from algokit_utils._legacy_v2.application_specification import ApplicationSpecification
1213
from algokit_utils.algorand import AlgorandClient
1314
from algokit_utils.applications.abi import ABIType
@@ -166,45 +167,16 @@ def testing_app_puya_arc32_app_spec() -> ApplicationSpecification:
166167
return ApplicationSpecification.from_json(raw_json_spec.read_text())
167168

168169

169-
@pytest.fixture
170-
def testing_app_puya_arc32_app_id(
171-
algorand: AlgorandClient, funded_account: SigningAccount, testing_app_puya_arc32_app_spec: ApplicationSpecification
172-
) -> int:
173-
global_schema = testing_app_puya_arc32_app_spec.global_state_schema
174-
local_schema = testing_app_puya_arc32_app_spec.local_state_schema
175-
176-
response = algorand.send.app_create(
177-
AppCreateParams(
178-
sender=funded_account.address,
179-
approval_program=testing_app_puya_arc32_app_spec.approval_program,
180-
clear_state_program=testing_app_puya_arc32_app_spec.clear_program,
181-
schema={
182-
"global_byte_slices": int(global_schema.num_byte_slices) if global_schema.num_byte_slices else 0,
183-
"global_ints": int(global_schema.num_uints) if global_schema.num_uints else 0,
184-
"local_byte_slices": int(local_schema.num_byte_slices) if local_schema.num_byte_slices else 0,
185-
"local_ints": int(local_schema.num_uints) if local_schema.num_uints else 0,
186-
},
187-
)
188-
)
189-
return response.app_id
190-
191-
192170
@pytest.fixture
193171
def test_app_client_puya(
194-
algorand: AlgorandClient,
195-
funded_account: SigningAccount,
196-
testing_app_puya_arc32_app_spec: ApplicationSpecification,
197-
testing_app_puya_arc32_app_id: int,
172+
algorand: AlgorandClient, funded_account: SigningAccount, testing_app_puya_arc32_app_spec: ApplicationSpecification
198173
) -> AppClient:
199-
return AppClient(
200-
AppClientParams(
201-
default_sender=funded_account.address,
202-
default_signer=funded_account.signer,
203-
app_id=testing_app_puya_arc32_app_id,
204-
algorand=algorand,
205-
app_spec=testing_app_puya_arc32_app_spec,
206-
)
174+
factory = algorand.client.get_app_factory(
175+
app_spec=testing_app_puya_arc32_app_spec,
176+
default_sender=funded_account.address,
207177
)
178+
app_client, _ = factory.send.bare.create()
179+
return app_client
208180

209181

210182
def test_clone_overriding_default_sender_and_inheriting_app_name(
@@ -709,6 +681,29 @@ def test_box_methods_with_arc4_returns_parametrized(
709681
assert abi_decoded_boxes[0].value == arg_value
710682

711683

684+
@pytest.mark.parametrize(
685+
"populate",
686+
[
687+
True,
688+
# False, # enable this test once rejected transactions contain pc information
689+
],
690+
)
691+
def test_txn_with_reject(test_app_client_puya: AppClient, *, populate: bool) -> None:
692+
with pytest.raises(LogicError, match="expect this txn to be rejected"):
693+
test_app_client_puya.send.call(
694+
AppClientMethodCallParams(method="rejected"), send_params=SendParams(populate_app_call_resources=populate)
695+
)
696+
697+
698+
@pytest.mark.parametrize("populate", [True, False])
699+
def test_txn_with_logic_err(test_app_client_puya: AppClient, *, populate: bool) -> None:
700+
with pytest.raises(LogicError, match="expect this to be a logic err") as exc:
701+
test_app_client_puya.send.call(
702+
AppClientMethodCallParams(method="logic_err"), send_params=SendParams(populate_app_call_resources=populate)
703+
)
704+
assert exc
705+
706+
712707
def test_abi_with_default_arg_method(
713708
algorand: AlgorandClient,
714709
funded_account: SigningAccount,

0 commit comments

Comments
 (0)