|
8 | 8 | import pytest |
9 | 9 | from algosdk.atomic_transaction_composer import TransactionSigner, TransactionWithSigner |
10 | 10 |
|
| 11 | +from algokit_utils import SendParams |
11 | 12 | from algokit_utils._legacy_v2.application_specification import ApplicationSpecification |
12 | 13 | from algokit_utils.algorand import AlgorandClient |
13 | 14 | from algokit_utils.applications.abi import ABIType |
@@ -166,45 +167,16 @@ def testing_app_puya_arc32_app_spec() -> ApplicationSpecification: |
166 | 167 | return ApplicationSpecification.from_json(raw_json_spec.read_text()) |
167 | 168 |
|
168 | 169 |
|
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 | | - |
192 | 170 | @pytest.fixture |
193 | 171 | 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 |
198 | 173 | ) -> 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, |
207 | 177 | ) |
| 178 | + app_client, _ = factory.send.bare.create() |
| 179 | + return app_client |
208 | 180 |
|
209 | 181 |
|
210 | 182 | def test_clone_overriding_default_sender_and_inheriting_app_name( |
@@ -709,6 +681,29 @@ def test_box_methods_with_arc4_returns_parametrized( |
709 | 681 | assert abi_decoded_boxes[0].value == arg_value |
710 | 682 |
|
711 | 683 |
|
| 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 | + |
712 | 707 | def test_abi_with_default_arg_method( |
713 | 708 | algorand: AlgorandClient, |
714 | 709 | funded_account: SigningAccount, |
|
0 commit comments