genlayer-test 0.5.0__tar.gz → 0.6.0__tar.gz

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.
Files changed (84) hide show
  1. {genlayer_test-0.5.0/genlayer_test.egg-info → genlayer_test-0.6.0}/PKG-INFO +22 -3
  2. genlayer_test-0.5.0/PKG-INFO → genlayer_test-0.6.0/README.md +20 -24
  3. genlayer_test-0.5.0/README.md → genlayer_test-0.6.0/genlayer_test.egg-info/PKG-INFO +43 -1
  4. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/genlayer_test.egg-info/SOURCES.txt +3 -2
  5. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/genlayer_test.egg-info/requires.txt +1 -1
  6. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/contracts/contract.py +1 -1
  7. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/contracts/contract_factory.py +40 -29
  8. genlayer_test-0.6.0/gltest/utils.py +14 -0
  9. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/pyproject.toml +2 -2
  10. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/intelligent_oracle_factory.py +1 -0
  11. genlayer_test-0.6.0/tests/examples/contracts/invalid_deploy.py +10 -0
  12. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/multi_file_contract/__init__.py +1 -0
  13. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/multi_tenant_storage.py +3 -1
  14. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_intelligent_oracle_factory.py +0 -2
  15. genlayer_test-0.6.0/tests/examples/tests/test_invalid_deploy.py +24 -0
  16. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_multi_file_contract.py +4 -5
  17. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_multi_tenant_storage.py +6 -2
  18. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest/artifact/test_contract_definition.py +0 -36
  19. genlayer_test-0.5.0/tests/examples/tests/test_multi_file_contract_legacy.py +0 -16
  20. genlayer_test-0.5.0/tests/examples/tests/test_storage_legacy.py +0 -26
  21. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/LICENSE +0 -0
  22. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/genlayer_test.egg-info/dependency_links.txt +0 -0
  23. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/genlayer_test.egg-info/entry_points.txt +0 -0
  24. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/genlayer_test.egg-info/top_level.txt +0 -0
  25. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/__init__.py +0 -0
  26. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/accounts.py +0 -0
  27. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/artifacts/__init__.py +0 -0
  28. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/artifacts/contract.py +0 -0
  29. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/assertions.py +0 -0
  30. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/clients.py +0 -0
  31. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/contracts/__init__.py +0 -0
  32. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/contracts/contract_functions.py +0 -0
  33. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/contracts/method_stats.py +0 -0
  34. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/contracts/stats_collector.py +0 -0
  35. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/contracts/utils.py +0 -0
  36. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/exceptions.py +0 -0
  37. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/fixtures.py +0 -0
  38. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/helpers/__init__.py +0 -0
  39. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/helpers/fixture_snapshot.py +0 -0
  40. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/helpers/take_snapshot.py +0 -0
  41. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/logging.py +0 -0
  42. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest/types.py +0 -0
  43. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest_cli/config/__init__.py +0 -0
  44. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest_cli/config/constants.py +0 -0
  45. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest_cli/config/general.py +0 -0
  46. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest_cli/config/plugin.py +0 -0
  47. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest_cli/config/pytest_context.py +0 -0
  48. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest_cli/config/types.py +0 -0
  49. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest_cli/config/user.py +0 -0
  50. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest_cli/logging.py +0 -0
  51. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/gltest_cli/main.py +0 -0
  52. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/setup.cfg +0 -0
  53. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/__init__.py +0 -0
  54. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/conftest.py +0 -0
  55. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/football_prediction_market.py +0 -0
  56. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/intelligent_oracle.py +0 -0
  57. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/llm_erc20.py +0 -0
  58. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/log_indexer.py +0 -0
  59. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/multi_file_contract/other.py +0 -0
  60. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/multi_read_erc20.py +0 -0
  61. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/read_erc20.py +0 -0
  62. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/storage.py +0 -0
  63. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/user_storage.py +0 -0
  64. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/contracts/wizard_of_coin.py +0 -0
  65. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_football_prediction_market.py +0 -0
  66. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_llm_erc20.py +0 -0
  67. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_llm_erc20_analyze.py +0 -0
  68. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_log_indexer.py +0 -0
  69. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_multi_read_erc20.py +0 -0
  70. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_read_erc20.py +0 -0
  71. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_storage.py +0 -0
  72. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_user_storage.py +0 -0
  73. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/examples/tests/test_wizard_of_coin.py +0 -0
  74. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest/__init__.py +0 -0
  75. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest/artifact/__init__.py +0 -0
  76. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest/artifact/contracts/duplicate_ic_contract_1.py +0 -0
  77. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest/artifact/contracts/duplicate_ic_contract_2.py +0 -0
  78. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest/artifact/contracts/not_ic_contract.py +0 -0
  79. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest/assertions/test_assertions.py +0 -0
  80. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest_cli/__init__.py +0 -0
  81. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest_cli/config/test_config_integration.py +0 -0
  82. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest_cli/config/test_general_config.py +0 -0
  83. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest_cli/config/test_plugin.py +0 -0
  84. {genlayer_test-0.5.0 → genlayer_test-0.6.0}/tests/gltest_cli/config/test_user.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: genlayer-test
3
- Version: 0.5.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.7.2
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,26 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: genlayer-test
3
- Version: 0.5.0
4
- Summary: GenLayer Testing Suite
5
- Author: GenLayer
6
- License-Expression: MIT
7
- Classifier: Development Status :: 4 - Beta
8
- Classifier: Intended Audience :: Developers
9
- Classifier: Programming Language :: Python :: 3
10
- Classifier: Programming Language :: Python :: 3.12
11
- Classifier: Programming Language :: Python :: 3.13
12
- Classifier: Topic :: Software Development :: Testing
13
- Requires-Python: >=3.12
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
- Requires-Dist: pytest
17
- Requires-Dist: setuptools>=77.0
18
- Requires-Dist: genlayer-py==0.7.2
19
- Requires-Dist: colorama>=0.4.6
20
- Requires-Dist: pyyaml
21
- Requires-Dist: python-dotenv
22
- Dynamic: license-file
23
-
24
1
  # GenLayer Testing Suite
25
2
 
26
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)
@@ -365,17 +342,24 @@ Key features demonstrated in this contract:
365
342
 
366
343
  ### Contract Deployment
367
344
 
345
+ The GenLayer Testing Suite provides two methods for deploying contracts:
346
+
347
+ 1. **`deploy()`** - Returns the deployed contract instance (recommended for most use cases)
348
+ 2. **`deploy_contract_tx()`** - Returns only the transaction receipt
349
+
368
350
  Here's how to deploy the Storage contract:
369
351
 
370
352
  ```python
371
353
  from gltest import get_contract_factory, get_default_account
354
+ from gltest.assertions import tx_execution_succeeded
355
+ from gltest.utils import extract_contract_address
372
356
 
373
357
  def test_deployment():
374
358
  # Get the contract factory for your contract
375
359
  # it will search in the contracts directory
376
360
  factory = get_contract_factory("Storage")
377
361
 
378
- # Deploy the contract with constructor arguments
362
+ # Method 1: Deploy the contract with constructor arguments (recommended)
379
363
  contract = factory.deploy(
380
364
  args=["initial_value"], # Constructor arguments
381
365
  account=get_default_account(), # Account to deploy from
@@ -384,6 +368,18 @@ def test_deployment():
384
368
 
385
369
  # Contract is now deployed and ready to use
386
370
  assert contract.address is not None
371
+
372
+ # Method 2: Deploy and get only the receipt
373
+ receipt = factory.deploy_contract_tx(
374
+ args=["initial_value"],
375
+ account=get_default_account(),
376
+ )
377
+
378
+ # Verify deployment succeeded
379
+ assert tx_execution_succeeded(receipt)
380
+
381
+ # Get the contract address
382
+ contract_address = extract_contract_address(receipt)
387
383
  ```
388
384
 
389
385
  ### Read Methods
@@ -1,3 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: genlayer-test
3
+ Version: 0.6.0
4
+ Summary: GenLayer Testing Suite
5
+ Author: GenLayer
6
+ License-Expression: MIT
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Topic :: Software Development :: Testing
13
+ Requires-Python: >=3.12
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: pytest
17
+ Requires-Dist: setuptools>=77.0
18
+ Requires-Dist: genlayer-py==0.8.1
19
+ Requires-Dist: colorama>=0.4.6
20
+ Requires-Dist: pyyaml
21
+ Requires-Dist: python-dotenv
22
+ Dynamic: license-file
23
+
1
24
  # GenLayer Testing Suite
2
25
 
3
26
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)
@@ -342,17 +365,24 @@ Key features demonstrated in this contract:
342
365
 
343
366
  ### Contract Deployment
344
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
+
345
373
  Here's how to deploy the Storage contract:
346
374
 
347
375
  ```python
348
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
349
379
 
350
380
  def test_deployment():
351
381
  # Get the contract factory for your contract
352
382
  # it will search in the contracts directory
353
383
  factory = get_contract_factory("Storage")
354
384
 
355
- # Deploy the contract with constructor arguments
385
+ # Method 1: Deploy the contract with constructor arguments (recommended)
356
386
  contract = factory.deploy(
357
387
  args=["initial_value"], # Constructor arguments
358
388
  account=get_default_account(), # Account to deploy from
@@ -361,6 +391,18 @@ def test_deployment():
361
391
 
362
392
  # Contract is now deployed and ready to use
363
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)
364
406
  ```
365
407
 
366
408
  ### Read Methods
@@ -15,6 +15,7 @@ gltest/exceptions.py
15
15
  gltest/fixtures.py
16
16
  gltest/logging.py
17
17
  gltest/types.py
18
+ gltest/utils.py
18
19
  gltest/artifacts/__init__.py
19
20
  gltest/artifacts/contract.py
20
21
  gltest/contracts/__init__.py
@@ -41,6 +42,7 @@ tests/conftest.py
41
42
  tests/examples/contracts/football_prediction_market.py
42
43
  tests/examples/contracts/intelligent_oracle.py
43
44
  tests/examples/contracts/intelligent_oracle_factory.py
45
+ tests/examples/contracts/invalid_deploy.py
44
46
  tests/examples/contracts/llm_erc20.py
45
47
  tests/examples/contracts/log_indexer.py
46
48
  tests/examples/contracts/multi_read_erc20.py
@@ -53,16 +55,15 @@ tests/examples/contracts/multi_file_contract/__init__.py
53
55
  tests/examples/contracts/multi_file_contract/other.py
54
56
  tests/examples/tests/test_football_prediction_market.py
55
57
  tests/examples/tests/test_intelligent_oracle_factory.py
58
+ tests/examples/tests/test_invalid_deploy.py
56
59
  tests/examples/tests/test_llm_erc20.py
57
60
  tests/examples/tests/test_llm_erc20_analyze.py
58
61
  tests/examples/tests/test_log_indexer.py
59
62
  tests/examples/tests/test_multi_file_contract.py
60
- tests/examples/tests/test_multi_file_contract_legacy.py
61
63
  tests/examples/tests/test_multi_read_erc20.py
62
64
  tests/examples/tests/test_multi_tenant_storage.py
63
65
  tests/examples/tests/test_read_erc20.py
64
66
  tests/examples/tests/test_storage.py
65
- tests/examples/tests/test_storage_legacy.py
66
67
  tests/examples/tests/test_user_storage.py
67
68
  tests/examples/tests/test_wizard_of_coin.py
68
69
  tests/gltest/__init__.py
@@ -1,6 +1,6 @@
1
1
  pytest
2
2
  setuptools>=77.0
3
- genlayer-py==0.7.2
3
+ genlayer-py==0.8.1
4
4
  colorama>=0.4.6
5
5
  pyyaml
6
6
  python-dotenv
@@ -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["triggered_transactions"]
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[Any] = [],
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["triggered_transactions"]
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)}"
@@ -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")
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "genlayer-test"
7
- version = "0.5.0"
7
+ version = "0.6.0"
8
8
  description = "GenLayer Testing Suite"
9
9
  authors = [
10
10
  { name = "GenLayer" }
@@ -15,7 +15,7 @@ requires-python = ">=3.12"
15
15
  dependencies = [
16
16
  "pytest",
17
17
  "setuptools>=77.0",
18
- "genlayer-py==0.7.2",
18
+ "genlayer-py==0.8.1",
19
19
  "colorama>=0.4.6",
20
20
  "pyyaml",
21
21
  "python-dotenv"
@@ -38,6 +38,7 @@ class Registry(gl.Contract):
38
38
  earliest_resolution_date,
39
39
  ],
40
40
  salt_nonce=registered_contracts + 1,
41
+ on="accepted",
41
42
  )
42
43
  print("contract_address", contract_address)
43
44
  print("contract_address type", type(contract_address))
@@ -0,0 +1,10 @@
1
+ # { "Depends": "py-genlayer:test" }
2
+
3
+ import genlayer as gl
4
+
5
+
6
+ class InvalidDeploy(gl.Contract):
7
+ """Contract that always fails during deployment"""
8
+
9
+ def __init__(self):
10
+ raise Exception("This is an invalid deploy")
@@ -12,6 +12,7 @@ class MultiFileContract(gl.Contract):
12
12
  args=["123"],
13
13
  salt_nonce=u256(1),
14
14
  value=u256(0),
15
+ on="accepted",
15
16
  )
16
17
 
17
18
  @gl.public.write
@@ -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(new_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(args=[])
11
-
12
- wait_response = contract.wait(args=[]).transact()
13
- assert tx_execution_succeeded(wait_response)
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