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