genlayer-test 0.5.0__py3-none-any.whl → 0.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {genlayer_test-0.5.0.dist-info → genlayer_test-0.6.0.dist-info}/METADATA +22 -3
- {genlayer_test-0.5.0.dist-info → genlayer_test-0.6.0.dist-info}/RECORD +18 -17
- gltest/contracts/contract.py +1 -1
- gltest/contracts/contract_factory.py +40 -29
- gltest/utils.py +14 -0
- tests/examples/contracts/intelligent_oracle_factory.py +1 -0
- tests/examples/contracts/invalid_deploy.py +10 -0
- tests/examples/contracts/multi_file_contract/__init__.py +1 -0
- tests/examples/contracts/multi_tenant_storage.py +3 -1
- tests/examples/tests/test_intelligent_oracle_factory.py +0 -2
- tests/examples/tests/test_invalid_deploy.py +24 -0
- tests/examples/tests/test_multi_file_contract.py +4 -5
- tests/examples/tests/test_multi_tenant_storage.py +6 -2
- tests/gltest/artifact/test_contract_definition.py +0 -36
- tests/examples/tests/test_multi_file_contract_legacy.py +0 -16
- tests/examples/tests/test_storage_legacy.py +0 -26
- {genlayer_test-0.5.0.dist-info → genlayer_test-0.6.0.dist-info}/WHEEL +0 -0
- {genlayer_test-0.5.0.dist-info → genlayer_test-0.6.0.dist-info}/entry_points.txt +0 -0
- {genlayer_test-0.5.0.dist-info → genlayer_test-0.6.0.dist-info}/licenses/LICENSE +0 -0
- {genlayer_test-0.5.0.dist-info → genlayer_test-0.6.0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: genlayer-test
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.6.0
|
4
4
|
Summary: GenLayer Testing Suite
|
5
5
|
Author: GenLayer
|
6
6
|
License-Expression: MIT
|
@@ -15,7 +15,7 @@ Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
16
16
|
Requires-Dist: pytest
|
17
17
|
Requires-Dist: setuptools>=77.0
|
18
|
-
Requires-Dist: genlayer-py==0.
|
18
|
+
Requires-Dist: genlayer-py==0.8.1
|
19
19
|
Requires-Dist: colorama>=0.4.6
|
20
20
|
Requires-Dist: pyyaml
|
21
21
|
Requires-Dist: python-dotenv
|
@@ -365,17 +365,24 @@ Key features demonstrated in this contract:
|
|
365
365
|
|
366
366
|
### Contract Deployment
|
367
367
|
|
368
|
+
The GenLayer Testing Suite provides two methods for deploying contracts:
|
369
|
+
|
370
|
+
1. **`deploy()`** - Returns the deployed contract instance (recommended for most use cases)
|
371
|
+
2. **`deploy_contract_tx()`** - Returns only the transaction receipt
|
372
|
+
|
368
373
|
Here's how to deploy the Storage contract:
|
369
374
|
|
370
375
|
```python
|
371
376
|
from gltest import get_contract_factory, get_default_account
|
377
|
+
from gltest.assertions import tx_execution_succeeded
|
378
|
+
from gltest.utils import extract_contract_address
|
372
379
|
|
373
380
|
def test_deployment():
|
374
381
|
# Get the contract factory for your contract
|
375
382
|
# it will search in the contracts directory
|
376
383
|
factory = get_contract_factory("Storage")
|
377
384
|
|
378
|
-
# Deploy the contract with constructor arguments
|
385
|
+
# Method 1: Deploy the contract with constructor arguments (recommended)
|
379
386
|
contract = factory.deploy(
|
380
387
|
args=["initial_value"], # Constructor arguments
|
381
388
|
account=get_default_account(), # Account to deploy from
|
@@ -384,6 +391,18 @@ def test_deployment():
|
|
384
391
|
|
385
392
|
# Contract is now deployed and ready to use
|
386
393
|
assert contract.address is not None
|
394
|
+
|
395
|
+
# Method 2: Deploy and get only the receipt
|
396
|
+
receipt = factory.deploy_contract_tx(
|
397
|
+
args=["initial_value"],
|
398
|
+
account=get_default_account(),
|
399
|
+
)
|
400
|
+
|
401
|
+
# Verify deployment succeeded
|
402
|
+
assert tx_execution_succeeded(receipt)
|
403
|
+
|
404
|
+
# Get the contract address
|
405
|
+
contract_address = extract_contract_address(receipt)
|
387
406
|
```
|
388
407
|
|
389
408
|
### Read Methods
|
@@ -1,4 +1,4 @@
|
|
1
|
-
genlayer_test-0.
|
1
|
+
genlayer_test-0.6.0.dist-info/licenses/LICENSE,sha256=che_H4vE0QUx3HvWrAa1_jDEVInift0U6VO15-QqEls,1064
|
2
2
|
gltest/__init__.py,sha256=qoBV3IgDJr8uh9262XsWNMhi-ilkSgMqKVC9FVMk7cw,372
|
3
3
|
gltest/accounts.py,sha256=HUmWguJMolggQaZNRPw-LGlRlQCjLLdUanKRowMv6pI,812
|
4
4
|
gltest/assertions.py,sha256=0dEk0VxcHK4I7GZPHxJmz-2jaA60V499gOSR74rZbfM,1748
|
@@ -7,11 +7,12 @@ gltest/exceptions.py,sha256=deJPmrTe5gF33qkkKF2IVJY7lc_knI7Ql3N7jZ8aLZs,510
|
|
7
7
|
gltest/fixtures.py,sha256=EJXmqcC3LD03v07mepacFl58lAdhbLj6bP5rtALYISk,2507
|
8
8
|
gltest/logging.py,sha256=jAkHsuMm-AEx1Xu1srU6W-0YzTwXJB48mCK-OVzAiN4,342
|
9
9
|
gltest/types.py,sha256=Kj6UuTpRXkA4c5ystKfwgXuCiRJ1VMkbgvP7Auvznhw,184
|
10
|
+
gltest/utils.py,sha256=-gHhjrS7i_GhDG3sKOq2qsTtYBt4HHgXHEXh-3RB_rI,573
|
10
11
|
gltest/artifacts/__init__.py,sha256=qTt3TE19gVNWnQLUlt5aDe4nNvJ2YJ1jzDkMmYIsCG0,194
|
11
12
|
gltest/artifacts/contract.py,sha256=KChpmfjZod_0dVB8y-dvWz6IVm7QlIJsgG2ArtvVDaU,6457
|
12
13
|
gltest/contracts/__init__.py,sha256=A9bvEtYOoqoHS8TLlFBfmNOnfwdsJPEf-AZuikagCHM,166
|
13
|
-
gltest/contracts/contract.py,sha256=
|
14
|
-
gltest/contracts/contract_factory.py,sha256
|
14
|
+
gltest/contracts/contract.py,sha256=hYuugaV_gNFk58mGyLRPKkKVKIjsCDlVpKLvwRBf7sM,6743
|
15
|
+
gltest/contracts/contract_factory.py,sha256=SCmhp2DRfD8FRejOqa6-_UF-yJaJr0ShB9lDkLLBzU0,8264
|
15
16
|
gltest/contracts/contract_functions.py,sha256=5gNQYzN47rCJtmcMtUkl4ZK-yDifdZup2YhtlFlrx7E,2203
|
16
17
|
gltest/contracts/method_stats.py,sha256=zWWjvf7K5VC4yrHpDIR717VF7LYp1RaZ1Hr_RZvWxJA,5150
|
17
18
|
gltest/contracts/stats_collector.py,sha256=fuCc8L8hd0tsVGzH4adtZWwPa7ORf0A0zR5Dt1w92Qk,9033
|
@@ -32,34 +33,34 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
33
|
tests/conftest.py,sha256=RKdoE5_zcMimeojAoA_GSFI9du4pMzMi1vZ1njtfoAs,28
|
33
34
|
tests/examples/contracts/football_prediction_market.py,sha256=9xwU8f3q73Hae-ByHy_wauhMPLRnLZd4XKNrClnjOJM,3248
|
34
35
|
tests/examples/contracts/intelligent_oracle.py,sha256=cZNGbjKMXY-pimVmPIKIlS963Gd3L1JAipq0VBR1J5Q,12360
|
35
|
-
tests/examples/contracts/intelligent_oracle_factory.py,sha256=
|
36
|
+
tests/examples/contracts/intelligent_oracle_factory.py,sha256=6UApEdPzcUXR18wMpaQXtWpEKeQjU0zDkI5ezghuJUo,1526
|
37
|
+
tests/examples/contracts/invalid_deploy.py,sha256=cHXV0aq8gfbWdvjchnjSeoZDCCC-5iNdLGUkJi-tQfo,228
|
36
38
|
tests/examples/contracts/llm_erc20.py,sha256=pOvSUszCtC_f5yDX0tZnj494Ce10uESZ09JLLE8V67o,2534
|
37
39
|
tests/examples/contracts/log_indexer.py,sha256=Nlf8XUt13ujam3k6hbbVrPHK-KJ366Csz1TBjc4P07g,1901
|
38
40
|
tests/examples/contracts/multi_read_erc20.py,sha256=28qYqn191Ro3rP7YJtZwL6Sc7JDXTeh8_QoqvdVPdqM,864
|
39
|
-
tests/examples/contracts/multi_tenant_storage.py,sha256=
|
41
|
+
tests/examples/contracts/multi_tenant_storage.py,sha256=ceq3X4E7pkvSdy7eQMhAoHme4KFedjAcpkfUYBmcgVM,1941
|
40
42
|
tests/examples/contracts/read_erc20.py,sha256=RgH269F0x482WuLLYcacBnZsGJjhgJp6sG_33cV6Z-w,454
|
41
43
|
tests/examples/contracts/storage.py,sha256=3DD3qvzb0JkVcBtu240e5kaZWgkh-bu6YExqBUYvfaw,501
|
42
44
|
tests/examples/contracts/user_storage.py,sha256=2W2Iv-hQZMkAaPl2RY_F-OeJpD4IlPxgWzN6e1bTkKE,649
|
43
45
|
tests/examples/contracts/wizard_of_coin.py,sha256=Y8daPpoSKdM8wfbCPOIgEdpkLIA1ZMmeg6Hu5fBB-kU,1624
|
44
|
-
tests/examples/contracts/multi_file_contract/__init__.py,sha256=
|
46
|
+
tests/examples/contracts/multi_file_contract/__init__.py,sha256=xDn_wS62GhCmnYoI6xIqlic2i882SoPnR2TEauKc9tQ,575
|
45
47
|
tests/examples/contracts/multi_file_contract/other.py,sha256=jHDtjUL3eAUgE6yOYKFw_RfAH7kIwk8CvxUjbWHNruk,236
|
46
48
|
tests/examples/tests/test_football_prediction_market.py,sha256=f2hfDK76WrNJZtFkTPKoPRR6bkmFLEssnlwwltSnU9A,1111
|
47
|
-
tests/examples/tests/test_intelligent_oracle_factory.py,sha256=
|
49
|
+
tests/examples/tests/test_intelligent_oracle_factory.py,sha256=sL26aeb84XpJPCSUSIX3yrbwQE8GZtvNcsaKTpngFmY,7611
|
50
|
+
tests/examples/tests/test_invalid_deploy.py,sha256=pppM8_Vn4DXcWq9iyJXb0SpZnKXkIyJxoIDW5ApCS94,814
|
48
51
|
tests/examples/tests/test_llm_erc20.py,sha256=zb5F_7NgvZXhvqL2nULwzuTT6LGDprSy0WgrdjY7pZc,2096
|
49
52
|
tests/examples/tests/test_llm_erc20_analyze.py,sha256=ccWQenEOG-U4TJdu-0i-3qNM4xRRCHSr3Iwz7pxknws,1729
|
50
53
|
tests/examples/tests/test_log_indexer.py,sha256=46AqL7qquNc9GX2wxFxVcQXLqruMnPmxXl1yeB0-KZ4,2869
|
51
|
-
tests/examples/tests/test_multi_file_contract.py,sha256=
|
52
|
-
tests/examples/tests/test_multi_file_contract_legacy.py,sha256=UTI7Thc8Wg-lotH9JiB5hp9ba6O-yFy1Ss-yuhlgljA,584
|
54
|
+
tests/examples/tests/test_multi_file_contract.py,sha256=1Emj6ze4f-OrpxvqExeJhPHjK0cNAQW54MXf6fy2Yuc,469
|
53
55
|
tests/examples/tests/test_multi_read_erc20.py,sha256=pSZUxoB33Z2EBtcvXxfUgwGSi_h7ryPoovkiNIfNAVQ,3713
|
54
|
-
tests/examples/tests/test_multi_tenant_storage.py,sha256=
|
56
|
+
tests/examples/tests/test_multi_tenant_storage.py,sha256=8B3tjnRbT8ATN5obtWkGsN3nOtBU9OSjuaH9aEat3vc,2935
|
55
57
|
tests/examples/tests/test_read_erc20.py,sha256=vLGQwguaNnT497nSq-vt4LrXj4ehn5ZSgfPt0GVFoPc,1254
|
56
58
|
tests/examples/tests/test_storage.py,sha256=y46nPjM-Jd9FVJmaNE29RPqamzxVwYtPPWE_GlXUsls,774
|
57
|
-
tests/examples/tests/test_storage_legacy.py,sha256=STcoRKYP0JcwwNjFSTMpYGuOyXcw2DxGlemUivWp2B0,755
|
58
59
|
tests/examples/tests/test_user_storage.py,sha256=wk0r0AXfKNgI7Eeyc8noNlJKvZBFXDbXTQE_u19XxBQ,2927
|
59
60
|
tests/examples/tests/test_wizard_of_coin.py,sha256=AOQTanDsfZt9zIGkqZass_4BsGcVKTHzqRejN4KhSPI,854
|
60
61
|
tests/gltest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
61
62
|
tests/gltest/artifact/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
62
|
-
tests/gltest/artifact/test_contract_definition.py,sha256=
|
63
|
+
tests/gltest/artifact/test_contract_definition.py,sha256=riNNZ5Bu18zn5yuKXvJ5djRDmBNsFZTT0sdw9vX4Js8,2066
|
63
64
|
tests/gltest/artifact/contracts/duplicate_ic_contract_1.py,sha256=bSWsUVjBy5cGtI72cjnkstsMzuUJbB3IG5JjTxOF-dc,500
|
64
65
|
tests/gltest/artifact/contracts/duplicate_ic_contract_2.py,sha256=bSWsUVjBy5cGtI72cjnkstsMzuUJbB3IG5JjTxOF-dc,500
|
65
66
|
tests/gltest/artifact/contracts/not_ic_contract.py,sha256=hQyGnYiiVceYdLI2WrvcFgPqzy1S4-YMb9FPhiHEGSA,510
|
@@ -69,8 +70,8 @@ tests/gltest_cli/config/test_config_integration.py,sha256=vPTzr3_h9UMw7m72HogBJE
|
|
69
70
|
tests/gltest_cli/config/test_general_config.py,sha256=UHtSwVnso-ZwNtYM0Z4v2sCLKwyrVbHlk6b1leVfV84,14703
|
70
71
|
tests/gltest_cli/config/test_plugin.py,sha256=COrEK5tHP1BSzanWbZHmN3EQgE9VuTcPvB95pgOvKS4,7974
|
71
72
|
tests/gltest_cli/config/test_user.py,sha256=JxR655oUFoM9quWQO68CVPKRpT0TMpzS3bF6j6NWyT4,14401
|
72
|
-
genlayer_test-0.
|
73
|
-
genlayer_test-0.
|
74
|
-
genlayer_test-0.
|
75
|
-
genlayer_test-0.
|
76
|
-
genlayer_test-0.
|
73
|
+
genlayer_test-0.6.0.dist-info/METADATA,sha256=uHgafSUvII1G16UbdZ-26QwmtaV86EX1Pk-VwXsZAxs,32466
|
74
|
+
genlayer_test-0.6.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
75
|
+
genlayer_test-0.6.0.dist-info/entry_points.txt,sha256=RWPcSArBpz_G4BYioh5L8Q8hyClRbSgzLimjcWMp-BQ,94
|
76
|
+
genlayer_test-0.6.0.dist-info/top_level.txt,sha256=-qiGZxTRBytujzgVcKpxjvQ-WNeUDjXa59ceGMwMpko,24
|
77
|
+
genlayer_test-0.6.0.dist-info/RECORD,,
|
gltest/contracts/contract.py
CHANGED
@@ -96,7 +96,7 @@ def write_contract_wrapper(
|
|
96
96
|
retries=actual_wait_retries,
|
97
97
|
)
|
98
98
|
if wait_triggered_transactions:
|
99
|
-
triggered_transactions = receipt
|
99
|
+
triggered_transactions = receipt.get("triggered_transactions", [])
|
100
100
|
for triggered_transaction in triggered_transactions:
|
101
101
|
client.wait_for_transaction_receipt(
|
102
102
|
transaction_hash=triggered_transaction,
|
@@ -17,10 +17,11 @@ from gltest.clients import (
|
|
17
17
|
)
|
18
18
|
from .contract import Contract
|
19
19
|
from gltest.logging import logger
|
20
|
-
from gltest.types import TransactionStatus
|
20
|
+
from gltest.types import TransactionStatus, GenLayerTransaction, CalldataEncodable
|
21
21
|
from gltest.assertions import tx_execution_failed
|
22
22
|
from gltest.exceptions import DeploymentError
|
23
23
|
from gltest_cli.config.general import get_general_config
|
24
|
+
from gltest.utils import extract_contract_address
|
24
25
|
|
25
26
|
|
26
27
|
@dataclass
|
@@ -104,7 +105,7 @@ class ContractFactory:
|
|
104
105
|
|
105
106
|
def deploy(
|
106
107
|
self,
|
107
|
-
args: List[
|
108
|
+
args: Optional[List[CalldataEncodable]] = None,
|
108
109
|
account: Optional[LocalAccount] = None,
|
109
110
|
consensus_max_rotations: Optional[int] = None,
|
110
111
|
wait_interval: Optional[int] = None,
|
@@ -114,7 +115,41 @@ class ContractFactory:
|
|
114
115
|
wait_triggered_transactions_status: TransactionStatus = TransactionStatus.ACCEPTED,
|
115
116
|
) -> Contract:
|
116
117
|
"""
|
117
|
-
Deploy the contract
|
118
|
+
Deploy the contract and return a Contract instance (convenience method).
|
119
|
+
|
120
|
+
This is a convenience method that handles receipt validation
|
121
|
+
and contract instantiation automatically.
|
122
|
+
"""
|
123
|
+
receipt = self.deploy_contract_tx(
|
124
|
+
args=args,
|
125
|
+
account=account,
|
126
|
+
consensus_max_rotations=consensus_max_rotations,
|
127
|
+
wait_interval=wait_interval,
|
128
|
+
wait_retries=wait_retries,
|
129
|
+
wait_transaction_status=wait_transaction_status,
|
130
|
+
wait_triggered_transactions=wait_triggered_transactions,
|
131
|
+
wait_triggered_transactions_status=wait_triggered_transactions_status,
|
132
|
+
)
|
133
|
+
|
134
|
+
if tx_execution_failed(receipt):
|
135
|
+
raise DeploymentError(f"Deployment transaction failed: {receipt}")
|
136
|
+
|
137
|
+
contract_address = extract_contract_address(receipt)
|
138
|
+
return self.build_contract(contract_address=contract_address, account=account)
|
139
|
+
|
140
|
+
def deploy_contract_tx(
|
141
|
+
self,
|
142
|
+
args: Optional[List[CalldataEncodable]] = None,
|
143
|
+
account: Optional[LocalAccount] = None,
|
144
|
+
consensus_max_rotations: Optional[int] = None,
|
145
|
+
wait_interval: Optional[int] = None,
|
146
|
+
wait_retries: Optional[int] = None,
|
147
|
+
wait_transaction_status: TransactionStatus = TransactionStatus.ACCEPTED,
|
148
|
+
wait_triggered_transactions: bool = False,
|
149
|
+
wait_triggered_transactions_status: TransactionStatus = TransactionStatus.ACCEPTED,
|
150
|
+
) -> GenLayerTransaction:
|
151
|
+
"""
|
152
|
+
Deploy the contract and return the transaction receipt.
|
118
153
|
"""
|
119
154
|
general_config = get_general_config()
|
120
155
|
actual_wait_interval = (
|
@@ -148,13 +183,8 @@ class ContractFactory:
|
|
148
183
|
interval=actual_wait_interval,
|
149
184
|
retries=actual_wait_retries,
|
150
185
|
)
|
151
|
-
if tx_execution_failed(tx_receipt):
|
152
|
-
raise ValueError(
|
153
|
-
f"Deployment transaction finalized with error: {tx_receipt}"
|
154
|
-
)
|
155
|
-
|
156
186
|
if wait_triggered_transactions:
|
157
|
-
triggered_transactions = tx_receipt
|
187
|
+
triggered_transactions = tx_receipt.get("triggered_transactions", [])
|
158
188
|
for triggered_transaction in triggered_transactions:
|
159
189
|
client.wait_for_transaction_receipt(
|
160
190
|
transaction_hash=triggered_transaction,
|
@@ -162,26 +192,7 @@ class ContractFactory:
|
|
162
192
|
interval=actual_wait_interval,
|
163
193
|
retries=actual_wait_retries,
|
164
194
|
)
|
165
|
-
|
166
|
-
if (
|
167
|
-
"tx_data_decoded" in tx_receipt
|
168
|
-
and "contract_address" in tx_receipt["tx_data_decoded"]
|
169
|
-
):
|
170
|
-
contract_address = tx_receipt["tx_data_decoded"]["contract_address"]
|
171
|
-
elif "data" in tx_receipt and "contract_address" in tx_receipt["data"]:
|
172
|
-
contract_address = tx_receipt["data"]["contract_address"]
|
173
|
-
else:
|
174
|
-
raise ValueError("Transaction receipt missing contract address")
|
175
|
-
|
176
|
-
schema = self._get_schema_with_fallback()
|
177
|
-
if schema is None:
|
178
|
-
raise ValueError(
|
179
|
-
"Failed to get schema from all clients (default, hosted studio, and local)"
|
180
|
-
)
|
181
|
-
|
182
|
-
return Contract.new(
|
183
|
-
address=contract_address, schema=schema, account=account
|
184
|
-
)
|
195
|
+
return tx_receipt
|
185
196
|
except Exception as e:
|
186
197
|
raise DeploymentError(
|
187
198
|
f"Failed to deploy contract {self.contract_name}: {str(e)}"
|
gltest/utils.py
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
from genlayer_py.types import GenLayerTransaction
|
2
|
+
|
3
|
+
|
4
|
+
def extract_contract_address(receipt: GenLayerTransaction) -> str:
|
5
|
+
"""Extract contract address from a deployment transaction receipt."""
|
6
|
+
if (
|
7
|
+
"tx_data_decoded" in receipt
|
8
|
+
and "contract_address" in receipt["tx_data_decoded"]
|
9
|
+
):
|
10
|
+
return receipt["tx_data_decoded"]["contract_address"]
|
11
|
+
elif "data" in receipt and "contract_address" in receipt["data"]:
|
12
|
+
return receipt["data"]["contract_address"]
|
13
|
+
else:
|
14
|
+
raise ValueError("Transaction receipt missing contract address")
|
@@ -46,4 +46,6 @@ class MultiTentantStorage(gl.Contract):
|
|
46
46
|
self.available_storage_contracts.pop()
|
47
47
|
|
48
48
|
contract_to_use = self.mappings[gl.message.sender_address]
|
49
|
-
gl.get_contract_at(contract_to_use).emit().update_storage(
|
49
|
+
gl.get_contract_at(contract_to_use).emit(on="accepted").update_storage(
|
50
|
+
new_storage
|
51
|
+
)
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import json
|
2
|
-
from gltest.types import TransactionStatus
|
3
2
|
|
4
3
|
from gltest import get_contract_factory
|
5
4
|
from gltest.assertions import tx_execution_succeeded
|
@@ -112,7 +111,6 @@ def test_intelligent_oracle_factory_pattern(setup_validators):
|
|
112
111
|
],
|
113
112
|
).transact(
|
114
113
|
wait_triggered_transactions=True,
|
115
|
-
wait_triggered_transactions_status=TransactionStatus.ACCEPTED,
|
116
114
|
)
|
117
115
|
assert tx_execution_succeeded(create_result)
|
118
116
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import pytest
|
2
|
+
from gltest import get_contract_factory
|
3
|
+
from gltest.assertions import tx_execution_failed
|
4
|
+
from gltest.exceptions import DeploymentError
|
5
|
+
|
6
|
+
|
7
|
+
def test_invalid_deploy_basic_exception(setup_validators):
|
8
|
+
"""Test deployment failure with basic exception"""
|
9
|
+
setup_validators()
|
10
|
+
factory = get_contract_factory("InvalidDeploy")
|
11
|
+
|
12
|
+
# Deployment should fail with exception
|
13
|
+
with pytest.raises(DeploymentError):
|
14
|
+
factory.deploy()
|
15
|
+
|
16
|
+
|
17
|
+
def test_invalid_deploy_receipt_only(setup_validators):
|
18
|
+
"""Test deployment failure using deploy_contract_tx() method that returns receipt only"""
|
19
|
+
setup_validators()
|
20
|
+
factory = get_contract_factory("InvalidDeploy")
|
21
|
+
|
22
|
+
# Deploy and get receipt - should show failure
|
23
|
+
receipt = factory.deploy_contract_tx()
|
24
|
+
assert tx_execution_failed(receipt)
|
@@ -1,5 +1,4 @@
|
|
1
1
|
from gltest import get_contract_factory
|
2
|
-
from gltest.assertions import tx_execution_succeeded
|
3
2
|
|
4
3
|
|
5
4
|
def test_multi_file_contract(setup_validators):
|
@@ -7,10 +6,10 @@ def test_multi_file_contract(setup_validators):
|
|
7
6
|
# Deploy Contract, it will deploy other.py as well
|
8
7
|
setup_validators()
|
9
8
|
factory = get_contract_factory("MultiFileContract")
|
10
|
-
contract = factory.deploy(
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
contract = factory.deploy(
|
10
|
+
args=[],
|
11
|
+
wait_triggered_transactions=True,
|
12
|
+
)
|
14
13
|
|
15
14
|
res = contract.test(args=[]).call()
|
16
15
|
assert res == "123"
|
@@ -51,7 +51,9 @@ def test_multi_tenant_storage(setup_validators):
|
|
51
51
|
transaction_response_call = (
|
52
52
|
multi_tenant_storage_contract.connect(account=user_account_a)
|
53
53
|
.update_storage(args=["user_a_storage"])
|
54
|
-
.transact(
|
54
|
+
.transact(
|
55
|
+
wait_triggered_transactions=True,
|
56
|
+
)
|
55
57
|
)
|
56
58
|
assert tx_execution_succeeded(transaction_response_call)
|
57
59
|
|
@@ -59,7 +61,9 @@ def test_multi_tenant_storage(setup_validators):
|
|
59
61
|
transaction_response_call = (
|
60
62
|
multi_tenant_storage_contract.connect(account=user_account_b)
|
61
63
|
.update_storage(args=["user_b_storage"])
|
62
|
-
.transact(
|
64
|
+
.transact(
|
65
|
+
wait_triggered_transactions=True,
|
66
|
+
)
|
63
67
|
)
|
64
68
|
assert tx_execution_succeeded(transaction_response_call)
|
65
69
|
|
@@ -47,42 +47,6 @@ def test_multiple_files():
|
|
47
47
|
assert contract_definition.contract_code == contract_code
|
48
48
|
|
49
49
|
|
50
|
-
def test_single_file_legacy():
|
51
|
-
general_config = get_general_config()
|
52
|
-
general_config.set_contracts_dir(Path("."))
|
53
|
-
contract_definition = find_contract_definition_from_name("StorageLegacy")
|
54
|
-
|
55
|
-
# Assert complete contract definition
|
56
|
-
assert contract_definition.contract_name == "StorageLegacy"
|
57
|
-
expected_main_file_path = CONTRACTS_DIR / "storage_legacy.gpy"
|
58
|
-
expected_runner_file_path = None
|
59
|
-
contract_code = compute_contract_code(
|
60
|
-
expected_main_file_path, expected_runner_file_path
|
61
|
-
)
|
62
|
-
assert contract_definition.contract_code == contract_code
|
63
|
-
assert str(contract_definition.main_file_path) == str(
|
64
|
-
CONTRACTS_DIR / "storage_legacy.gpy"
|
65
|
-
)
|
66
|
-
assert contract_definition.runner_file_path is None
|
67
|
-
|
68
|
-
|
69
|
-
def test_multiple_files_legacy():
|
70
|
-
general_config = get_general_config()
|
71
|
-
general_config.set_contracts_dir(Path("."))
|
72
|
-
contract_definition = find_contract_definition_from_name("MultiFileContractLegacy")
|
73
|
-
|
74
|
-
# Assert complete contract definition
|
75
|
-
assert contract_definition.contract_name == "MultiFileContractLegacy"
|
76
|
-
expected_main_file_path = CONTRACTS_DIR / "multi_file_contract_legacy/__init__.gpy"
|
77
|
-
expected_runner_file_path = CONTRACTS_DIR / "multi_file_contract_legacy/runner.json"
|
78
|
-
assert contract_definition.main_file_path == expected_main_file_path
|
79
|
-
assert contract_definition.runner_file_path == expected_runner_file_path
|
80
|
-
contract_code = compute_contract_code(
|
81
|
-
expected_main_file_path, expected_runner_file_path
|
82
|
-
)
|
83
|
-
assert contract_definition.contract_code == contract_code
|
84
|
-
|
85
|
-
|
86
50
|
def test_class_is_not_intelligent_contract():
|
87
51
|
general_config = get_general_config()
|
88
52
|
general_config.set_contracts_dir(Path("."))
|
@@ -1,16 +0,0 @@
|
|
1
|
-
from gltest import get_contract_factory
|
2
|
-
from gltest.assertions import tx_execution_succeeded
|
3
|
-
|
4
|
-
|
5
|
-
def test_multi_file_contract_legacy(setup_validators):
|
6
|
-
# Multi file contracts are considered if they are defined in a __init__.gpy file
|
7
|
-
# Deploy Contract, it will deploy other.gpy as well
|
8
|
-
setup_validators()
|
9
|
-
factory = get_contract_factory("MultiFileContractLegacy")
|
10
|
-
contract = factory.deploy(args=[])
|
11
|
-
|
12
|
-
wait_response = contract.wait(args=[]).transact()
|
13
|
-
assert tx_execution_succeeded(wait_response)
|
14
|
-
|
15
|
-
res = contract.test(args=[]).call()
|
16
|
-
assert res == "123"
|
@@ -1,26 +0,0 @@
|
|
1
|
-
from gltest import get_contract_factory
|
2
|
-
from gltest.assertions import tx_execution_succeeded
|
3
|
-
|
4
|
-
|
5
|
-
INITIAL_STATE = "a"
|
6
|
-
UPDATED_STATE = "b"
|
7
|
-
|
8
|
-
|
9
|
-
def test_storage_legacy(setup_validators):
|
10
|
-
setup_validators()
|
11
|
-
factory = get_contract_factory("StorageLegacy")
|
12
|
-
contract = factory.deploy(args=[INITIAL_STATE])
|
13
|
-
|
14
|
-
# Get initial state
|
15
|
-
contract_state_1 = contract.get_storage(args=[]).call()
|
16
|
-
assert contract_state_1 == INITIAL_STATE
|
17
|
-
|
18
|
-
# Update State
|
19
|
-
transaction_response_call_1 = contract.update_storage(
|
20
|
-
args=[UPDATED_STATE]
|
21
|
-
).transact()
|
22
|
-
assert tx_execution_succeeded(transaction_response_call_1)
|
23
|
-
|
24
|
-
# Get Updated State
|
25
|
-
contract_state_2 = contract.get_storage(args=[]).call()
|
26
|
-
assert contract_state_2 == UPDATED_STATE
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|