genlayer-test 0.2.0__tar.gz → 0.3.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 (77) hide show
  1. {genlayer_test-0.2.0/genlayer_test.egg-info → genlayer_test-0.3.0}/PKG-INFO +77 -10
  2. genlayer_test-0.2.0/PKG-INFO → genlayer_test-0.3.0/README.md +71 -27
  3. genlayer_test-0.2.0/README.md → genlayer_test-0.3.0/genlayer_test.egg-info/PKG-INFO +94 -8
  4. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/genlayer_test.egg-info/SOURCES.txt +19 -9
  5. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/genlayer_test.egg-info/entry_points.txt +1 -1
  6. genlayer_test-0.3.0/genlayer_test.egg-info/requires.txt +6 -0
  7. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest/__init__.py +4 -4
  8. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest/artifacts/contract.py +9 -4
  9. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest/glchain/__init__.py +3 -3
  10. genlayer_test-0.3.0/gltest/glchain/account.py +22 -0
  11. genlayer_test-0.3.0/gltest/glchain/client.py +59 -0
  12. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest/glchain/contract.py +57 -26
  13. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest/helpers/fixture_snapshot.py +3 -2
  14. genlayer_test-0.3.0/gltest_cli/config/__init__.py +0 -0
  15. genlayer_test-0.3.0/gltest_cli/config/constants.py +10 -0
  16. genlayer_test-0.3.0/gltest_cli/config/general.py +10 -0
  17. genlayer_test-0.3.0/gltest_cli/config/plugin.py +102 -0
  18. genlayer_test-0.3.0/gltest_cli/config/types.py +137 -0
  19. genlayer_test-0.3.0/gltest_cli/config/user.py +222 -0
  20. genlayer_test-0.3.0/gltest_cli/logging.py +51 -0
  21. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/pyproject.toml +7 -3
  22. genlayer_test-0.3.0/tests/__init__.py +0 -0
  23. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_llm_erc20.py +2 -2
  24. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_multi_read_erc20.py +13 -3
  25. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_multi_tenant_storage.py +12 -3
  26. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_read_erc20.py +2 -2
  27. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_storage.py +4 -2
  28. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_user_storage.py +17 -3
  29. genlayer_test-0.3.0/tests/gltest/__init__.py +0 -0
  30. genlayer_test-0.3.0/tests/gltest/artifact/__init__.py +0 -0
  31. genlayer_test-0.3.0/tests/gltest/artifact/test_contract_definition.py +91 -0
  32. genlayer_test-0.3.0/tests/gltest_cli/__init__.py +0 -0
  33. genlayer_test-0.3.0/tests/gltest_cli/config/test_plugin.py +127 -0
  34. genlayer_test-0.3.0/tests/gltest_cli/config/test_user.py +351 -0
  35. genlayer_test-0.2.0/genlayer_test.egg-info/requires.txt +0 -2
  36. genlayer_test-0.2.0/gltest/glchain/account.py +0 -18
  37. genlayer_test-0.2.0/gltest/glchain/client.py +0 -23
  38. genlayer_test-0.2.0/gltest/plugin_config.py +0 -42
  39. genlayer_test-0.2.0/gltest/plugin_hooks.py +0 -51
  40. genlayer_test-0.2.0/tests/artifact/test_contract_definition.py +0 -347
  41. genlayer_test-0.2.0/tests/plugin/test_plugin_hooks.py +0 -78
  42. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/LICENSE +0 -0
  43. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/genlayer_test.egg-info/dependency_links.txt +0 -0
  44. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/genlayer_test.egg-info/top_level.txt +0 -0
  45. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest/artifacts/__init__.py +0 -0
  46. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest/assertions.py +0 -0
  47. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest/exceptions.py +0 -0
  48. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest/helpers/__init__.py +0 -0
  49. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest/helpers/take_snapshot.py +0 -0
  50. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest/types.py +0 -0
  51. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/gltest_cli/main.py +0 -0
  52. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/setup.cfg +0 -0
  53. {genlayer_test-0.2.0/tests/plugin → genlayer_test-0.3.0/tests}/conftest.py +0 -0
  54. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/football_prediction_market.py +0 -0
  55. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/intelligent_oracle.py +0 -0
  56. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/intelligent_oracle_factory.py +0 -0
  57. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/llm_erc20.py +0 -0
  58. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/log_indexer.py +0 -0
  59. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/multi_file_contract/__init__.py +0 -0
  60. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/multi_file_contract/other.py +0 -0
  61. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/multi_read_erc20.py +0 -0
  62. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/multi_tenant_storage.py +0 -0
  63. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/read_erc20.py +0 -0
  64. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/storage.py +0 -0
  65. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/user_storage.py +0 -0
  66. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/contracts/wizard_of_coin.py +0 -0
  67. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_football_prediction_market.py +0 -0
  68. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_intelligent_oracle_factory.py +0 -0
  69. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_log_indexer.py +0 -0
  70. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_multi_file_contract.py +0 -0
  71. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_multi_file_contract_legacy.py +0 -0
  72. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_storage_legacy.py +0 -0
  73. {genlayer_test-0.2.0 → genlayer_test-0.3.0}/tests/examples/tests/test_wizard_of_coin.py +0 -0
  74. {genlayer_test-0.2.0/tests → genlayer_test-0.3.0/tests/gltest}/artifact/contracts/duplicate_ic_contract_1.py +0 -0
  75. {genlayer_test-0.2.0/tests → genlayer_test-0.3.0/tests/gltest}/artifact/contracts/duplicate_ic_contract_2.py +0 -0
  76. {genlayer_test-0.2.0/tests → genlayer_test-0.3.0/tests/gltest}/artifact/contracts/not_ic_contract.py +0 -0
  77. {genlayer_test-0.2.0/tests → genlayer_test-0.3.0/tests/gltest}/assertions/test_assertions.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: genlayer-test
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: GenLayer Testing Suite
5
5
  Author: GenLayer
6
6
  License-Expression: MIT
@@ -14,7 +14,11 @@ Requires-Python: >=3.12
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
16
  Requires-Dist: pytest
17
- Requires-Dist: genlayer-py==0.3.0
17
+ Requires-Dist: setuptools>=77.0
18
+ Requires-Dist: genlayer-py==0.5.0
19
+ Requires-Dist: colorama>=0.4.6
20
+ Requires-Dist: pyyaml
21
+ Requires-Dist: python-dotenv
18
22
  Dynamic: license-file
19
23
 
20
24
  # GenLayer Testing Suite
@@ -41,13 +45,13 @@ pip install genlayer-test
41
45
  ### Basic Usage
42
46
 
43
47
  ```python
44
- from gltest import get_contract_factory, default_account, create_account
48
+ from gltest import get_contract_factory, get_default_account, create_account
45
49
  from gltest.assertions import tx_execution_succeeded
46
50
 
47
51
  factory = get_contract_factory("MyContract")
48
52
  # Deploy a contract with default account
49
53
  contract = factory.deploy() # This will be deployed with default_account
50
- assert contract.account == default_account
54
+ assert contract.account == get_default_account()
51
55
 
52
56
  # Deploy a contract with other account
53
57
  other_account = create_account()
@@ -99,6 +103,58 @@ $ cd genlayer-testing-suite
99
103
  $ pip install -e .
100
104
  ```
101
105
 
106
+ ### Configuration
107
+
108
+ The GenLayer Testing Suite can be configured using an optional but recommended `gltest.config.yaml` file in your project root. While not required, this file helps manage network configurations, contract paths, and environment settings in a centralized way, making it easier to maintain different environments and share configurations across team members.
109
+
110
+ ```yaml
111
+ # gltest.config.yaml
112
+ networks:
113
+ default: localnet # Default network to use
114
+
115
+ localnet: # Local development network configuration
116
+ url: "http://127.0.0.1:4000/api"
117
+
118
+ testnet_asimov: # Test network configuration
119
+ id: 4221
120
+ url: "http://34.32.169.58:9151"
121
+ accounts:
122
+ - "${ACCOUNT_PRIVATE_KEY_1}"
123
+ - "${ACCOUNT_PRIVATE_KEY_2}"
124
+ - "${ACCOUNT_PRIVATE_KEY_3}"
125
+
126
+ paths:
127
+ contracts: "contracts" # Path to your contracts directory
128
+
129
+ environment: .env # Path to your environment file containing private keys and other secrets
130
+ ```
131
+
132
+ Key configuration sections:
133
+
134
+ 1. **Networks**: Define different network environments
135
+ - `default`: Specifies which network to use by default
136
+ - Network configurations can include:
137
+ - `url`: The RPC endpoint for the network
138
+ - `id`: Chain ID
139
+ - `accounts`: List of account private keys (using environment variables)
140
+ - Special case for `localnet`:
141
+ - If a network is named `localnet`, missing fields will be filled with default values
142
+ - For all other network names, `id`, `url`, and `accounts` are required fields
143
+
144
+ 2. **Paths**: Define important directory paths
145
+ - `contracts`: Location of your contract files
146
+
147
+ 3. **Environment**: Path to your `.env` file containing sensitive information like private keys
148
+
149
+ If you don't provide a config file, the suite will use default values. You can override these settings using command-line arguments. For example:
150
+ ```bash
151
+ # Override the default network
152
+ gltest --network testnet_asimov
153
+
154
+ # Override the contracts directory
155
+ gltest --contracts-dir custom/contracts/path
156
+ ```
157
+
102
158
  ### Running Tests
103
159
 
104
160
  1. Run all tests:
@@ -126,17 +182,27 @@ $ gltest -v
126
182
  $ gltest --contracts-dir <path_to_contracts>
127
183
  ```
128
184
 
129
- 6. Run tests with a custom RPC url
185
+ 6. Run tests on a specific network:
186
+ ```bash
187
+ # Run tests on localnet (default)
188
+ $ gltest --network localnet
189
+
190
+ # Run tests on testnet
191
+ $ gltest --network testnet_asimov
192
+ ```
193
+ The `--network` flag allows you to specify which network configuration to use from your `gltest.config.yaml`. If not specified, it will use the `default` network defined in your config file.
194
+
195
+ 7. Run tests with a custom RPC url
130
196
  ```bash
131
197
  $ gltest --rpc-url <custom_rpc_url>
132
198
  ```
133
199
 
134
- 6. Run tests with a default wait interval for waiting transaction receipts
200
+ 8. Run tests with a default wait interval for waiting transaction receipts
135
201
  ```bash
136
202
  $ gltest --default-wait-interval <default_wait_interval>
137
203
  ```
138
204
 
139
- 6. Run tests with a default wait retries for waiting transaction receipts
205
+ 9. Run tests with a default wait retries for waiting transaction receipts
140
206
  ```bash
141
207
  $ gltest --default-wait-retries <default_wait_retries>
142
208
  ```
@@ -233,13 +299,14 @@ def test_deployment():
233
299
  Reading from the contract is straightforward:
234
300
 
235
301
  ```python
236
- from gltest import get_contract_factory, default_account
302
+ from gltest import get_contract_factory
237
303
 
238
304
  def test_read_methods():
305
+
239
306
  # Get the contract factory and deploy the contract
240
307
  factory = get_contract_factory("Storage")
241
- contract = factory.deploy(account=default_account)
242
-
308
+ contract = factory.deploy()
309
+
243
310
  # Call a read-only method
244
311
  result = contract.get_value(args=[])
245
312
 
@@ -1,22 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: genlayer-test
3
- Version: 0.2.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: genlayer-py==0.3.0
18
- Dynamic: license-file
19
-
20
1
  # GenLayer Testing Suite
21
2
 
22
3
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)
@@ -41,13 +22,13 @@ pip install genlayer-test
41
22
  ### Basic Usage
42
23
 
43
24
  ```python
44
- from gltest import get_contract_factory, default_account, create_account
25
+ from gltest import get_contract_factory, get_default_account, create_account
45
26
  from gltest.assertions import tx_execution_succeeded
46
27
 
47
28
  factory = get_contract_factory("MyContract")
48
29
  # Deploy a contract with default account
49
30
  contract = factory.deploy() # This will be deployed with default_account
50
- assert contract.account == default_account
31
+ assert contract.account == get_default_account()
51
32
 
52
33
  # Deploy a contract with other account
53
34
  other_account = create_account()
@@ -99,6 +80,58 @@ $ cd genlayer-testing-suite
99
80
  $ pip install -e .
100
81
  ```
101
82
 
83
+ ### Configuration
84
+
85
+ The GenLayer Testing Suite can be configured using an optional but recommended `gltest.config.yaml` file in your project root. While not required, this file helps manage network configurations, contract paths, and environment settings in a centralized way, making it easier to maintain different environments and share configurations across team members.
86
+
87
+ ```yaml
88
+ # gltest.config.yaml
89
+ networks:
90
+ default: localnet # Default network to use
91
+
92
+ localnet: # Local development network configuration
93
+ url: "http://127.0.0.1:4000/api"
94
+
95
+ testnet_asimov: # Test network configuration
96
+ id: 4221
97
+ url: "http://34.32.169.58:9151"
98
+ accounts:
99
+ - "${ACCOUNT_PRIVATE_KEY_1}"
100
+ - "${ACCOUNT_PRIVATE_KEY_2}"
101
+ - "${ACCOUNT_PRIVATE_KEY_3}"
102
+
103
+ paths:
104
+ contracts: "contracts" # Path to your contracts directory
105
+
106
+ environment: .env # Path to your environment file containing private keys and other secrets
107
+ ```
108
+
109
+ Key configuration sections:
110
+
111
+ 1. **Networks**: Define different network environments
112
+ - `default`: Specifies which network to use by default
113
+ - Network configurations can include:
114
+ - `url`: The RPC endpoint for the network
115
+ - `id`: Chain ID
116
+ - `accounts`: List of account private keys (using environment variables)
117
+ - Special case for `localnet`:
118
+ - If a network is named `localnet`, missing fields will be filled with default values
119
+ - For all other network names, `id`, `url`, and `accounts` are required fields
120
+
121
+ 2. **Paths**: Define important directory paths
122
+ - `contracts`: Location of your contract files
123
+
124
+ 3. **Environment**: Path to your `.env` file containing sensitive information like private keys
125
+
126
+ If you don't provide a config file, the suite will use default values. You can override these settings using command-line arguments. For example:
127
+ ```bash
128
+ # Override the default network
129
+ gltest --network testnet_asimov
130
+
131
+ # Override the contracts directory
132
+ gltest --contracts-dir custom/contracts/path
133
+ ```
134
+
102
135
  ### Running Tests
103
136
 
104
137
  1. Run all tests:
@@ -126,17 +159,27 @@ $ gltest -v
126
159
  $ gltest --contracts-dir <path_to_contracts>
127
160
  ```
128
161
 
129
- 6. Run tests with a custom RPC url
162
+ 6. Run tests on a specific network:
163
+ ```bash
164
+ # Run tests on localnet (default)
165
+ $ gltest --network localnet
166
+
167
+ # Run tests on testnet
168
+ $ gltest --network testnet_asimov
169
+ ```
170
+ The `--network` flag allows you to specify which network configuration to use from your `gltest.config.yaml`. If not specified, it will use the `default` network defined in your config file.
171
+
172
+ 7. Run tests with a custom RPC url
130
173
  ```bash
131
174
  $ gltest --rpc-url <custom_rpc_url>
132
175
  ```
133
176
 
134
- 6. Run tests with a default wait interval for waiting transaction receipts
177
+ 8. Run tests with a default wait interval for waiting transaction receipts
135
178
  ```bash
136
179
  $ gltest --default-wait-interval <default_wait_interval>
137
180
  ```
138
181
 
139
- 6. Run tests with a default wait retries for waiting transaction receipts
182
+ 9. Run tests with a default wait retries for waiting transaction receipts
140
183
  ```bash
141
184
  $ gltest --default-wait-retries <default_wait_retries>
142
185
  ```
@@ -233,13 +276,14 @@ def test_deployment():
233
276
  Reading from the contract is straightforward:
234
277
 
235
278
  ```python
236
- from gltest import get_contract_factory, default_account
279
+ from gltest import get_contract_factory
237
280
 
238
281
  def test_read_methods():
282
+
239
283
  # Get the contract factory and deploy the contract
240
284
  factory = get_contract_factory("Storage")
241
- contract = factory.deploy(account=default_account)
242
-
285
+ contract = factory.deploy()
286
+
243
287
  # Call a read-only method
244
288
  result = contract.get_value(args=[])
245
289
 
@@ -1,3 +1,26 @@
1
+ Metadata-Version: 2.4
2
+ Name: genlayer-test
3
+ Version: 0.3.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.5.0
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/)
@@ -22,13 +45,13 @@ pip install genlayer-test
22
45
  ### Basic Usage
23
46
 
24
47
  ```python
25
- from gltest import get_contract_factory, default_account, create_account
48
+ from gltest import get_contract_factory, get_default_account, create_account
26
49
  from gltest.assertions import tx_execution_succeeded
27
50
 
28
51
  factory = get_contract_factory("MyContract")
29
52
  # Deploy a contract with default account
30
53
  contract = factory.deploy() # This will be deployed with default_account
31
- assert contract.account == default_account
54
+ assert contract.account == get_default_account()
32
55
 
33
56
  # Deploy a contract with other account
34
57
  other_account = create_account()
@@ -80,6 +103,58 @@ $ cd genlayer-testing-suite
80
103
  $ pip install -e .
81
104
  ```
82
105
 
106
+ ### Configuration
107
+
108
+ The GenLayer Testing Suite can be configured using an optional but recommended `gltest.config.yaml` file in your project root. While not required, this file helps manage network configurations, contract paths, and environment settings in a centralized way, making it easier to maintain different environments and share configurations across team members.
109
+
110
+ ```yaml
111
+ # gltest.config.yaml
112
+ networks:
113
+ default: localnet # Default network to use
114
+
115
+ localnet: # Local development network configuration
116
+ url: "http://127.0.0.1:4000/api"
117
+
118
+ testnet_asimov: # Test network configuration
119
+ id: 4221
120
+ url: "http://34.32.169.58:9151"
121
+ accounts:
122
+ - "${ACCOUNT_PRIVATE_KEY_1}"
123
+ - "${ACCOUNT_PRIVATE_KEY_2}"
124
+ - "${ACCOUNT_PRIVATE_KEY_3}"
125
+
126
+ paths:
127
+ contracts: "contracts" # Path to your contracts directory
128
+
129
+ environment: .env # Path to your environment file containing private keys and other secrets
130
+ ```
131
+
132
+ Key configuration sections:
133
+
134
+ 1. **Networks**: Define different network environments
135
+ - `default`: Specifies which network to use by default
136
+ - Network configurations can include:
137
+ - `url`: The RPC endpoint for the network
138
+ - `id`: Chain ID
139
+ - `accounts`: List of account private keys (using environment variables)
140
+ - Special case for `localnet`:
141
+ - If a network is named `localnet`, missing fields will be filled with default values
142
+ - For all other network names, `id`, `url`, and `accounts` are required fields
143
+
144
+ 2. **Paths**: Define important directory paths
145
+ - `contracts`: Location of your contract files
146
+
147
+ 3. **Environment**: Path to your `.env` file containing sensitive information like private keys
148
+
149
+ If you don't provide a config file, the suite will use default values. You can override these settings using command-line arguments. For example:
150
+ ```bash
151
+ # Override the default network
152
+ gltest --network testnet_asimov
153
+
154
+ # Override the contracts directory
155
+ gltest --contracts-dir custom/contracts/path
156
+ ```
157
+
83
158
  ### Running Tests
84
159
 
85
160
  1. Run all tests:
@@ -107,17 +182,27 @@ $ gltest -v
107
182
  $ gltest --contracts-dir <path_to_contracts>
108
183
  ```
109
184
 
110
- 6. Run tests with a custom RPC url
185
+ 6. Run tests on a specific network:
186
+ ```bash
187
+ # Run tests on localnet (default)
188
+ $ gltest --network localnet
189
+
190
+ # Run tests on testnet
191
+ $ gltest --network testnet_asimov
192
+ ```
193
+ The `--network` flag allows you to specify which network configuration to use from your `gltest.config.yaml`. If not specified, it will use the `default` network defined in your config file.
194
+
195
+ 7. Run tests with a custom RPC url
111
196
  ```bash
112
197
  $ gltest --rpc-url <custom_rpc_url>
113
198
  ```
114
199
 
115
- 6. Run tests with a default wait interval for waiting transaction receipts
200
+ 8. Run tests with a default wait interval for waiting transaction receipts
116
201
  ```bash
117
202
  $ gltest --default-wait-interval <default_wait_interval>
118
203
  ```
119
204
 
120
- 6. Run tests with a default wait retries for waiting transaction receipts
205
+ 9. Run tests with a default wait retries for waiting transaction receipts
121
206
  ```bash
122
207
  $ gltest --default-wait-retries <default_wait_retries>
123
208
  ```
@@ -214,13 +299,14 @@ def test_deployment():
214
299
  Reading from the contract is straightforward:
215
300
 
216
301
  ```python
217
- from gltest import get_contract_factory, default_account
302
+ from gltest import get_contract_factory
218
303
 
219
304
  def test_read_methods():
305
+
220
306
  # Get the contract factory and deploy the contract
221
307
  factory = get_contract_factory("Storage")
222
- contract = factory.deploy(account=default_account)
223
-
308
+ contract = factory.deploy()
309
+
224
310
  # Call a read-only method
225
311
  result = contract.get_value(args=[])
226
312
 
@@ -10,8 +10,6 @@ genlayer_test.egg-info/top_level.txt
10
10
  gltest/__init__.py
11
11
  gltest/assertions.py
12
12
  gltest/exceptions.py
13
- gltest/plugin_config.py
14
- gltest/plugin_hooks.py
15
13
  gltest/types.py
16
14
  gltest/artifacts/__init__.py
17
15
  gltest/artifacts/contract.py
@@ -22,12 +20,16 @@ gltest/glchain/contract.py
22
20
  gltest/helpers/__init__.py
23
21
  gltest/helpers/fixture_snapshot.py
24
22
  gltest/helpers/take_snapshot.py
23
+ gltest_cli/logging.py
25
24
  gltest_cli/main.py
26
- tests/artifact/test_contract_definition.py
27
- tests/artifact/contracts/duplicate_ic_contract_1.py
28
- tests/artifact/contracts/duplicate_ic_contract_2.py
29
- tests/artifact/contracts/not_ic_contract.py
30
- tests/assertions/test_assertions.py
25
+ gltest_cli/config/__init__.py
26
+ gltest_cli/config/constants.py
27
+ gltest_cli/config/general.py
28
+ gltest_cli/config/plugin.py
29
+ gltest_cli/config/types.py
30
+ gltest_cli/config/user.py
31
+ tests/__init__.py
32
+ tests/conftest.py
31
33
  tests/examples/contracts/football_prediction_market.py
32
34
  tests/examples/contracts/intelligent_oracle.py
33
35
  tests/examples/contracts/intelligent_oracle_factory.py
@@ -54,5 +56,13 @@ tests/examples/tests/test_storage.py
54
56
  tests/examples/tests/test_storage_legacy.py
55
57
  tests/examples/tests/test_user_storage.py
56
58
  tests/examples/tests/test_wizard_of_coin.py
57
- tests/plugin/conftest.py
58
- tests/plugin/test_plugin_hooks.py
59
+ tests/gltest/__init__.py
60
+ tests/gltest/artifact/__init__.py
61
+ tests/gltest/artifact/test_contract_definition.py
62
+ tests/gltest/artifact/contracts/duplicate_ic_contract_1.py
63
+ tests/gltest/artifact/contracts/duplicate_ic_contract_2.py
64
+ tests/gltest/artifact/contracts/not_ic_contract.py
65
+ tests/gltest/assertions/test_assertions.py
66
+ tests/gltest_cli/__init__.py
67
+ tests/gltest_cli/config/test_plugin.py
68
+ tests/gltest_cli/config/test_user.py
@@ -2,4 +2,4 @@
2
2
  gltest = gltest_cli.main:main
3
3
 
4
4
  [pytest11]
5
- gltest = gltest.plugin_hooks
5
+ gltest = gltest_cli.config.plugin
@@ -0,0 +1,6 @@
1
+ pytest
2
+ setuptools>=77.0
3
+ genlayer-py==0.5.0
4
+ colorama>=0.4.6
5
+ pyyaml
6
+ python-dotenv
@@ -3,8 +3,8 @@ from gltest.glchain import (
3
3
  create_accounts,
4
4
  get_contract_factory,
5
5
  get_gl_client,
6
- default_account,
7
- accounts,
6
+ get_accounts,
7
+ get_default_account,
8
8
  )
9
9
 
10
10
  __all__ = [
@@ -13,6 +13,6 @@ __all__ = [
13
13
  "create_accounts",
14
14
  "get_contract_factory",
15
15
  "get_gl_client",
16
- "default_account",
17
- "accounts",
16
+ "get_accounts",
17
+ "get_default_account",
18
18
  ]
@@ -2,7 +2,7 @@ import ast
2
2
  from typing import Optional
3
3
  from dataclasses import dataclass
4
4
  from pathlib import Path
5
- from gltest.plugin_config import get_contracts_dir
5
+ from gltest_cli.config.general import get_general_config
6
6
  import io
7
7
  import zipfile
8
8
  from typing import Union
@@ -21,9 +21,12 @@ class ContractDefinition:
21
21
  def search_path_by_class_name(contracts_dir: Path, contract_name: str) -> Path:
22
22
  """Search for a file by class name in the contracts directory."""
23
23
  matching_files = []
24
+ exclude_dirs = {".venv", "venv", "env", "build", "dist", "__pycache__", ".git"}
24
25
 
25
26
  for file_path in contracts_dir.rglob("*"):
26
- if not file_path.suffix in [".gpy", ".py"]:
27
+ if any(exclude_dir in file_path.parts for exclude_dir in exclude_dirs):
28
+ continue
29
+ if file_path.suffix not in [".gpy", ".py"]:
27
30
  continue
28
31
  try:
29
32
  # Read the file content
@@ -142,7 +145,8 @@ def find_contract_definition_from_name(
142
145
  """
143
146
  Search in the contracts directory for a contract definition.
144
147
  """
145
- contracts_dir = get_contracts_dir()
148
+ general_config = get_general_config()
149
+ contracts_dir = general_config.get_contracts_dir()
146
150
  if not contracts_dir.exists():
147
151
  raise FileNotFoundError(f"Contracts directory not found at: {contracts_dir}")
148
152
 
@@ -156,7 +160,8 @@ def find_contract_definition_from_path(
156
160
  """
157
161
  Create a ContractDefinition from a given file path relative to the contracts directory.
158
162
  """
159
- contracts_dir = get_contracts_dir()
163
+ general_config = get_general_config()
164
+ contracts_dir = general_config.get_contracts_dir()
160
165
  if not contracts_dir.exists():
161
166
  raise FileNotFoundError(f"Contracts directory not found at: {contracts_dir}")
162
167
 
@@ -1,6 +1,6 @@
1
1
  from .contract import Contract, ContractFactory, get_contract_factory
2
2
  from .client import get_gl_client, get_gl_provider
3
- from .account import create_accounts, create_account, accounts, default_account
3
+ from .account import create_account, get_accounts, get_default_account, create_accounts
4
4
 
5
5
 
6
6
  __all__ = [
@@ -8,9 +8,9 @@ __all__ = [
8
8
  "ContractFactory",
9
9
  "get_contract_factory",
10
10
  "create_account",
11
- "default_account",
12
- "accounts",
13
11
  "create_accounts",
12
+ "get_accounts",
13
+ "get_default_account",
14
14
  "get_gl_client",
15
15
  "get_gl_provider",
16
16
  ]
@@ -0,0 +1,22 @@
1
+ from gltest_cli.config.general import get_general_config
2
+ from genlayer_py import create_account
3
+ from eth_account.signers.local import LocalAccount
4
+ from typing import List
5
+
6
+
7
+ def create_accounts(n_accounts: int):
8
+ return [create_account() for _ in range(n_accounts)]
9
+
10
+
11
+ def get_accounts() -> List[LocalAccount]:
12
+ general_config = get_general_config()
13
+ selected_network = general_config.get_network_name()
14
+ accounts = general_config.get_accounts_keys(selected_network)
15
+ return [create_account(account) for account in accounts]
16
+
17
+
18
+ def get_default_account() -> LocalAccount:
19
+ general_config = get_general_config()
20
+ selected_network = general_config.get_network_name()
21
+ default_account_key = general_config.get_default_account_key(selected_network)
22
+ return create_account(default_account_key)
@@ -0,0 +1,59 @@
1
+ from genlayer_py.chains import localnet
2
+ from genlayer_py import create_client
3
+ from .account import get_default_account
4
+ from functools import lru_cache
5
+ from gltest_cli.config.general import get_general_config
6
+
7
+
8
+ @lru_cache(maxsize=1)
9
+ def get_gl_client():
10
+ """
11
+ Get the GenLayer client instance.
12
+ """
13
+ general_config = get_general_config()
14
+ chain = general_config.get_chain()
15
+ default_account = get_default_account()
16
+ endpoint = general_config.get_rpc_url()
17
+ return create_client(
18
+ chain=chain,
19
+ account=default_account,
20
+ endpoint=endpoint,
21
+ )
22
+
23
+
24
+ @lru_cache(maxsize=1)
25
+ def get_gl_hosted_studio_client():
26
+ """
27
+ Get the GenLayer hosted studio client instance.
28
+
29
+ Note: This is a temporary solution to get contract schema.
30
+ TODO: Remove this once we have a proper way to get contract schema from testnet.
31
+ """
32
+ return create_client(
33
+ chain=localnet,
34
+ account=get_default_account(),
35
+ endpoint="https://studio.genlayer.com/api",
36
+ )
37
+
38
+
39
+ @lru_cache(maxsize=1)
40
+ def get_local_client():
41
+ """
42
+ Get the GenLayer local client instance.
43
+
44
+ Note: This is a temporary solution to get contract schema.
45
+ TODO: Remove this once we have a proper way to get contract schema from testnet.
46
+ """
47
+ return create_client(
48
+ chain=localnet,
49
+ account=get_default_account(),
50
+ endpoint="http://127.0.0.1:4000/api",
51
+ )
52
+
53
+
54
+ def get_gl_provider():
55
+ """
56
+ Get the GenLayer provider instance.
57
+ """
58
+ client = get_gl_client()
59
+ return client.provider