genlayer-test 0.5.1__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 (82) hide show
  1. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/PKG-INFO +21 -2
  2. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/README.md +20 -1
  3. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/genlayer_test.egg-info/PKG-INFO +21 -2
  4. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/genlayer_test.egg-info/SOURCES.txt +3 -0
  5. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/contracts/contract_factory.py +39 -28
  6. genlayer_test-0.6.0/gltest/utils.py +14 -0
  7. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/pyproject.toml +1 -1
  8. genlayer_test-0.6.0/tests/examples/contracts/invalid_deploy.py +10 -0
  9. genlayer_test-0.6.0/tests/examples/tests/test_invalid_deploy.py +24 -0
  10. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/LICENSE +0 -0
  11. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/genlayer_test.egg-info/dependency_links.txt +0 -0
  12. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/genlayer_test.egg-info/entry_points.txt +0 -0
  13. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/genlayer_test.egg-info/requires.txt +0 -0
  14. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/genlayer_test.egg-info/top_level.txt +0 -0
  15. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/__init__.py +0 -0
  16. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/accounts.py +0 -0
  17. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/artifacts/__init__.py +0 -0
  18. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/artifacts/contract.py +0 -0
  19. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/assertions.py +0 -0
  20. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/clients.py +0 -0
  21. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/contracts/__init__.py +0 -0
  22. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/contracts/contract.py +0 -0
  23. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/contracts/contract_functions.py +0 -0
  24. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/contracts/method_stats.py +0 -0
  25. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/contracts/stats_collector.py +0 -0
  26. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/contracts/utils.py +0 -0
  27. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/exceptions.py +0 -0
  28. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/fixtures.py +0 -0
  29. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/helpers/__init__.py +0 -0
  30. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/helpers/fixture_snapshot.py +0 -0
  31. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/helpers/take_snapshot.py +0 -0
  32. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/logging.py +0 -0
  33. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest/types.py +0 -0
  34. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest_cli/config/__init__.py +0 -0
  35. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest_cli/config/constants.py +0 -0
  36. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest_cli/config/general.py +0 -0
  37. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest_cli/config/plugin.py +0 -0
  38. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest_cli/config/pytest_context.py +0 -0
  39. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest_cli/config/types.py +0 -0
  40. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest_cli/config/user.py +0 -0
  41. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest_cli/logging.py +0 -0
  42. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/gltest_cli/main.py +0 -0
  43. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/setup.cfg +0 -0
  44. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/__init__.py +0 -0
  45. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/conftest.py +0 -0
  46. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/football_prediction_market.py +0 -0
  47. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/intelligent_oracle.py +0 -0
  48. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/intelligent_oracle_factory.py +0 -0
  49. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/llm_erc20.py +0 -0
  50. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/log_indexer.py +0 -0
  51. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/multi_file_contract/__init__.py +0 -0
  52. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/multi_file_contract/other.py +0 -0
  53. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/multi_read_erc20.py +0 -0
  54. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/multi_tenant_storage.py +0 -0
  55. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/read_erc20.py +0 -0
  56. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/storage.py +0 -0
  57. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/user_storage.py +0 -0
  58. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/contracts/wizard_of_coin.py +0 -0
  59. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_football_prediction_market.py +0 -0
  60. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_intelligent_oracle_factory.py +0 -0
  61. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_llm_erc20.py +0 -0
  62. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_llm_erc20_analyze.py +0 -0
  63. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_log_indexer.py +0 -0
  64. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_multi_file_contract.py +0 -0
  65. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_multi_read_erc20.py +0 -0
  66. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_multi_tenant_storage.py +0 -0
  67. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_read_erc20.py +0 -0
  68. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_storage.py +0 -0
  69. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_user_storage.py +0 -0
  70. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/examples/tests/test_wizard_of_coin.py +0 -0
  71. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/gltest/__init__.py +0 -0
  72. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/gltest/artifact/__init__.py +0 -0
  73. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/gltest/artifact/contracts/duplicate_ic_contract_1.py +0 -0
  74. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/gltest/artifact/contracts/duplicate_ic_contract_2.py +0 -0
  75. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/gltest/artifact/contracts/not_ic_contract.py +0 -0
  76. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/gltest/artifact/test_contract_definition.py +0 -0
  77. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/gltest/assertions/test_assertions.py +0 -0
  78. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/gltest_cli/__init__.py +0 -0
  79. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/gltest_cli/config/test_config_integration.py +0 -0
  80. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/gltest_cli/config/test_general_config.py +0 -0
  81. {genlayer_test-0.5.1 → genlayer_test-0.6.0}/tests/gltest_cli/config/test_plugin.py +0 -0
  82. {genlayer_test-0.5.1 → 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.1
3
+ Version: 0.6.0
4
4
  Summary: GenLayer Testing Suite
5
5
  Author: GenLayer
6
6
  License-Expression: MIT
@@ -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
@@ -342,17 +342,24 @@ Key features demonstrated in this contract:
342
342
 
343
343
  ### Contract Deployment
344
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
+
345
350
  Here's how to deploy the Storage contract:
346
351
 
347
352
  ```python
348
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
349
356
 
350
357
  def test_deployment():
351
358
  # Get the contract factory for your contract
352
359
  # it will search in the contracts directory
353
360
  factory = get_contract_factory("Storage")
354
361
 
355
- # Deploy the contract with constructor arguments
362
+ # Method 1: Deploy the contract with constructor arguments (recommended)
356
363
  contract = factory.deploy(
357
364
  args=["initial_value"], # Constructor arguments
358
365
  account=get_default_account(), # Account to deploy from
@@ -361,6 +368,18 @@ def test_deployment():
361
368
 
362
369
  # Contract is now deployed and ready to use
363
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)
364
383
  ```
365
384
 
366
385
  ### Read Methods
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: genlayer-test
3
- Version: 0.5.1
3
+ Version: 0.6.0
4
4
  Summary: GenLayer Testing Suite
5
5
  Author: GenLayer
6
6
  License-Expression: MIT
@@ -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
@@ -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,6 +55,7 @@ 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
@@ -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,11 +183,6 @@ 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
187
  triggered_transactions = tx_receipt.get("triggered_transactions", [])
158
188
  for triggered_transaction in triggered_transactions:
@@ -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.1"
7
+ version = "0.6.0"
8
8
  description = "GenLayer Testing Suite"
9
9
  authors = [
10
10
  { name = "GenLayer" }
@@ -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")
@@ -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)
File without changes
File without changes