genlayer-test 0.8.0__tar.gz → 0.9.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 (88) hide show
  1. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/PKG-INFO +29 -2
  2. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/README.md +28 -1
  3. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/genlayer_test.egg-info/PKG-INFO +29 -2
  4. genlayer_test-0.9.0/genlayer_test.egg-info/SOURCES.txt +41 -0
  5. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/genlayer_test.egg-info/top_level.txt +0 -2
  6. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest_cli/config/constants.py +7 -0
  7. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest_cli/config/plugin.py +22 -4
  8. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest_cli/config/types.py +81 -46
  9. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest_cli/config/user.py +95 -7
  10. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/pyproject.toml +2 -1
  11. genlayer_test-0.8.0/genlayer_test.egg-info/SOURCES.txt +0 -85
  12. genlayer_test-0.8.0/tests/__init__.py +0 -0
  13. genlayer_test-0.8.0/tests/conftest.py +0 -1
  14. genlayer_test-0.8.0/tests/examples/contracts/football_prediction_market.py +0 -100
  15. genlayer_test-0.8.0/tests/examples/contracts/intelligent_oracle.py +0 -370
  16. genlayer_test-0.8.0/tests/examples/contracts/intelligent_oracle_factory.py +0 -49
  17. genlayer_test-0.8.0/tests/examples/contracts/invalid_deploy.py +0 -10
  18. genlayer_test-0.8.0/tests/examples/contracts/llm_erc20.py +0 -70
  19. genlayer_test-0.8.0/tests/examples/contracts/log_indexer.py +0 -69
  20. genlayer_test-0.8.0/tests/examples/contracts/multi_file_contract/__init__.py +0 -24
  21. genlayer_test-0.8.0/tests/examples/contracts/multi_file_contract/other.py +0 -14
  22. genlayer_test-0.8.0/tests/examples/contracts/multi_read_erc20.py +0 -29
  23. genlayer_test-0.8.0/tests/examples/contracts/multi_tenant_storage.py +0 -51
  24. genlayer_test-0.8.0/tests/examples/contracts/read_erc20.py +0 -19
  25. genlayer_test-0.8.0/tests/examples/contracts/simple_time_contract.py +0 -85
  26. genlayer_test-0.8.0/tests/examples/contracts/storage.py +0 -23
  27. genlayer_test-0.8.0/tests/examples/contracts/user_storage.py +0 -25
  28. genlayer_test-0.8.0/tests/examples/contracts/wizard_of_coin.py +0 -57
  29. genlayer_test-0.8.0/tests/examples/tests/test_custom_validators.py +0 -65
  30. genlayer_test-0.8.0/tests/examples/tests/test_football_prediction_market.py +0 -38
  31. genlayer_test-0.8.0/tests/examples/tests/test_intelligent_oracle_factory.py +0 -162
  32. genlayer_test-0.8.0/tests/examples/tests/test_invalid_deploy.py +0 -24
  33. genlayer_test-0.8.0/tests/examples/tests/test_llm_erc20.py +0 -60
  34. genlayer_test-0.8.0/tests/examples/tests/test_llm_erc20_analyze.py +0 -54
  35. genlayer_test-0.8.0/tests/examples/tests/test_log_indexer.py +0 -76
  36. genlayer_test-0.8.0/tests/examples/tests/test_multi_file_contract.py +0 -15
  37. genlayer_test-0.8.0/tests/examples/tests/test_multi_read_erc20.py +0 -103
  38. genlayer_test-0.8.0/tests/examples/tests/test_multi_tenant_storage.py +0 -76
  39. genlayer_test-0.8.0/tests/examples/tests/test_read_erc20.py +0 -38
  40. genlayer_test-0.8.0/tests/examples/tests/test_simple_time_contract.py +0 -90
  41. genlayer_test-0.8.0/tests/examples/tests/test_storage.py +0 -26
  42. genlayer_test-0.8.0/tests/examples/tests/test_user_storage.py +0 -87
  43. genlayer_test-0.8.0/tests/examples/tests/test_wizard_of_coin.py +0 -27
  44. genlayer_test-0.8.0/tests/gltest/__init__.py +0 -0
  45. genlayer_test-0.8.0/tests/gltest/artifact/__init__.py +0 -0
  46. genlayer_test-0.8.0/tests/gltest/artifact/contracts/duplicate_ic_contract_1.py +0 -22
  47. genlayer_test-0.8.0/tests/gltest/artifact/contracts/duplicate_ic_contract_2.py +0 -22
  48. genlayer_test-0.8.0/tests/gltest/artifact/contracts/not_ic_contract.py +0 -22
  49. genlayer_test-0.8.0/tests/gltest/artifact/test_contract_definition.py +0 -55
  50. genlayer_test-0.8.0/tests/gltest/assertions/test_assertions.py +0 -344
  51. genlayer_test-0.8.0/tests/gltest_cli/__init__.py +0 -0
  52. genlayer_test-0.8.0/tests/gltest_cli/config/test_config_integration.py +0 -432
  53. genlayer_test-0.8.0/tests/gltest_cli/config/test_general_config.py +0 -406
  54. genlayer_test-0.8.0/tests/gltest_cli/config/test_plugin.py +0 -290
  55. genlayer_test-0.8.0/tests/gltest_cli/config/test_user.py +0 -411
  56. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/LICENSE +0 -0
  57. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/genlayer_test.egg-info/dependency_links.txt +0 -0
  58. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/genlayer_test.egg-info/entry_points.txt +0 -0
  59. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/genlayer_test.egg-info/requires.txt +0 -0
  60. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/__init__.py +0 -0
  61. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/accounts.py +0 -0
  62. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/artifacts/__init__.py +0 -0
  63. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/artifacts/contract.py +0 -0
  64. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/assertions.py +0 -0
  65. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/clients.py +0 -0
  66. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/contracts/__init__.py +0 -0
  67. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/contracts/contract.py +0 -0
  68. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/contracts/contract_factory.py +0 -0
  69. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/contracts/contract_functions.py +0 -0
  70. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/contracts/method_stats.py +0 -0
  71. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/contracts/stats_collector.py +0 -0
  72. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/contracts/utils.py +0 -0
  73. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/exceptions.py +0 -0
  74. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/fixtures.py +0 -0
  75. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/helpers/__init__.py +0 -0
  76. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/helpers/fixture_snapshot.py +0 -0
  77. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/helpers/take_snapshot.py +0 -0
  78. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/logging.py +0 -0
  79. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/types.py +0 -0
  80. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/utils.py +0 -0
  81. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/validators/__init__.py +0 -0
  82. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest/validators/validator_factory.py +0 -0
  83. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest_cli/config/__init__.py +0 -0
  84. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest_cli/config/general.py +0 -0
  85. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest_cli/config/pytest_context.py +0 -0
  86. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest_cli/logging.py +0 -0
  87. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/gltest_cli/main.py +0 -0
  88. {genlayer_test-0.8.0 → genlayer_test-0.9.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: genlayer-test
3
- Version: 0.8.0
3
+ Version: 0.9.0
4
4
  Summary: GenLayer Testing Suite
5
5
  Author: GenLayer
6
6
  License-Expression: MIT
@@ -140,6 +140,7 @@ networks:
140
140
  custom_network: # Custom network configuration
141
141
  id: 1234
142
142
  url: "http://custom.network:8545"
143
+ chain_type: "localnet" # Required for custom networks: localnet, studionet, or testnet_asimov
143
144
  accounts:
144
145
  - "${CUSTOM_ACCOUNT_1}"
145
146
  - "${CUSTOM_ACCOUNT_2}"
@@ -163,10 +164,11 @@ Key configuration sections:
163
164
  - Network configurations can include:
164
165
  - `url`: The RPC endpoint for the network (optional for pre-configured networks)
165
166
  - `id`: Chain ID (optional for pre-configured networks)
167
+ - `chain_type`: Chain type - one of: `localnet`, `studionet`, or `testnet_asimov` (required for custom networks)
166
168
  - `accounts`: List of account private keys (using environment variables)
167
169
  - `from`: Specify which account to use as the default for transactions (optional, defaults to first account)
168
170
  - `leader_only`: Leader only mode
169
- - For custom networks (non-pre-configured), `id`, `url`, and `accounts` are required fields
171
+ - For custom networks (non-pre-configured), `id`, `url`, `chain_type`, and `accounts` are required fields
170
172
 
171
173
  **Note on Environment Variables**: When using environment variables in your configuration (e.g., `${ACCOUNT_PRIVATE_KEY_1}`), ensure they are properly set in your `environment` file. If an environment variable is not found, the system will raise a clear error message indicating which variable is missing.
172
174
 
@@ -182,6 +184,13 @@ testnet_asimov:
182
184
  from: "${ADMIN_KEY}" # Use ADMIN_KEY as default instead of DEPLOYER_KEY
183
185
  ```
184
186
 
187
+ **Chain vs Network**:
188
+ - **Network**: Defines the connection details (URL, accounts, etc.) for a specific environment
189
+ - **Chain**: Defines the genlayer chain type and its associated behaviors (localnet, studionet, or testnet_asimov)
190
+ - Pre-configured networks automatically have the correct chain type set
191
+ - Custom networks must specify the chain type explicitly
192
+ - The `--chain-type` CLI flag can override the chain type for any network, allowing you to test different chain behaviors with the same network configuration
193
+
185
194
  2. **Paths**: Define important directory paths
186
195
  - `contracts`: Location of your contract files
187
196
  - `artifacts`: Location of your artifacts files (analysis results will be stored here)
@@ -299,6 +308,24 @@ When this flag is enabled, all contracts deployed and all write transactions wil
299
308
 
300
309
  **Note:** Leader-only mode is only available for studio-based networks (localhost, 127.0.0.1, *.genlayer.com, *.genlayerlabs.com). When enabled on other networks, it will have no effect and a warning will be logged.
301
310
 
311
+ 12. Override the chain type
312
+ ```bash
313
+ $ gltest --chain-type localnet
314
+ $ gltest --chain-type studionet
315
+ $ gltest --chain-type testnet_asimov
316
+ ```
317
+ The `--chain-type` flag allows you to override the chain type configured for the network. This is useful when:
318
+ - Testing different chain behaviors without changing network configuration
319
+ - Switching between chain types for testing purposes
320
+ - Using a custom network URL with a specific chain type
321
+
322
+ Available chain types:
323
+ - `localnet`: Local development chain
324
+ - `studionet`: Studio-based chain
325
+ - `testnet_asimov`: Testnet Asimov chain
326
+
327
+ The chain type determines various behaviors including RPC endpoints, consensus mechanisms, and available features. When specified, this flag overrides the chain type configured in your network settings.
328
+
302
329
  ## 🚀 Key Features
303
330
 
304
331
  - **Pytest Integration** – Extends pytest to support intelligent contract testing, making it familiar and easy to adopt.
@@ -117,6 +117,7 @@ networks:
117
117
  custom_network: # Custom network configuration
118
118
  id: 1234
119
119
  url: "http://custom.network:8545"
120
+ chain_type: "localnet" # Required for custom networks: localnet, studionet, or testnet_asimov
120
121
  accounts:
121
122
  - "${CUSTOM_ACCOUNT_1}"
122
123
  - "${CUSTOM_ACCOUNT_2}"
@@ -140,10 +141,11 @@ Key configuration sections:
140
141
  - Network configurations can include:
141
142
  - `url`: The RPC endpoint for the network (optional for pre-configured networks)
142
143
  - `id`: Chain ID (optional for pre-configured networks)
144
+ - `chain_type`: Chain type - one of: `localnet`, `studionet`, or `testnet_asimov` (required for custom networks)
143
145
  - `accounts`: List of account private keys (using environment variables)
144
146
  - `from`: Specify which account to use as the default for transactions (optional, defaults to first account)
145
147
  - `leader_only`: Leader only mode
146
- - For custom networks (non-pre-configured), `id`, `url`, and `accounts` are required fields
148
+ - For custom networks (non-pre-configured), `id`, `url`, `chain_type`, and `accounts` are required fields
147
149
 
148
150
  **Note on Environment Variables**: When using environment variables in your configuration (e.g., `${ACCOUNT_PRIVATE_KEY_1}`), ensure they are properly set in your `environment` file. If an environment variable is not found, the system will raise a clear error message indicating which variable is missing.
149
151
 
@@ -159,6 +161,13 @@ testnet_asimov:
159
161
  from: "${ADMIN_KEY}" # Use ADMIN_KEY as default instead of DEPLOYER_KEY
160
162
  ```
161
163
 
164
+ **Chain vs Network**:
165
+ - **Network**: Defines the connection details (URL, accounts, etc.) for a specific environment
166
+ - **Chain**: Defines the genlayer chain type and its associated behaviors (localnet, studionet, or testnet_asimov)
167
+ - Pre-configured networks automatically have the correct chain type set
168
+ - Custom networks must specify the chain type explicitly
169
+ - The `--chain-type` CLI flag can override the chain type for any network, allowing you to test different chain behaviors with the same network configuration
170
+
162
171
  2. **Paths**: Define important directory paths
163
172
  - `contracts`: Location of your contract files
164
173
  - `artifacts`: Location of your artifacts files (analysis results will be stored here)
@@ -276,6 +285,24 @@ When this flag is enabled, all contracts deployed and all write transactions wil
276
285
 
277
286
  **Note:** Leader-only mode is only available for studio-based networks (localhost, 127.0.0.1, *.genlayer.com, *.genlayerlabs.com). When enabled on other networks, it will have no effect and a warning will be logged.
278
287
 
288
+ 12. Override the chain type
289
+ ```bash
290
+ $ gltest --chain-type localnet
291
+ $ gltest --chain-type studionet
292
+ $ gltest --chain-type testnet_asimov
293
+ ```
294
+ The `--chain-type` flag allows you to override the chain type configured for the network. This is useful when:
295
+ - Testing different chain behaviors without changing network configuration
296
+ - Switching between chain types for testing purposes
297
+ - Using a custom network URL with a specific chain type
298
+
299
+ Available chain types:
300
+ - `localnet`: Local development chain
301
+ - `studionet`: Studio-based chain
302
+ - `testnet_asimov`: Testnet Asimov chain
303
+
304
+ The chain type determines various behaviors including RPC endpoints, consensus mechanisms, and available features. When specified, this flag overrides the chain type configured in your network settings.
305
+
279
306
  ## 🚀 Key Features
280
307
 
281
308
  - **Pytest Integration** – Extends pytest to support intelligent contract testing, making it familiar and easy to adopt.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: genlayer-test
3
- Version: 0.8.0
3
+ Version: 0.9.0
4
4
  Summary: GenLayer Testing Suite
5
5
  Author: GenLayer
6
6
  License-Expression: MIT
@@ -140,6 +140,7 @@ networks:
140
140
  custom_network: # Custom network configuration
141
141
  id: 1234
142
142
  url: "http://custom.network:8545"
143
+ chain_type: "localnet" # Required for custom networks: localnet, studionet, or testnet_asimov
143
144
  accounts:
144
145
  - "${CUSTOM_ACCOUNT_1}"
145
146
  - "${CUSTOM_ACCOUNT_2}"
@@ -163,10 +164,11 @@ Key configuration sections:
163
164
  - Network configurations can include:
164
165
  - `url`: The RPC endpoint for the network (optional for pre-configured networks)
165
166
  - `id`: Chain ID (optional for pre-configured networks)
167
+ - `chain_type`: Chain type - one of: `localnet`, `studionet`, or `testnet_asimov` (required for custom networks)
166
168
  - `accounts`: List of account private keys (using environment variables)
167
169
  - `from`: Specify which account to use as the default for transactions (optional, defaults to first account)
168
170
  - `leader_only`: Leader only mode
169
- - For custom networks (non-pre-configured), `id`, `url`, and `accounts` are required fields
171
+ - For custom networks (non-pre-configured), `id`, `url`, `chain_type`, and `accounts` are required fields
170
172
 
171
173
  **Note on Environment Variables**: When using environment variables in your configuration (e.g., `${ACCOUNT_PRIVATE_KEY_1}`), ensure they are properly set in your `environment` file. If an environment variable is not found, the system will raise a clear error message indicating which variable is missing.
172
174
 
@@ -182,6 +184,13 @@ testnet_asimov:
182
184
  from: "${ADMIN_KEY}" # Use ADMIN_KEY as default instead of DEPLOYER_KEY
183
185
  ```
184
186
 
187
+ **Chain vs Network**:
188
+ - **Network**: Defines the connection details (URL, accounts, etc.) for a specific environment
189
+ - **Chain**: Defines the genlayer chain type and its associated behaviors (localnet, studionet, or testnet_asimov)
190
+ - Pre-configured networks automatically have the correct chain type set
191
+ - Custom networks must specify the chain type explicitly
192
+ - The `--chain-type` CLI flag can override the chain type for any network, allowing you to test different chain behaviors with the same network configuration
193
+
185
194
  2. **Paths**: Define important directory paths
186
195
  - `contracts`: Location of your contract files
187
196
  - `artifacts`: Location of your artifacts files (analysis results will be stored here)
@@ -299,6 +308,24 @@ When this flag is enabled, all contracts deployed and all write transactions wil
299
308
 
300
309
  **Note:** Leader-only mode is only available for studio-based networks (localhost, 127.0.0.1, *.genlayer.com, *.genlayerlabs.com). When enabled on other networks, it will have no effect and a warning will be logged.
301
310
 
311
+ 12. Override the chain type
312
+ ```bash
313
+ $ gltest --chain-type localnet
314
+ $ gltest --chain-type studionet
315
+ $ gltest --chain-type testnet_asimov
316
+ ```
317
+ The `--chain-type` flag allows you to override the chain type configured for the network. This is useful when:
318
+ - Testing different chain behaviors without changing network configuration
319
+ - Switching between chain types for testing purposes
320
+ - Using a custom network URL with a specific chain type
321
+
322
+ Available chain types:
323
+ - `localnet`: Local development chain
324
+ - `studionet`: Studio-based chain
325
+ - `testnet_asimov`: Testnet Asimov chain
326
+
327
+ The chain type determines various behaviors including RPC endpoints, consensus mechanisms, and available features. When specified, this flag overrides the chain type configured in your network settings.
328
+
302
329
  ## 🚀 Key Features
303
330
 
304
331
  - **Pytest Integration** – Extends pytest to support intelligent contract testing, making it familiar and easy to adopt.
@@ -0,0 +1,41 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ genlayer_test.egg-info/PKG-INFO
5
+ genlayer_test.egg-info/SOURCES.txt
6
+ genlayer_test.egg-info/dependency_links.txt
7
+ genlayer_test.egg-info/entry_points.txt
8
+ genlayer_test.egg-info/requires.txt
9
+ genlayer_test.egg-info/top_level.txt
10
+ gltest/__init__.py
11
+ gltest/accounts.py
12
+ gltest/assertions.py
13
+ gltest/clients.py
14
+ gltest/exceptions.py
15
+ gltest/fixtures.py
16
+ gltest/logging.py
17
+ gltest/types.py
18
+ gltest/utils.py
19
+ gltest/artifacts/__init__.py
20
+ gltest/artifacts/contract.py
21
+ gltest/contracts/__init__.py
22
+ gltest/contracts/contract.py
23
+ gltest/contracts/contract_factory.py
24
+ gltest/contracts/contract_functions.py
25
+ gltest/contracts/method_stats.py
26
+ gltest/contracts/stats_collector.py
27
+ gltest/contracts/utils.py
28
+ gltest/helpers/__init__.py
29
+ gltest/helpers/fixture_snapshot.py
30
+ gltest/helpers/take_snapshot.py
31
+ gltest/validators/__init__.py
32
+ gltest/validators/validator_factory.py
33
+ gltest_cli/logging.py
34
+ gltest_cli/main.py
35
+ gltest_cli/config/__init__.py
36
+ gltest_cli/config/constants.py
37
+ gltest_cli/config/general.py
38
+ gltest_cli/config/plugin.py
39
+ gltest_cli/config/pytest_context.py
40
+ gltest_cli/config/types.py
41
+ gltest_cli/config/user.py
@@ -1,5 +1,3 @@
1
1
  dist
2
2
  gltest
3
3
  gltest_cli
4
- scripts
5
- tests
@@ -5,8 +5,15 @@ from pathlib import Path
5
5
  GLTEST_CONFIG_FILE = "gltest.config.yaml"
6
6
  DEFAULT_NETWORK = "localnet"
7
7
  PRECONFIGURED_NETWORKS = ["localnet", "studionet", "testnet_asimov"]
8
+ CHAINS = ["localnet", "studionet", "testnet_asimov"]
8
9
  DEFAULT_RPC_URL = SIMULATOR_JSON_RPC_URL
9
10
  DEFAULT_ENVIRONMENT = ".env"
10
11
  DEFAULT_CONTRACTS_DIR = Path("contracts")
11
12
  DEFAULT_ARTIFACTS_DIR = Path("artifacts")
12
13
  DEFAULT_NETWORK_ID = 61999
14
+
15
+ # Defaults per network
16
+ DEFAULT_WAIT_INTERVAL = 3000
17
+ DEFAULT_WAIT_RETRIES = 50
18
+ DEFAULT_TEST_WITH_MOCKS = False
19
+ DEFAULT_LEADER_ONLY = False
@@ -12,6 +12,13 @@ from gltest_cli.config.general import (
12
12
  )
13
13
  from gltest_cli.config.types import PluginConfig
14
14
  from gltest_cli.config.pytest_context import _pytest_context
15
+ from gltest_cli.config.constants import (
16
+ DEFAULT_WAIT_INTERVAL,
17
+ DEFAULT_WAIT_RETRIES,
18
+ DEFAULT_TEST_WITH_MOCKS,
19
+ DEFAULT_LEADER_ONLY,
20
+ CHAINS,
21
+ )
15
22
 
16
23
 
17
24
  def pytest_addoption(parser):
@@ -33,14 +40,14 @@ def pytest_addoption(parser):
33
40
  group.addoption(
34
41
  "--default-wait-interval",
35
42
  action="store",
36
- default=3000,
43
+ default=DEFAULT_WAIT_INTERVAL,
37
44
  help="Default interval (ms) between transaction receipt checks",
38
45
  )
39
46
 
40
47
  group.addoption(
41
48
  "--default-wait-retries",
42
49
  action="store",
43
- default=50,
50
+ default=DEFAULT_WAIT_RETRIES,
44
51
  help="Default number of retries for transaction receipt checks",
45
52
  )
46
53
 
@@ -61,17 +68,24 @@ def pytest_addoption(parser):
61
68
  group.addoption(
62
69
  "--test-with-mocks",
63
70
  action="store_true",
64
- default=False,
71
+ default=DEFAULT_TEST_WITH_MOCKS,
65
72
  help="Test with mocks",
66
73
  )
67
74
 
68
75
  group.addoption(
69
76
  "--leader-only",
70
77
  action="store_true",
71
- default=False,
78
+ default=DEFAULT_LEADER_ONLY,
72
79
  help="Run contracts in leader-only mode",
73
80
  )
74
81
 
82
+ group.addoption(
83
+ "--chain-type",
84
+ action="store",
85
+ default=None,
86
+ help=f"Chain type (possible values: {', '.join(CHAINS)})",
87
+ )
88
+
75
89
 
76
90
  def pytest_configure(config):
77
91
  try:
@@ -108,6 +122,7 @@ def pytest_configure(config):
108
122
  network = config.getoption("--network")
109
123
  test_with_mocks = config.getoption("--test-with-mocks")
110
124
  leader_only = config.getoption("--leader-only")
125
+ chain_type = config.getoption("--chain-type")
111
126
 
112
127
  plugin_config = PluginConfig()
113
128
  plugin_config.contracts_dir = (
@@ -122,6 +137,7 @@ def pytest_configure(config):
122
137
  plugin_config.network_name = network
123
138
  plugin_config.test_with_mocks = test_with_mocks
124
139
  plugin_config.leader_only = leader_only
140
+ plugin_config.chain_type = chain_type
125
141
 
126
142
  general_config.plugin_config = plugin_config
127
143
  except Exception as e:
@@ -148,6 +164,8 @@ def pytest_sessionstart(session):
148
164
  # Show available networks including preconfigured ones
149
165
  all_networks = general_config.get_networks_keys()
150
166
  logger.info(f" Available networks: {all_networks}")
167
+ logger.info(f" Selected chain type: {general_config.get_chain_type()}")
168
+ logger.info(f" Available chains: {', '.join(CHAINS)}")
151
169
  logger.info(f" Contracts directory: {general_config.get_contracts_dir()}")
152
170
  logger.info(f" Artifacts directory: {general_config.get_artifacts_dir()}")
153
171
  logger.info(f" Environment: {general_config.user_config.environment}")
@@ -1,11 +1,16 @@
1
- from enum import Enum
2
1
  from dataclasses import dataclass, field
3
2
  from pathlib import Path
4
3
  from typing import Dict, List, Optional
5
4
  from genlayer_py.chains import localnet, studionet, testnet_asimov
6
5
  from genlayer_py.types import GenLayerChain
7
- from urllib.parse import urlparse
8
6
  from gltest_cli.config.constants import PRECONFIGURED_NETWORKS
7
+ from gltest_cli.config.constants import (
8
+ DEFAULT_WAIT_INTERVAL,
9
+ DEFAULT_WAIT_RETRIES,
10
+ DEFAULT_TEST_WITH_MOCKS,
11
+ DEFAULT_LEADER_ONLY,
12
+ CHAINS,
13
+ )
9
14
 
10
15
 
11
16
  @dataclass
@@ -18,6 +23,7 @@ class PluginConfig:
18
23
  network_name: Optional[str] = None
19
24
  test_with_mocks: bool = False
20
25
  leader_only: bool = False
26
+ chain_type: Optional[str] = None
21
27
 
22
28
 
23
29
  @dataclass
@@ -27,6 +33,10 @@ class NetworkConfigData:
27
33
  accounts: Optional[List[str]] = None
28
34
  from_account: Optional[str] = None
29
35
  leader_only: bool = False
36
+ default_wait_interval: Optional[int] = None
37
+ default_wait_retries: Optional[int] = None
38
+ test_with_mocks: bool = False
39
+ chain_type: Optional[str] = None
30
40
 
31
41
  def __post_init__(self):
32
42
  if self.id is not None and not isinstance(self.id, int):
@@ -40,6 +50,20 @@ class NetworkConfigData:
40
50
  raise ValueError("accounts must be strings")
41
51
  if self.from_account is not None and not isinstance(self.from_account, str):
42
52
  raise ValueError("from_account must be a string")
53
+ if not isinstance(self.leader_only, bool):
54
+ raise TypeError("leader_only must be a boolean")
55
+ if self.default_wait_interval is not None and not isinstance(
56
+ self.default_wait_interval, int
57
+ ):
58
+ raise ValueError("default_wait_interval must be an integer")
59
+ if self.default_wait_retries is not None and not isinstance(
60
+ self.default_wait_retries, int
61
+ ):
62
+ raise ValueError("default_wait_retries must be an integer")
63
+ if not isinstance(self.test_with_mocks, bool):
64
+ raise TypeError("test_with_mocks must be a boolean")
65
+ if self.chain_type is not None and not isinstance(self.chain_type, str):
66
+ raise ValueError("chain_type must be a string")
43
67
 
44
68
 
45
69
  @dataclass
@@ -130,50 +154,69 @@ class GeneralConfig:
130
154
  return self.user_config.networks[network_name].accounts
131
155
  return self.user_config.networks[self.user_config.default_network].accounts
132
156
 
133
- def get_chain(self) -> GenLayerChain:
157
+ def get_chain_type(self) -> str:
158
+ # If chain_type is explicitly set via CLI, use it
159
+ if self.plugin_config.chain_type is not None:
160
+ if self.plugin_config.chain_type not in CHAINS:
161
+ raise ValueError(
162
+ f"Unknown chain type: {self.plugin_config.chain_type}. "
163
+ f"Valid values: {', '.join(CHAINS)}"
164
+ )
165
+ return self.plugin_config.chain_type
166
+
134
167
  network_name = self.get_network_name()
135
168
  if network_name not in self.user_config.networks:
136
169
  raise ValueError(
137
170
  f"Unknown network: {network_name}, possible values: {self.get_networks_keys()}"
138
171
  )
172
+ network_config = self.user_config.networks[network_name]
173
+ # For preconfigured networks, use its chain type
174
+ if network_name in PRECONFIGURED_NETWORKS:
175
+ chain_type = network_config.chain_type
176
+ else:
177
+ # For custom networks, chain_type field is required
178
+ chain_type = network_config.chain_type
179
+ if not chain_type:
180
+ raise ValueError(
181
+ f"Custom network {network_name} must specify a 'chain_type' field. "
182
+ f"Valid values: {', '.join(CHAINS)}"
183
+ )
184
+
185
+ if chain_type not in CHAINS:
186
+ raise ValueError(
187
+ f"Unknown chain type: {chain_type}. "
188
+ f"Valid values: {', '.join(CHAINS)}"
189
+ )
190
+ return chain_type
139
191
 
140
- # Reserved network names
141
- chain_map_by_name = {
192
+ def get_chain(self) -> GenLayerChain:
193
+ chain_map = {
142
194
  "localnet": localnet,
143
195
  "studionet": studionet,
144
196
  "testnet_asimov": testnet_asimov,
145
197
  }
146
-
147
- if network_name in chain_map_by_name:
148
- return chain_map_by_name[network_name]
149
-
150
- if network_name in PRECONFIGURED_NETWORKS:
151
- raise ValueError(
152
- f"Network {network_name} should be handled by reserved mapping"
153
- )
154
-
155
- # Custom networks
156
- chain_map_by_id = {
157
- 61999: localnet,
158
- 4221: testnet_asimov,
159
- }
160
- network_id = self.user_config.networks[network_name].id
161
- if network_id not in chain_map_by_id:
162
- known = ", ".join(map(str, chain_map_by_id.keys()))
163
- raise ValueError(
164
- f"Unknown network id: {network_id}, possible values: {known}"
165
- )
166
- return chain_map_by_id[network_id]
198
+ chain_type = self.get_chain_type()
199
+ return chain_map[chain_type]
167
200
 
168
201
  def get_default_wait_interval(self) -> int:
169
202
  if self.plugin_config.default_wait_interval is not None:
170
203
  return self.plugin_config.default_wait_interval
171
- raise ValueError("default_wait_interval is not set")
204
+ network_name = self.get_network_name()
205
+ if network_name in self.user_config.networks:
206
+ network_config = self.user_config.networks[network_name]
207
+ if network_config.default_wait_interval is not None:
208
+ return network_config.default_wait_interval
209
+ return DEFAULT_WAIT_INTERVAL
172
210
 
173
211
  def get_default_wait_retries(self) -> int:
174
212
  if self.plugin_config.default_wait_retries is not None:
175
213
  return self.plugin_config.default_wait_retries
176
- raise ValueError("default_wait_retries is not set")
214
+ network_name = self.get_network_name()
215
+ if network_name in self.user_config.networks:
216
+ network_config = self.user_config.networks[network_name]
217
+ if network_config.default_wait_retries is not None:
218
+ return network_config.default_wait_retries
219
+ return DEFAULT_WAIT_RETRIES
177
220
 
178
221
  def get_network_name(self) -> str:
179
222
  if self.plugin_config.network_name is not None:
@@ -181,7 +224,13 @@ class GeneralConfig:
181
224
  return self.user_config.default_network
182
225
 
183
226
  def get_test_with_mocks(self) -> bool:
184
- return self.plugin_config.test_with_mocks
227
+ if self.plugin_config.test_with_mocks:
228
+ return True
229
+ network_name = self.get_network_name()
230
+ if network_name in self.user_config.networks:
231
+ network_config = self.user_config.networks[network_name]
232
+ return network_config.test_with_mocks
233
+ return DEFAULT_TEST_WITH_MOCKS
185
234
 
186
235
  def get_leader_only(self) -> bool:
187
236
  if self.plugin_config.leader_only:
@@ -190,24 +239,10 @@ class GeneralConfig:
190
239
  if network_name in self.user_config.networks:
191
240
  network_config = self.user_config.networks[network_name]
192
241
  return network_config.leader_only
193
- return False
242
+ return DEFAULT_LEADER_ONLY
194
243
 
195
244
  def check_local_rpc(self) -> bool:
196
- SUPPORTED_RPC_DOMAINS = ["localhost", "127.0.0.1"]
197
- rpc_url = self.get_rpc_url()
198
- domain = urlparse(rpc_url).netloc.split(":")[0] # Extract domain without port
199
- return domain in SUPPORTED_RPC_DOMAINS
245
+ return self.get_chain_type() == "localnet"
200
246
 
201
247
  def check_studio_based_rpc(self) -> bool:
202
- SUPPORTED_RPC_DOMAINS = ["localhost", "127.0.0.1"]
203
- rpc_url = self.get_rpc_url()
204
- domain = urlparse(rpc_url).netloc.split(":")[0] # Extract domain without port
205
-
206
- if domain in SUPPORTED_RPC_DOMAINS:
207
- return True
208
-
209
- # Check .genlayer.com or .genlayerlabs.com subdomains
210
- if domain.endswith(".genlayer.com") or domain.endswith(".genlayerlabs.com"):
211
- return True
212
-
213
- return False
248
+ return self.get_chain_type() == "studionet"