genlayer-test 0.12.0__py3-none-any.whl → 0.13.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.12.0.dist-info → genlayer_test-0.13.0.dist-info}/METADATA +1 -1
- {genlayer_test-0.12.0.dist-info → genlayer_test-0.13.0.dist-info}/RECORD +7 -7
- gltest/direct/wasi_mock.py +49 -10
- {genlayer_test-0.12.0.dist-info → genlayer_test-0.13.0.dist-info}/WHEEL +0 -0
- {genlayer_test-0.12.0.dist-info → genlayer_test-0.13.0.dist-info}/entry_points.txt +0 -0
- {genlayer_test-0.12.0.dist-info → genlayer_test-0.13.0.dist-info}/licenses/LICENSE +0 -0
- {genlayer_test-0.12.0.dist-info → genlayer_test-0.13.0.dist-info}/top_level.txt +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
genlayer_test-0.
|
|
1
|
+
genlayer_test-0.13.0.dist-info/licenses/LICENSE,sha256=qeyU7v-TUbXruF0KGiAPMvgxsqxMq1ObA47C0gR5kWI,1070
|
|
2
2
|
gltest/__init__.py,sha256=49112x2CLdYwvCbBZ1laJmMk0NQ7S3u5YUbxPefqhrk,454
|
|
3
3
|
gltest/accounts.py,sha256=HUmWguJMolggQaZNRPw-LGlRlQCjLLdUanKRowMv6pI,812
|
|
4
4
|
gltest/assertions.py,sha256=0dEk0VxcHK4I7GZPHxJmz-2jaA60V499gOSR74rZbfM,1748
|
|
@@ -23,7 +23,7 @@ gltest/direct/pytest_plugin.py,sha256=HvHZcjRGenuXWCHnmFJJarwZDLKeIniLOXkEHxqpfu
|
|
|
23
23
|
gltest/direct/sdk_loader.py,sha256=Q3fSVpBRBiQgHDUCw1S2pIkqxnOCkRSYA3_Sl6FwVPo,8120
|
|
24
24
|
gltest/direct/types.py,sha256=PY5vsVrkxdC-8HTit8FpRp7TcqOqXwErz2xra3FVDek,356
|
|
25
25
|
gltest/direct/vm.py,sha256=lBc6nJInnfHAmXnSuoimBmBO_ijmJNDsTNXz4Jjh_f8,13812
|
|
26
|
-
gltest/direct/wasi_mock.py,sha256=
|
|
26
|
+
gltest/direct/wasi_mock.py,sha256=gW6GDQ-VB9uoUCjEUUDyTzTX0lvJKyi7XqW5EKC2eQY,7290
|
|
27
27
|
gltest/helpers/__init__.py,sha256=I7HiTu_H7_hP65zY6Wl02r-5eAMr2eZvqBVmusuQLX4,180
|
|
28
28
|
gltest/helpers/fixture_snapshot.py,sha256=bMgvlEVQBGIQzj7NOyosXWlphI1H2C1o75Zo0C-kGfQ,1931
|
|
29
29
|
gltest/helpers/take_snapshot.py,sha256=-QkaBvFG4ZsNKv_nCSEsy5Ze1pICOHxVhReSeQmZUlY,1276
|
|
@@ -38,8 +38,8 @@ gltest_cli/config/plugin.py,sha256=jxmdSBq7A1UPpxL4zolhDX53T8Eo4M8xluAsKx_6MTY,6
|
|
|
38
38
|
gltest_cli/config/pytest_context.py,sha256=Ze8JSkrwMTCE8jIhpzU_71CEXg92SiEPvSgNTp-gbS4,243
|
|
39
39
|
gltest_cli/config/types.py,sha256=nGKm2qTwo99M8DbGchj14IdIQ4lcNTDODZFHXdsi5rY,9506
|
|
40
40
|
gltest_cli/config/user.py,sha256=JeclpIVv4BT5COMW2xrEbTspI6e1RAYIOvd8ruPc3gM,12887
|
|
41
|
-
genlayer_test-0.
|
|
42
|
-
genlayer_test-0.
|
|
43
|
-
genlayer_test-0.
|
|
44
|
-
genlayer_test-0.
|
|
45
|
-
genlayer_test-0.
|
|
41
|
+
genlayer_test-0.13.0.dist-info/METADATA,sha256=hlxvP_CMiVlg5Qw4AJzjmhSKQzqPCcC_egm-7jSO86A,45258
|
|
42
|
+
genlayer_test-0.13.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
43
|
+
genlayer_test-0.13.0.dist-info/entry_points.txt,sha256=0cvllUWh2HnyzAv9L2YlXErDCsd2DDU2lR-6Mm-BNcc,138
|
|
44
|
+
genlayer_test-0.13.0.dist-info/top_level.txt,sha256=GSdrnQbiLcZssmtCpbDgBTygsc8Bt_TPeYjwm0FmpdA,18
|
|
45
|
+
genlayer_test-0.13.0.dist-info/RECORD,,
|
gltest/direct/wasi_mock.py
CHANGED
|
@@ -102,12 +102,19 @@ def gl_call(data: bytes, /) -> int:
|
|
|
102
102
|
if response is None:
|
|
103
103
|
return 2**32 - 1
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
# If response is already bytes (from RunNondet), use directly
|
|
106
|
+
# RunNondet handles its own ResultCode prefix for sub-VM result format
|
|
107
|
+
if isinstance(response, bytes):
|
|
108
|
+
encoded = response
|
|
109
|
+
else:
|
|
110
|
+
# Regular responses (web, llm, etc) are just calldata-encoded
|
|
111
|
+
# The SDK's _decode_nondet expects plain {"ok": ...} format
|
|
112
|
+
try:
|
|
113
|
+
from genlayer.py import calldata
|
|
114
|
+
encoded = calldata.encode(response)
|
|
115
|
+
except Exception as e:
|
|
116
|
+
vm._trace(f"gl_call encode error: {e}")
|
|
117
|
+
return 2**32 - 1
|
|
111
118
|
|
|
112
119
|
fd_counter = getattr(_local, 'fd_counter', 100)
|
|
113
120
|
fd = fd_counter
|
|
@@ -148,7 +155,7 @@ def _handle_gl_call(vm: "VMContext", request: Any) -> Any:
|
|
|
148
155
|
return {"ok": None}
|
|
149
156
|
|
|
150
157
|
if "RunNondet" in request:
|
|
151
|
-
return
|
|
158
|
+
return _handle_run_nondet(vm, request["RunNondet"])
|
|
152
159
|
|
|
153
160
|
if "GetWebsite" in request or "WebRequest" in request:
|
|
154
161
|
web_data = request.get("GetWebsite") or request.get("WebRequest", {})
|
|
@@ -167,9 +174,13 @@ def _handle_web_request(vm: "VMContext", data: Any) -> Any:
|
|
|
167
174
|
url = data.get("url", "")
|
|
168
175
|
method = data.get("method", "GET")
|
|
169
176
|
|
|
170
|
-
|
|
171
|
-
if
|
|
172
|
-
|
|
177
|
+
mock_data = vm._match_web_mock(url, method)
|
|
178
|
+
if mock_data:
|
|
179
|
+
# SDK expects {"ok": {"response": {...}}} format
|
|
180
|
+
# Mock stores {"response": {...}, "method": "..."}
|
|
181
|
+
if "response" in mock_data:
|
|
182
|
+
return {"ok": {"response": mock_data["response"]}}
|
|
183
|
+
return {"ok": mock_data}
|
|
173
184
|
|
|
174
185
|
raise MockNotFoundError(f"No web mock for {method} {url}")
|
|
175
186
|
|
|
@@ -185,6 +196,34 @@ def _handle_llm_request(vm: "VMContext", data: Any) -> Any:
|
|
|
185
196
|
raise MockNotFoundError(f"No LLM mock for prompt: {prompt[:100]}...")
|
|
186
197
|
|
|
187
198
|
|
|
199
|
+
def _handle_run_nondet(vm: "VMContext", data: Any) -> Any:
|
|
200
|
+
"""Handle RunNondet request by executing the leader function directly.
|
|
201
|
+
|
|
202
|
+
In direct mode, we skip the leader/validator consensus and just run
|
|
203
|
+
the leader function, returning its result.
|
|
204
|
+
"""
|
|
205
|
+
import cloudpickle
|
|
206
|
+
from genlayer.py import calldata
|
|
207
|
+
|
|
208
|
+
data_leader = data.get("data_leader")
|
|
209
|
+
if not data_leader:
|
|
210
|
+
raise ValueError("RunNondet missing data_leader")
|
|
211
|
+
|
|
212
|
+
# Unpickle and execute the leader function
|
|
213
|
+
# The lambda expects a stage_data argument, but in leader mode it's None
|
|
214
|
+
leader_fn = cloudpickle.loads(data_leader)
|
|
215
|
+
|
|
216
|
+
try:
|
|
217
|
+
result = leader_fn(None)
|
|
218
|
+
# Wrap result in Return format (code 0 + calldata)
|
|
219
|
+
encoded = bytes([0]) + calldata.encode(result)
|
|
220
|
+
return encoded
|
|
221
|
+
except Exception as e:
|
|
222
|
+
# Wrap error in UserError format (code 1 + message)
|
|
223
|
+
error_msg = str(e)
|
|
224
|
+
return bytes([1]) + error_msg.encode('utf-8')
|
|
225
|
+
|
|
226
|
+
|
|
188
227
|
def patched_fdopen(fd_arg: int, mode: str = "r", *args, **kwargs):
|
|
189
228
|
"""Patched os.fdopen that intercepts mock file descriptors."""
|
|
190
229
|
fd_buffers = getattr(_local, 'fd_buffers', {})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|