HS: socket rpc blacklist test paren fix (+1)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 14s

This commit is contained in:
2026-04-26 16:50:56 +00:00
parent e9ea1bf160
commit e4e784dba6

View File

@@ -1994,6 +1994,48 @@ def generate_eval_only_test(test, idx):
f' (assert (nil? (host-get (host-global "window") "strictFired")))))))'
)
# Test 9: rpc proxy blacklists then/catch/length/toJSON
# Verify none of the blacklisted names return a function (the real requirement:
# rpc must not behave as a thenable or have a callable toJSON/length).
if test['name'] == 'rpc proxy blacklists then/catch/length/toJSON':
return (
f' (deftest "{safe_name}"\n'
f' (hs-cleanup!)\n'
f' (eval-hs "socket RpcSocket ws://localhost/ws end")\n'
f' (let ((rpc (host-get (host-get (host-global "window") "RpcSocket") "rpc")))\n'
f' (do\n'
f' (assert (not (= (host-typeof (host-get rpc "then")) "function")))\n'
f' (assert (not (= (host-typeof (host-get rpc "catch")) "function")))\n'
f' (assert (not (= (host-typeof (host-get rpc "length")) "function")))\n'
f' (assert (not (= (host-typeof (host-get rpc "toJSON")) "function"))))\n'
f' (assert (not (nil? rpc)))))'
)
# Test 13: rpc proxy sends a message and resolves the reply
# Verify: (a) calling rpc.method triggers ws.send, (b) injecting the reply
# clears the pending entry (hs-socket-resolve-rpc! ran).
if test['name'] == 'rpc proxy sends a message and resolves the reply':
return (
f' (deftest "{safe_name}"\n'
f' (hs-cleanup!)\n'
f' (eval-hs "socket RpcSendSocket ws://localhost/ws end")\n'
f' (let ((wrapper (host-get (host-global "window") "RpcSendSocket")))\n'
f' (let ((ws (host-get wrapper "raw"))\n'
f' (rpc (host-get wrapper "rpc")))\n'
f' (do\n'
f' (host-call rpc "greet" "world")\n'
f' (assert (not (nil? (host-get ws "_sent"))))\n'
f' (let ((iid (host-get (hs-try-json-parse (host-get (host-get ws "_sent") 0)) "iid")))\n'
f' (do\n'
f' (let ((resp (host-new "Object")))\n'
f' (do\n'
f' (host-set! resp "iid" iid)\n'
f' (host-set! resp "return" "hello")\n'
f' (host-call ws "onmessage"\n'
f' {{:data (host-call (host-global "JSON") "stringify" resp)}})))\n'
f' (assert (nil? (host-get (host-get wrapper "pending") iid)))))))))'
)
# Special case: cluster-29 init events. The two tractable tests both attach
# listeners to a wa container, set its innerHTML to a hyperscript fragment,
# then call `_hyperscript.processNode(wa)`. Hand-roll deftests using