genlayer-test 0.8.0__py3-none-any.whl → 0.10.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {genlayer_test-0.8.0.dist-info → genlayer_test-0.10.0.dist-info}/METADATA +77 -177
- genlayer_test-0.10.0.dist-info/RECORD +38 -0
- {genlayer_test-0.8.0.dist-info → genlayer_test-0.10.0.dist-info}/top_level.txt +0 -1
- gltest/fixtures.py +1 -50
- gltest_cli/config/constants.py +6 -0
- gltest_cli/config/plugin.py +19 -12
- gltest_cli/config/types.py +70 -49
- gltest_cli/config/user.py +79 -7
- genlayer_test-0.8.0.dist-info/RECORD +0 -82
- tests/__init__.py +0 -0
- tests/conftest.py +0 -1
- tests/examples/contracts/football_prediction_market.py +0 -100
- tests/examples/contracts/intelligent_oracle.py +0 -370
- tests/examples/contracts/intelligent_oracle_factory.py +0 -49
- tests/examples/contracts/invalid_deploy.py +0 -10
- tests/examples/contracts/llm_erc20.py +0 -70
- tests/examples/contracts/log_indexer.py +0 -69
- tests/examples/contracts/multi_file_contract/__init__.py +0 -24
- tests/examples/contracts/multi_file_contract/other.py +0 -14
- tests/examples/contracts/multi_read_erc20.py +0 -29
- tests/examples/contracts/multi_tenant_storage.py +0 -51
- tests/examples/contracts/read_erc20.py +0 -19
- tests/examples/contracts/simple_time_contract.py +0 -85
- tests/examples/contracts/storage.py +0 -23
- tests/examples/contracts/user_storage.py +0 -25
- tests/examples/contracts/wizard_of_coin.py +0 -57
- tests/examples/tests/test_custom_validators.py +0 -65
- tests/examples/tests/test_football_prediction_market.py +0 -38
- tests/examples/tests/test_intelligent_oracle_factory.py +0 -162
- tests/examples/tests/test_invalid_deploy.py +0 -24
- tests/examples/tests/test_llm_erc20.py +0 -60
- tests/examples/tests/test_llm_erc20_analyze.py +0 -54
- tests/examples/tests/test_log_indexer.py +0 -76
- tests/examples/tests/test_multi_file_contract.py +0 -15
- tests/examples/tests/test_multi_read_erc20.py +0 -103
- tests/examples/tests/test_multi_tenant_storage.py +0 -76
- tests/examples/tests/test_read_erc20.py +0 -38
- tests/examples/tests/test_simple_time_contract.py +0 -90
- tests/examples/tests/test_storage.py +0 -26
- tests/examples/tests/test_user_storage.py +0 -87
- tests/examples/tests/test_wizard_of_coin.py +0 -27
- tests/gltest/__init__.py +0 -0
- tests/gltest/artifact/__init__.py +0 -0
- tests/gltest/artifact/contracts/duplicate_ic_contract_1.py +0 -22
- tests/gltest/artifact/contracts/duplicate_ic_contract_2.py +0 -22
- tests/gltest/artifact/contracts/not_ic_contract.py +0 -22
- tests/gltest/artifact/test_contract_definition.py +0 -55
- tests/gltest/assertions/test_assertions.py +0 -344
- tests/gltest_cli/__init__.py +0 -0
- tests/gltest_cli/config/test_config_integration.py +0 -432
- tests/gltest_cli/config/test_general_config.py +0 -406
- tests/gltest_cli/config/test_plugin.py +0 -290
- tests/gltest_cli/config/test_user.py +0 -411
- {genlayer_test-0.8.0.dist-info → genlayer_test-0.10.0.dist-info}/WHEEL +0 -0
- {genlayer_test-0.8.0.dist-info → genlayer_test-0.10.0.dist-info}/entry_points.txt +0 -0
- {genlayer_test-0.8.0.dist-info → genlayer_test-0.10.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: genlayer-test
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.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)
|
|
@@ -261,31 +270,7 @@ $ gltest --default-wait-interval <default_wait_interval>
|
|
|
261
270
|
$ gltest --default-wait-retries <default_wait_retries>
|
|
262
271
|
```
|
|
263
272
|
|
|
264
|
-
10. Run tests with
|
|
265
|
-
```bash
|
|
266
|
-
$ gltest --test-with-mocks
|
|
267
|
-
```
|
|
268
|
-
The `--test-with-mocks` flag enables mocking of LLM responses when creating validators. This is particularly useful for:
|
|
269
|
-
- Testing without actual LLM API calls
|
|
270
|
-
- Ensuring deterministic test results
|
|
271
|
-
- Faster test execution
|
|
272
|
-
- Testing specific edge cases with controlled responses
|
|
273
|
-
|
|
274
|
-
When using this flag with the `setup_validators` fixture, you can provide custom mock responses:
|
|
275
|
-
```python
|
|
276
|
-
def test_with_mocked_llm(setup_validators):
|
|
277
|
-
# Setup validators with a specific mock response
|
|
278
|
-
mock_response = {"result": "This is a mocked LLM response"}
|
|
279
|
-
setup_validators(mock_response=mock_response)
|
|
280
|
-
|
|
281
|
-
# Your LLM-based contract will receive the mocked response
|
|
282
|
-
contract = factory.deploy()
|
|
283
|
-
result = contract.llm_method() # Will use the mocked response
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
Note: This feature is only available when running tests on localnet.
|
|
287
|
-
|
|
288
|
-
11. Run tests with leader-only mode enabled
|
|
273
|
+
10. Run tests with leader-only mode enabled
|
|
289
274
|
```bash
|
|
290
275
|
$ gltest --leader-only
|
|
291
276
|
```
|
|
@@ -299,6 +284,24 @@ When this flag is enabled, all contracts deployed and all write transactions wil
|
|
|
299
284
|
|
|
300
285
|
**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
286
|
|
|
287
|
+
12. Override the chain type
|
|
288
|
+
```bash
|
|
289
|
+
$ gltest --chain-type localnet
|
|
290
|
+
$ gltest --chain-type studionet
|
|
291
|
+
$ gltest --chain-type testnet_asimov
|
|
292
|
+
```
|
|
293
|
+
The `--chain-type` flag allows you to override the chain type configured for the network. This is useful when:
|
|
294
|
+
- Testing different chain behaviors without changing network configuration
|
|
295
|
+
- Switching between chain types for testing purposes
|
|
296
|
+
- Using a custom network URL with a specific chain type
|
|
297
|
+
|
|
298
|
+
Available chain types:
|
|
299
|
+
- `localnet`: Local development chain
|
|
300
|
+
- `studionet`: Studio-based chain
|
|
301
|
+
- `testnet_asimov`: Testnet Asimov chain
|
|
302
|
+
|
|
303
|
+
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.
|
|
304
|
+
|
|
302
305
|
## 🚀 Key Features
|
|
303
306
|
|
|
304
307
|
- **Pytest Integration** – Extends pytest to support intelligent contract testing, making it familiar and easy to adopt.
|
|
@@ -448,7 +451,7 @@ def test_write_methods():
|
|
|
448
451
|
).transact(
|
|
449
452
|
value=0, # Optional: amount of native currency to send
|
|
450
453
|
consensus_max_rotations=3, # Optional: max consensus rotations
|
|
451
|
-
wait_interval=
|
|
454
|
+
wait_interval=1000, # Optional: milliseconds between status checks
|
|
452
455
|
wait_retries=10, # Optional: max number of retries
|
|
453
456
|
transaction_context=None, # Optional: custom transaction context
|
|
454
457
|
)
|
|
@@ -511,7 +514,6 @@ The following fixtures are available in `gltest.fixtures`:
|
|
|
511
514
|
- **`gl_client`** (session scope) - GenLayer client instance for network operations
|
|
512
515
|
- **`default_account`** (session scope) - Default account for testing and deployments
|
|
513
516
|
- **`accounts`** (session scope) - List of test accounts for multi-account scenarios
|
|
514
|
-
- **`setup_validators`** (function scope) - Function to create test validators for LLM operations
|
|
515
517
|
|
|
516
518
|
##### 1. `gl_client` (session scope)
|
|
517
519
|
Provides a GenLayer PY client instance that's created once per test session. This is useful for operations that interact directly with the GenLayer network.
|
|
@@ -546,26 +548,6 @@ def test_multiple_accounts(accounts):
|
|
|
546
548
|
contract.transfer(args=[receiver.address, 100], account=sender)
|
|
547
549
|
```
|
|
548
550
|
|
|
549
|
-
##### 4. `setup_validators` (function scope)
|
|
550
|
-
Creates test validators for localnet environment. This fixture is particularly useful for testing LLM-based contract methods and consensus behavior. It yields a function that allows you to configure validators with custom settings.
|
|
551
|
-
|
|
552
|
-
```python
|
|
553
|
-
def test_with_validators(setup_validators):
|
|
554
|
-
# Setup validators with default configuration
|
|
555
|
-
setup_validators()
|
|
556
|
-
|
|
557
|
-
# Or setup with custom mock responses for testing
|
|
558
|
-
mock_response = {"result": "mocked LLM response"}
|
|
559
|
-
setup_validators(mock_response=mock_response, n_validators=3)
|
|
560
|
-
|
|
561
|
-
# Now test your LLM-based contract methods
|
|
562
|
-
contract = factory.deploy()
|
|
563
|
-
result = contract.llm_based_method()
|
|
564
|
-
```
|
|
565
|
-
|
|
566
|
-
Parameters for `setup_validators`:
|
|
567
|
-
- `mock_response` (dict, optional): Mock validator response when using `--test-with-mocks` flag
|
|
568
|
-
- `n_validators` (int, optional): Number of validators to create (default: 5)
|
|
569
551
|
|
|
570
552
|
#### Using Fixtures in Your Tests
|
|
571
553
|
|
|
@@ -575,9 +557,7 @@ To use these fixtures, simply import them and include them as parameters in your
|
|
|
575
557
|
from gltest import get_contract_factory
|
|
576
558
|
from gltest.assertions import tx_execution_succeeded
|
|
577
559
|
|
|
578
|
-
def test_complete_workflow(gl_client, default_account, accounts
|
|
579
|
-
# Setup validators for LLM operations
|
|
580
|
-
setup_validators()
|
|
560
|
+
def test_complete_workflow(gl_client, default_account, accounts):
|
|
581
561
|
|
|
582
562
|
# Deploy contract with default account
|
|
583
563
|
factory = get_contract_factory("MyContract")
|
|
@@ -623,7 +603,7 @@ def test_analyze_method():
|
|
|
623
603
|
print(f"Reliability score: {analysis.reliability_score:.2f}%")
|
|
624
604
|
print(f"Unique states: {analysis.unique_states}")
|
|
625
605
|
print(f"Execution time: {analysis.execution_time:.1f}s")
|
|
626
|
-
|
|
606
|
+
|
|
627
607
|
# The analysis returns a MethodStatsSummary object with:
|
|
628
608
|
# - method: The contract method name
|
|
629
609
|
# - args: Arguments passed to the method
|
|
@@ -641,127 +621,6 @@ The `.analyze()` method helps you:
|
|
|
641
621
|
- Identify edge cases and failure patterns
|
|
642
622
|
- Benchmark performance across multiple runs
|
|
643
623
|
|
|
644
|
-
### Mock LLM Responses
|
|
645
|
-
|
|
646
|
-
The Mock LLM system allows you to simulate Large Language Model responses in GenLayer tests. This is essential for creating deterministic tests by providing predefined responses instead of relying on actual LLM calls.
|
|
647
|
-
|
|
648
|
-
#### Basic Structure
|
|
649
|
-
|
|
650
|
-
The mock system consists of a response dictionary that maps GenLayer methods to their mocked responses:
|
|
651
|
-
|
|
652
|
-
```python
|
|
653
|
-
mock_response = {
|
|
654
|
-
"response": {}, # Optional: mocks gl.nondet.exec_prompt
|
|
655
|
-
"eq_principle_prompt_comparative": {}, # Optional: mocks gl.eq_principle.prompt_comparative
|
|
656
|
-
"eq_principle_prompt_non_comparative": {} # Optional: mocks gl.eq_principle.prompt_non_comparative
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
setup_validators(mock_response)
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
#### Method Mappings
|
|
663
|
-
|
|
664
|
-
| Mock Key | GenLayer Method |
|
|
665
|
-
|----------|----------------|
|
|
666
|
-
| `"response"` | `gl.nondet.exec_prompt` |
|
|
667
|
-
| `"eq_principle_prompt_comparative"` | `gl.eq_principle.prompt_comparative` |
|
|
668
|
-
| `"eq_principle_prompt_non_comparative"` | `gl.eq_principle.prompt_non_comparative` |
|
|
669
|
-
|
|
670
|
-
#### How It Works
|
|
671
|
-
|
|
672
|
-
The mock system works by pattern matching against the user message that gets built internally. When a GenLayer method is called:
|
|
673
|
-
|
|
674
|
-
1. A user message is constructed internally (`<user_message>`)
|
|
675
|
-
2. The mock system searches for strings within that message
|
|
676
|
-
3. If a matching string is found in the mock dictionary, the associated response is returned
|
|
677
|
-
|
|
678
|
-
##### String Matching Rules
|
|
679
|
-
|
|
680
|
-
The system performs **substring matching** on the user message. The key in your mock dictionary must be contained within the actual user message.
|
|
681
|
-
|
|
682
|
-
#### Examples
|
|
683
|
-
|
|
684
|
-
##### Basic Example
|
|
685
|
-
|
|
686
|
-
```python
|
|
687
|
-
# Mock setup
|
|
688
|
-
mock_response = {
|
|
689
|
-
"eq_principle_prompt_comparative": {
|
|
690
|
-
"The value of give_coin has to match": True
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
setup_validators(mock_response)
|
|
694
|
-
|
|
695
|
-
# In your contract
|
|
696
|
-
result = gl.eq_principle.prompt_comparative(
|
|
697
|
-
get_wizard_answer,
|
|
698
|
-
"The value of give_coin has to match" # This string will be matched
|
|
699
|
-
)
|
|
700
|
-
# result will be True
|
|
701
|
-
```
|
|
702
|
-
|
|
703
|
-
##### Substring Matching Examples
|
|
704
|
-
|
|
705
|
-
✅ **Will work** - Partial match:
|
|
706
|
-
```python
|
|
707
|
-
"eq_principle_prompt_comparative": {
|
|
708
|
-
"The value of give_coin": True # Substring of the full message
|
|
709
|
-
}
|
|
710
|
-
```
|
|
711
|
-
|
|
712
|
-
❌ **Won't work** - Extra words break the match:
|
|
713
|
-
```python
|
|
714
|
-
"eq_principle_prompt_comparative": {
|
|
715
|
-
"The good value of give_coin": True # "good" is not in the actual message
|
|
716
|
-
}
|
|
717
|
-
```
|
|
718
|
-
|
|
719
|
-
##### Complete Example
|
|
720
|
-
|
|
721
|
-
```python
|
|
722
|
-
from gltest import get_contract_factory
|
|
723
|
-
from gltest.fixtures import setup_validators
|
|
724
|
-
|
|
725
|
-
def test_with_mocked_llm(setup_validators):
|
|
726
|
-
# Define mock responses
|
|
727
|
-
mock_response = {
|
|
728
|
-
"response": {
|
|
729
|
-
"What is the weather?": "It's sunny today",
|
|
730
|
-
"Calculate 2+2": "4"
|
|
731
|
-
},
|
|
732
|
-
"eq_principle_prompt_comparative": {
|
|
733
|
-
"values must be equal": True,
|
|
734
|
-
"amounts should match": False
|
|
735
|
-
},
|
|
736
|
-
"eq_principle_prompt_non_comparative": {
|
|
737
|
-
"Is this valid?": True
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
# Initialize the mock system
|
|
742
|
-
setup_validators(mock_response)
|
|
743
|
-
|
|
744
|
-
# Deploy and test your contract
|
|
745
|
-
factory = get_contract_factory("MyLLMContract")
|
|
746
|
-
contract = factory.deploy()
|
|
747
|
-
|
|
748
|
-
# Your LLM methods will use the mocked responses
|
|
749
|
-
result = contract.check_weather() # Uses mocked response
|
|
750
|
-
```
|
|
751
|
-
|
|
752
|
-
#### Best Practices
|
|
753
|
-
|
|
754
|
-
1. **Be specific with match strings**: Use unique substrings that won't accidentally match other prompts
|
|
755
|
-
2. **Test your matches**: Verify that your mock strings actually appear in the generated user messages
|
|
756
|
-
3. **Keep mocks simple**: Mock responses should be minimal and focused on the test case
|
|
757
|
-
4. **Document your mocks**: Comment why specific responses are mocked for future reference
|
|
758
|
-
5. **Use with `--test-with-mocks` flag**: Enable mocking when running tests: `gltest --test-with-mocks`
|
|
759
|
-
|
|
760
|
-
#### Notes
|
|
761
|
-
|
|
762
|
-
- Mock responses are only available when running tests on localnet
|
|
763
|
-
- The `setup_validators` fixture handles the mock setup when provided with a mock_response
|
|
764
|
-
- Mocking is particularly useful for CI/CD pipelines where deterministic results are required
|
|
765
624
|
|
|
766
625
|
### Custom Transaction Context
|
|
767
626
|
|
|
@@ -812,17 +671,58 @@ def test_with_custom_transaction_context():
|
|
|
812
671
|
)
|
|
813
672
|
```
|
|
814
673
|
|
|
674
|
+
### Mock LLM Responses
|
|
675
|
+
|
|
676
|
+
The Mock LLM system allows you to simulate Large Language Model responses in GenLayer tests. This is essential for creating deterministic tests by providing predefined responses instead of relying on actual LLM calls.
|
|
677
|
+
|
|
678
|
+
#### Basic Structure
|
|
679
|
+
|
|
680
|
+
The mock system consists of a response dictionary that maps GenLayer methods to their mocked responses:
|
|
681
|
+
|
|
682
|
+
```python
|
|
683
|
+
from gltest.types import MockedLLMResponse
|
|
684
|
+
|
|
685
|
+
mock_response: MockedLLMResponse = {
|
|
686
|
+
"nondet_exec_prompt": {}, # Optional: mocks gl.nondet.exec_prompt
|
|
687
|
+
"eq_principle_prompt_comparative": {}, # Optional: mocks gl.eq_principle.prompt_comparative
|
|
688
|
+
"eq_principle_prompt_non_comparative": {} # Optional: mocks gl.eq_principle.prompt_non_comparative
|
|
689
|
+
}
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
#### Method Mappings
|
|
693
|
+
|
|
694
|
+
| Mock Key | GenLayer Method |
|
|
695
|
+
|----------|----------------|
|
|
696
|
+
| `"nondet_exec_prompt"` | `gl.nondet.exec_prompt` |
|
|
697
|
+
| `"eq_principle_prompt_comparative"` | `gl.eq_principle.prompt_comparative` |
|
|
698
|
+
| `"eq_principle_prompt_non_comparative"` | `gl.eq_principle.prompt_non_comparative` |
|
|
699
|
+
|
|
700
|
+
#### How It Works
|
|
701
|
+
|
|
702
|
+
The mock system works by pattern matching against the user message that gets built internally. When a GenLayer method is called:
|
|
703
|
+
|
|
704
|
+
1. A user message is constructed internally (`<user_message>`)
|
|
705
|
+
2. The mock system searches for strings within that message
|
|
706
|
+
3. If a matching string is found in the mock dictionary, the associated response is returned
|
|
707
|
+
|
|
708
|
+
##### String Matching Rules
|
|
709
|
+
|
|
710
|
+
The system performs **substring matching** on the user message. The key in your mock dictionary must be contained within the actual user message.
|
|
711
|
+
|
|
712
|
+
|
|
815
713
|
#### Mock Validators with Transaction Context
|
|
816
714
|
|
|
817
715
|
Combine mock validators with custom datetime for fully deterministic tests:
|
|
818
716
|
|
|
819
717
|
```python
|
|
718
|
+
from gltest.types import MockedLLMResponse
|
|
719
|
+
|
|
820
720
|
def test_with_mocked_context():
|
|
821
721
|
factory = get_contract_factory("LLMContract")
|
|
822
722
|
validator_factory = get_validator_factory()
|
|
823
723
|
|
|
824
724
|
# Define mock LLM responses
|
|
825
|
-
mock_response = {
|
|
725
|
+
mock_response: MockedLLMResponse = {
|
|
826
726
|
"nondet_exec_prompt": {
|
|
827
727
|
"analyze this": "positive sentiment"
|
|
828
728
|
},
|
|
@@ -1014,7 +914,7 @@ def test_validator_cloning():
|
|
|
1014
914
|
tx_receipt = contract.set_value(
|
|
1015
915
|
args=["new_value"],
|
|
1016
916
|
).transact(
|
|
1017
|
-
wait_interval=
|
|
917
|
+
wait_interval=2000, # Increase wait interval between status checks
|
|
1018
918
|
wait_retries=20, # Increase number of retry attempts
|
|
1019
919
|
)
|
|
1020
920
|
```
|
|
@@ -1031,7 +931,7 @@ def test_validator_cloning():
|
|
|
1031
931
|
# For critical operations, use more conservative settings
|
|
1032
932
|
contract = factory.deploy(
|
|
1033
933
|
consensus_max_rotations=10, # More rotations for better reliability
|
|
1034
|
-
wait_interval=
|
|
934
|
+
wait_interval=3000, # Longer wait between checks
|
|
1035
935
|
wait_retries=30 # More retries for consensus
|
|
1036
936
|
)
|
|
1037
937
|
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
genlayer_test-0.10.0.dist-info/licenses/LICENSE,sha256=che_H4vE0QUx3HvWrAa1_jDEVInift0U6VO15-QqEls,1064
|
|
2
|
+
gltest/__init__.py,sha256=49112x2CLdYwvCbBZ1laJmMk0NQ7S3u5YUbxPefqhrk,454
|
|
3
|
+
gltest/accounts.py,sha256=HUmWguJMolggQaZNRPw-LGlRlQCjLLdUanKRowMv6pI,812
|
|
4
|
+
gltest/assertions.py,sha256=0dEk0VxcHK4I7GZPHxJmz-2jaA60V499gOSR74rZbfM,1748
|
|
5
|
+
gltest/clients.py,sha256=1dX6wmG3QCevQRLbSaFlHymZSb-sJ5aYwet1IoX2nbA,1554
|
|
6
|
+
gltest/exceptions.py,sha256=deJPmrTe5gF33qkkKF2IVJY7lc_knI7Ql3N7jZ8aLZs,510
|
|
7
|
+
gltest/fixtures.py,sha256=omVjLh1kXXUyL7Oo8zzdooJBbSX-Qk-Aa-prp5MqvFc,833
|
|
8
|
+
gltest/logging.py,sha256=jAkHsuMm-AEx1Xu1srU6W-0YzTwXJB48mCK-OVzAiN4,342
|
|
9
|
+
gltest/types.py,sha256=H32fHrU5aFMaPHXgEWcHAmLWOZ9pBFVp8PK_ncpVOgM,940
|
|
10
|
+
gltest/utils.py,sha256=-gHhjrS7i_GhDG3sKOq2qsTtYBt4HHgXHEXh-3RB_rI,573
|
|
11
|
+
gltest/artifacts/__init__.py,sha256=qTt3TE19gVNWnQLUlt5aDe4nNvJ2YJ1jzDkMmYIsCG0,194
|
|
12
|
+
gltest/artifacts/contract.py,sha256=KChpmfjZod_0dVB8y-dvWz6IVm7QlIJsgG2ArtvVDaU,6457
|
|
13
|
+
gltest/contracts/__init__.py,sha256=A9bvEtYOoqoHS8TLlFBfmNOnfwdsJPEf-AZuikagCHM,166
|
|
14
|
+
gltest/contracts/contract.py,sha256=jLF_ojSM6IIbdGO2_DhsO79r2wZ2Z8eBAJRrZk2qVTI,7748
|
|
15
|
+
gltest/contracts/contract_factory.py,sha256=PpWh4mKf1hDMv_yms5lwFV_EoXxXiuNfdXbwD74hbAU,8929
|
|
16
|
+
gltest/contracts/contract_functions.py,sha256=W6Dpw1z-n9EeJxlNtIbeVnzpv4BPABhtgmgjnS8-P0w,2573
|
|
17
|
+
gltest/contracts/method_stats.py,sha256=zWWjvf7K5VC4yrHpDIR717VF7LYp1RaZ1Hr_RZvWxJA,5150
|
|
18
|
+
gltest/contracts/stats_collector.py,sha256=iwsnoYo5aZbI4SVMH7dR-5CQgkglExXfsvaUDpwcdss,9286
|
|
19
|
+
gltest/contracts/utils.py,sha256=TTXgcXn9BuRIlKJrjwmU7R3l1IgXsXk2luM-r3lfbbg,296
|
|
20
|
+
gltest/helpers/__init__.py,sha256=I7HiTu_H7_hP65zY6Wl02r-5eAMr2eZvqBVmusuQLX4,180
|
|
21
|
+
gltest/helpers/fixture_snapshot.py,sha256=bMgvlEVQBGIQzj7NOyosXWlphI1H2C1o75Zo0C-kGfQ,1931
|
|
22
|
+
gltest/helpers/take_snapshot.py,sha256=-QkaBvFG4ZsNKv_nCSEsy5Ze1pICOHxVhReSeQmZUlY,1276
|
|
23
|
+
gltest/validators/__init__.py,sha256=AXboXORF5a8MVtG7jWMT1fJcwGXNzcX6txXQstwX2EU,152
|
|
24
|
+
gltest/validators/validator_factory.py,sha256=fpb-YyAKuWo4-pXBjrZ_TApYLsm6HHa6kGpbFByRucs,3886
|
|
25
|
+
gltest_cli/logging.py,sha256=WXVhfq9vT6FtV_jxDqGEGia1ZWSIUKAfmWRnZd_gWQk,1266
|
|
26
|
+
gltest_cli/main.py,sha256=Ti2-0Ev1x5_cM0D1UKqdgaDt80CDHEQGtdRne2qLm4M,53
|
|
27
|
+
gltest_cli/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
|
+
gltest_cli/config/constants.py,sha256=z7njbU8WXYhTnp1NYrW4YI2jN-p114BP2UDSYF0qAJE,571
|
|
29
|
+
gltest_cli/config/general.py,sha256=ezpoGsT8grO9zQH6RugV14b1GzeFt-htYToHQBJhNvY,186
|
|
30
|
+
gltest_cli/config/plugin.py,sha256=rySUyo7OSG1SOiUx2Xrxiv-SfjaxJSWpT5KKKNRk4Mk,6719
|
|
31
|
+
gltest_cli/config/pytest_context.py,sha256=Ze8JSkrwMTCE8jIhpzU_71CEXg92SiEPvSgNTp-gbS4,243
|
|
32
|
+
gltest_cli/config/types.py,sha256=c_4Ya8M9pxQmceSGgcgBIN-5hmrJxAnPFXkTzD7qrtI,9492
|
|
33
|
+
gltest_cli/config/user.py,sha256=JeclpIVv4BT5COMW2xrEbTspI6e1RAYIOvd8ruPc3gM,12887
|
|
34
|
+
genlayer_test-0.10.0.dist-info/METADATA,sha256=CR7BasEbdFf2WiG8ue3KkMNNAVlRmeF8xBn6-liq4E8,36341
|
|
35
|
+
genlayer_test-0.10.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
36
|
+
genlayer_test-0.10.0.dist-info/entry_points.txt,sha256=RWPcSArBpz_G4BYioh5L8Q8hyClRbSgzLimjcWMp-BQ,94
|
|
37
|
+
genlayer_test-0.10.0.dist-info/top_level.txt,sha256=GSdrnQbiLcZssmtCpbDgBTygsc8Bt_TPeYjwm0FmpdA,18
|
|
38
|
+
genlayer_test-0.10.0.dist-info/RECORD,,
|
gltest/fixtures.py
CHANGED
|
@@ -4,9 +4,8 @@ These fixtures can be imported and used in test files.
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
import pytest
|
|
7
|
-
from gltest.clients import get_gl_client
|
|
7
|
+
from gltest.clients import get_gl_client
|
|
8
8
|
from gltest.accounts import get_accounts, get_default_account
|
|
9
|
-
from gltest_cli.config.general import get_general_config
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
@pytest.fixture(scope="session")
|
|
@@ -37,51 +36,3 @@ def accounts():
|
|
|
37
36
|
Scope: session - created once per test session
|
|
38
37
|
"""
|
|
39
38
|
return get_accounts()
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@pytest.fixture(scope="function")
|
|
43
|
-
def setup_validators():
|
|
44
|
-
"""
|
|
45
|
-
Creates test validators for localnet environment.
|
|
46
|
-
|
|
47
|
-
Args:
|
|
48
|
-
mock_response (dict, optional): Mock validator response when using --test-with-mocks flag
|
|
49
|
-
n_validators (int, optional): Number of validators to create (default: 5)
|
|
50
|
-
|
|
51
|
-
Scope: function - created fresh for each test
|
|
52
|
-
"""
|
|
53
|
-
general_config = get_general_config()
|
|
54
|
-
provider = get_gl_provider()
|
|
55
|
-
|
|
56
|
-
def _setup(mock_response=None, n_validators=5):
|
|
57
|
-
if not general_config.check_local_rpc():
|
|
58
|
-
return
|
|
59
|
-
if general_config.get_test_with_mocks():
|
|
60
|
-
for _ in range(n_validators):
|
|
61
|
-
provider.make_request(
|
|
62
|
-
method="sim_createValidator",
|
|
63
|
-
params=[
|
|
64
|
-
8,
|
|
65
|
-
"openai",
|
|
66
|
-
"gpt-4o",
|
|
67
|
-
{"temperature": 0.75, "max_tokens": 500},
|
|
68
|
-
"openai-compatible",
|
|
69
|
-
{
|
|
70
|
-
"api_key_env_var": "OPENAIKEY",
|
|
71
|
-
"api_url": "https://api.openai.com",
|
|
72
|
-
"mock_response": mock_response if mock_response else {},
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
)
|
|
76
|
-
else:
|
|
77
|
-
provider.make_request(
|
|
78
|
-
method="sim_createRandomValidators",
|
|
79
|
-
params=[n_validators, 8, 12],
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
yield _setup
|
|
83
|
-
|
|
84
|
-
if not general_config.check_local_rpc():
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
provider.make_request(method="sim_deleteAllValidators", params=[])
|
gltest_cli/config/constants.py
CHANGED
|
@@ -5,8 +5,14 @@ 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_LEADER_ONLY = False
|
gltest_cli/config/plugin.py
CHANGED
|
@@ -12,6 +12,12 @@ 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_LEADER_ONLY,
|
|
19
|
+
CHAINS,
|
|
20
|
+
)
|
|
15
21
|
|
|
16
22
|
|
|
17
23
|
def pytest_addoption(parser):
|
|
@@ -33,14 +39,14 @@ def pytest_addoption(parser):
|
|
|
33
39
|
group.addoption(
|
|
34
40
|
"--default-wait-interval",
|
|
35
41
|
action="store",
|
|
36
|
-
default=
|
|
42
|
+
default=DEFAULT_WAIT_INTERVAL,
|
|
37
43
|
help="Default interval (ms) between transaction receipt checks",
|
|
38
44
|
)
|
|
39
45
|
|
|
40
46
|
group.addoption(
|
|
41
47
|
"--default-wait-retries",
|
|
42
48
|
action="store",
|
|
43
|
-
default=
|
|
49
|
+
default=DEFAULT_WAIT_RETRIES,
|
|
44
50
|
help="Default number of retries for transaction receipt checks",
|
|
45
51
|
)
|
|
46
52
|
|
|
@@ -59,17 +65,17 @@ def pytest_addoption(parser):
|
|
|
59
65
|
)
|
|
60
66
|
|
|
61
67
|
group.addoption(
|
|
62
|
-
"--
|
|
68
|
+
"--leader-only",
|
|
63
69
|
action="store_true",
|
|
64
|
-
default=
|
|
65
|
-
help="
|
|
70
|
+
default=DEFAULT_LEADER_ONLY,
|
|
71
|
+
help="Run contracts in leader-only mode",
|
|
66
72
|
)
|
|
67
73
|
|
|
68
74
|
group.addoption(
|
|
69
|
-
"--
|
|
70
|
-
action="
|
|
71
|
-
default=
|
|
72
|
-
help="
|
|
75
|
+
"--chain-type",
|
|
76
|
+
action="store",
|
|
77
|
+
default=None,
|
|
78
|
+
help=f"Chain type (possible values: {', '.join(CHAINS)})",
|
|
73
79
|
)
|
|
74
80
|
|
|
75
81
|
|
|
@@ -106,8 +112,8 @@ def pytest_configure(config):
|
|
|
106
112
|
default_wait_retries = config.getoption("--default-wait-retries")
|
|
107
113
|
rpc_url = config.getoption("--rpc-url")
|
|
108
114
|
network = config.getoption("--network")
|
|
109
|
-
test_with_mocks = config.getoption("--test-with-mocks")
|
|
110
115
|
leader_only = config.getoption("--leader-only")
|
|
116
|
+
chain_type = config.getoption("--chain-type")
|
|
111
117
|
|
|
112
118
|
plugin_config = PluginConfig()
|
|
113
119
|
plugin_config.contracts_dir = (
|
|
@@ -120,8 +126,8 @@ def pytest_configure(config):
|
|
|
120
126
|
plugin_config.default_wait_retries = int(default_wait_retries)
|
|
121
127
|
plugin_config.rpc_url = rpc_url
|
|
122
128
|
plugin_config.network_name = network
|
|
123
|
-
plugin_config.test_with_mocks = test_with_mocks
|
|
124
129
|
plugin_config.leader_only = leader_only
|
|
130
|
+
plugin_config.chain_type = chain_type
|
|
125
131
|
|
|
126
132
|
general_config.plugin_config = plugin_config
|
|
127
133
|
except Exception as e:
|
|
@@ -148,6 +154,8 @@ def pytest_sessionstart(session):
|
|
|
148
154
|
# Show available networks including preconfigured ones
|
|
149
155
|
all_networks = general_config.get_networks_keys()
|
|
150
156
|
logger.info(f" Available networks: {all_networks}")
|
|
157
|
+
logger.info(f" Selected chain type: {general_config.get_chain_type()}")
|
|
158
|
+
logger.info(f" Available chains: {', '.join(CHAINS)}")
|
|
151
159
|
logger.info(f" Contracts directory: {general_config.get_contracts_dir()}")
|
|
152
160
|
logger.info(f" Artifacts directory: {general_config.get_artifacts_dir()}")
|
|
153
161
|
logger.info(f" Environment: {general_config.user_config.environment}")
|
|
@@ -157,7 +165,6 @@ def pytest_sessionstart(session):
|
|
|
157
165
|
logger.info(
|
|
158
166
|
f" Default wait retries: {general_config.get_default_wait_retries()}"
|
|
159
167
|
)
|
|
160
|
-
logger.info(f" Test with mocks: {general_config.get_test_with_mocks()}")
|
|
161
168
|
|
|
162
169
|
if (
|
|
163
170
|
general_config.get_leader_only()
|