genlayer-test 0.10.1__py3-none-any.whl → 0.12.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.10.1.dist-info → genlayer_test-0.12.0.dist-info}/METADATA +271 -6
- {genlayer_test-0.10.1.dist-info → genlayer_test-0.12.0.dist-info}/RECORD +16 -9
- {genlayer_test-0.10.1.dist-info → genlayer_test-0.12.0.dist-info}/WHEEL +1 -1
- {genlayer_test-0.10.1.dist-info → genlayer_test-0.12.0.dist-info}/entry_points.txt +1 -0
- {genlayer_test-0.10.1.dist-info → genlayer_test-0.12.0.dist-info}/licenses/LICENSE +2 -2
- gltest/direct/__init__.py +31 -0
- gltest/direct/loader.py +288 -0
- gltest/direct/pytest_plugin.py +117 -0
- gltest/direct/sdk_loader.py +260 -0
- gltest/direct/types.py +18 -0
- gltest/direct/vm.py +432 -0
- gltest/direct/wasi_mock.py +219 -0
- gltest/types.py +14 -0
- gltest/validators/validator_factory.py +37 -11
- gltest_cli/config/plugin.py +8 -6
- {genlayer_test-0.10.1.dist-info → genlayer_test-0.12.0.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from gltest.types import MockedLLMResponse
|
|
1
|
+
from gltest.types import MockedLLMResponse, MockedWebResponse
|
|
2
2
|
from dataclasses import dataclass
|
|
3
3
|
from typing import Dict, Any, Optional, List
|
|
4
4
|
from copy import deepcopy
|
|
@@ -16,6 +16,7 @@ class Validator:
|
|
|
16
16
|
# Mock configuration
|
|
17
17
|
mock_enabled: bool
|
|
18
18
|
mock_llm_response: Optional[MockedLLMResponse]
|
|
19
|
+
mock_web_response: Optional[MockedWebResponse]
|
|
19
20
|
|
|
20
21
|
def to_dict(self) -> Dict[str, Any]:
|
|
21
22
|
normal_config = {
|
|
@@ -29,21 +30,27 @@ class Validator:
|
|
|
29
30
|
if not self.mock_enabled:
|
|
30
31
|
return normal_config
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
33
|
+
# Mock llm response
|
|
34
|
+
mock_llm = self.mock_llm_response or {}
|
|
35
|
+
mock_llm_config = {
|
|
36
|
+
"response": mock_llm.get("nondet_exec_prompt", {}),
|
|
37
|
+
"eq_principle_prompt_comparative": mock_llm.get(
|
|
36
38
|
"eq_principle_prompt_comparative", {}
|
|
37
39
|
),
|
|
38
|
-
"eq_principle_prompt_non_comparative":
|
|
40
|
+
"eq_principle_prompt_non_comparative": mock_llm.get(
|
|
39
41
|
"eq_principle_prompt_non_comparative", {}
|
|
40
42
|
),
|
|
41
43
|
}
|
|
44
|
+
mock_web = self.mock_web_response or {}
|
|
45
|
+
mock_web_config = {
|
|
46
|
+
"nondet_web_request": mock_web.get("nondet_web_request", {}),
|
|
47
|
+
}
|
|
42
48
|
return {
|
|
43
49
|
**normal_config,
|
|
44
50
|
"plugin_config": {
|
|
45
51
|
**self.plugin_config,
|
|
46
|
-
"mock_response":
|
|
52
|
+
"mock_response": mock_llm_config,
|
|
53
|
+
"mock_web_response": mock_web_config,
|
|
47
54
|
},
|
|
48
55
|
}
|
|
49
56
|
|
|
@@ -60,6 +67,7 @@ class Validator:
|
|
|
60
67
|
plugin_config=deepcopy(self.plugin_config),
|
|
61
68
|
mock_enabled=self.mock_enabled,
|
|
62
69
|
mock_llm_response=deepcopy(self.mock_llm_response),
|
|
70
|
+
mock_web_response=deepcopy(self.mock_web_response),
|
|
63
71
|
)
|
|
64
72
|
|
|
65
73
|
|
|
@@ -85,6 +93,7 @@ class ValidatorFactory:
|
|
|
85
93
|
plugin_config=deepcopy(plugin_config),
|
|
86
94
|
mock_enabled=False,
|
|
87
95
|
mock_llm_response=None,
|
|
96
|
+
mock_web_response=None,
|
|
88
97
|
)
|
|
89
98
|
|
|
90
99
|
def batch_create_validators(
|
|
@@ -109,7 +118,15 @@ class ValidatorFactory:
|
|
|
109
118
|
for _ in range(count)
|
|
110
119
|
]
|
|
111
120
|
|
|
112
|
-
def create_mock_validator(
|
|
121
|
+
def create_mock_validator(
|
|
122
|
+
self,
|
|
123
|
+
mock_llm_response: Optional[MockedLLMResponse] = None,
|
|
124
|
+
mock_web_response: Optional[MockedWebResponse] = None,
|
|
125
|
+
) -> Validator:
|
|
126
|
+
if mock_llm_response is None and mock_web_response is None:
|
|
127
|
+
raise ValueError(
|
|
128
|
+
"mock_llm_response and mock_web_response cannot both be None"
|
|
129
|
+
)
|
|
113
130
|
return Validator(
|
|
114
131
|
stake=8,
|
|
115
132
|
provider="openai",
|
|
@@ -121,15 +138,24 @@ class ValidatorFactory:
|
|
|
121
138
|
"api_url": "https://api.openai.com",
|
|
122
139
|
},
|
|
123
140
|
mock_enabled=True,
|
|
124
|
-
mock_llm_response=
|
|
141
|
+
mock_llm_response=(
|
|
142
|
+
deepcopy(mock_llm_response) if mock_llm_response is not None else None
|
|
143
|
+
),
|
|
144
|
+
mock_web_response=(
|
|
145
|
+
deepcopy(mock_web_response) if mock_web_response is not None else None
|
|
146
|
+
),
|
|
125
147
|
)
|
|
126
148
|
|
|
127
149
|
def batch_create_mock_validators(
|
|
128
150
|
self,
|
|
129
151
|
count: int,
|
|
130
|
-
mock_llm_response: MockedLLMResponse,
|
|
152
|
+
mock_llm_response: Optional[MockedLLMResponse] = None,
|
|
153
|
+
mock_web_response: Optional[MockedWebResponse] = None,
|
|
131
154
|
) -> List[Validator]:
|
|
132
|
-
return [
|
|
155
|
+
return [
|
|
156
|
+
self.create_mock_validator(mock_llm_response, mock_web_response)
|
|
157
|
+
for _ in range(count)
|
|
158
|
+
]
|
|
133
159
|
|
|
134
160
|
|
|
135
161
|
def get_validator_factory() -> ValidatorFactory:
|
gltest_cli/config/plugin.py
CHANGED
|
@@ -13,8 +13,6 @@ from gltest_cli.config.general import (
|
|
|
13
13
|
from gltest_cli.config.types import PluginConfig
|
|
14
14
|
from gltest_cli.config.pytest_context import _pytest_context
|
|
15
15
|
from gltest_cli.config.constants import (
|
|
16
|
-
DEFAULT_WAIT_INTERVAL,
|
|
17
|
-
DEFAULT_WAIT_RETRIES,
|
|
18
16
|
DEFAULT_LEADER_ONLY,
|
|
19
17
|
CHAINS,
|
|
20
18
|
)
|
|
@@ -39,14 +37,14 @@ def pytest_addoption(parser):
|
|
|
39
37
|
group.addoption(
|
|
40
38
|
"--default-wait-interval",
|
|
41
39
|
action="store",
|
|
42
|
-
default=
|
|
40
|
+
default=None,
|
|
43
41
|
help="Default interval (ms) between transaction receipt checks",
|
|
44
42
|
)
|
|
45
43
|
|
|
46
44
|
group.addoption(
|
|
47
45
|
"--default-wait-retries",
|
|
48
46
|
action="store",
|
|
49
|
-
default=
|
|
47
|
+
default=None,
|
|
50
48
|
help="Default number of retries for transaction receipt checks",
|
|
51
49
|
)
|
|
52
50
|
|
|
@@ -122,8 +120,12 @@ def pytest_configure(config):
|
|
|
122
120
|
plugin_config.artifacts_dir = (
|
|
123
121
|
Path(artifacts_dir) if artifacts_dir is not None else None
|
|
124
122
|
)
|
|
125
|
-
plugin_config.default_wait_interval =
|
|
126
|
-
|
|
123
|
+
plugin_config.default_wait_interval = (
|
|
124
|
+
int(default_wait_interval) if default_wait_interval is not None else None
|
|
125
|
+
)
|
|
126
|
+
plugin_config.default_wait_retries = (
|
|
127
|
+
int(default_wait_retries) if default_wait_retries is not None else None
|
|
128
|
+
)
|
|
127
129
|
plugin_config.rpc_url = rpc_url
|
|
128
130
|
plugin_config.network_name = network
|
|
129
131
|
plugin_config.leader_only = leader_only
|
|
File without changes
|