mirror of
https://github.com/denoland/deno.git
synced 2024-12-18 05:14:21 -05:00
test: add node compat test cases (#27134)
This PR enables node compat test cases found passing by using the tool added in #27122 The percentage of passing test case increases from 16.16% to 30.43% by this change.
This commit is contained in:
parent
32b4c37c05
commit
fb24fd37c9
527 changed files with 30399 additions and 530 deletions
|
@ -122,6 +122,16 @@
|
||||||
"sequential": ["test-child-process-exit.js"]
|
"sequential": ["test-child-process-exit.js"]
|
||||||
},
|
},
|
||||||
"tests": {
|
"tests": {
|
||||||
|
"abort": [
|
||||||
|
"test-addon-uv-handle-leak.js"
|
||||||
|
],
|
||||||
|
"benchmark": [
|
||||||
|
"test-benchmark-async-hooks.js",
|
||||||
|
"test-benchmark-http.js",
|
||||||
|
"test-benchmark-http2.js",
|
||||||
|
"test-benchmark-tls.js",
|
||||||
|
"test-benchmark-worker.js"
|
||||||
|
],
|
||||||
"common": [
|
"common": [
|
||||||
"child_process.js",
|
"child_process.js",
|
||||||
"countdown.js",
|
"countdown.js",
|
||||||
|
@ -133,6 +143,13 @@
|
||||||
"internet.js",
|
"internet.js",
|
||||||
"tmpdir.js"
|
"tmpdir.js"
|
||||||
],
|
],
|
||||||
|
"es-module": [
|
||||||
|
"test-cjs-prototype-pollution.js",
|
||||||
|
"test-esm-dynamic-import-mutating-fs.js",
|
||||||
|
"test-esm-loader-cache-clearing.js",
|
||||||
|
"test-esm-windows.js",
|
||||||
|
"test-vm-compile-function-lineoffset.js"
|
||||||
|
],
|
||||||
"fixtures": [
|
"fixtures": [
|
||||||
"a.js",
|
"a.js",
|
||||||
"child_process_should_emit_error.js",
|
"child_process_should_emit_error.js",
|
||||||
|
@ -161,12 +178,29 @@
|
||||||
// "test-dns.js",
|
// "test-dns.js",
|
||||||
"test-http-https-default-ports.js"
|
"test-http-https-default-ports.js"
|
||||||
],
|
],
|
||||||
|
"message": [
|
||||||
|
"eval_messages.js",
|
||||||
|
"max_tick_depth.js",
|
||||||
|
"stdin_messages.js",
|
||||||
|
"util_inspect_error.js"
|
||||||
|
],
|
||||||
"parallel": [
|
"parallel": [
|
||||||
|
"test-arm-math-illegal-instruction.js",
|
||||||
"test-assert-async.js",
|
"test-assert-async.js",
|
||||||
"test-assert-fail.js",
|
"test-assert-fail.js",
|
||||||
"test-assert-strict-exists.js",
|
"test-assert-strict-exists.js",
|
||||||
"test-assert.js",
|
"test-assert.js",
|
||||||
|
"test-async-hooks-run-in-async-scope-caught-exception.js",
|
||||||
|
"test-async-hooks-run-in-async-scope-this-arg.js",
|
||||||
|
"test-async-local-storage-bind.js",
|
||||||
|
"test-async-local-storage-contexts.js",
|
||||||
|
"test-async-local-storage-deep-stack.js",
|
||||||
|
"test-async-local-storage-http-multiclients.js",
|
||||||
|
"test-async-local-storage-snapshot.js",
|
||||||
|
"test-atomics-wake.js",
|
||||||
"test-bad-unicode.js",
|
"test-bad-unicode.js",
|
||||||
|
"test-beforeexit-event-exit.js",
|
||||||
|
"test-blob-buffer-too-large.js",
|
||||||
"test-blocklist.js",
|
"test-blocklist.js",
|
||||||
"test-btoa-atob.js",
|
"test-btoa-atob.js",
|
||||||
"test-buffer-alloc.js",
|
"test-buffer-alloc.js",
|
||||||
|
@ -202,6 +236,7 @@
|
||||||
"test-buffer-readint.js",
|
"test-buffer-readint.js",
|
||||||
"test-buffer-readuint.js",
|
"test-buffer-readuint.js",
|
||||||
"test-buffer-safe-unsafe.js",
|
"test-buffer-safe-unsafe.js",
|
||||||
|
"test-buffer-sharedarraybuffer.js",
|
||||||
"test-buffer-slice.js",
|
"test-buffer-slice.js",
|
||||||
"test-buffer-slow.js",
|
"test-buffer-slow.js",
|
||||||
"test-buffer-swap.js",
|
"test-buffer-swap.js",
|
||||||
|
@ -209,6 +244,7 @@
|
||||||
"test-buffer-tostring-range.js",
|
"test-buffer-tostring-range.js",
|
||||||
"test-buffer-tostring-rangeerror.js",
|
"test-buffer-tostring-rangeerror.js",
|
||||||
"test-buffer-tostring.js",
|
"test-buffer-tostring.js",
|
||||||
|
"test-buffer-write.js",
|
||||||
"test-buffer-writedouble.js",
|
"test-buffer-writedouble.js",
|
||||||
"test-buffer-writefloat.js",
|
"test-buffer-writefloat.js",
|
||||||
"test-buffer-writeint.js",
|
"test-buffer-writeint.js",
|
||||||
|
@ -237,8 +273,10 @@
|
||||||
"test-child-process-execfilesync-maxbuf.js",
|
"test-child-process-execfilesync-maxbuf.js",
|
||||||
"test-child-process-execsync-maxbuf.js",
|
"test-child-process-execsync-maxbuf.js",
|
||||||
"test-child-process-flush-stdio.js",
|
"test-child-process-flush-stdio.js",
|
||||||
|
"test-child-process-fork3.js",
|
||||||
"test-child-process-ipc-next-tick.js",
|
"test-child-process-ipc-next-tick.js",
|
||||||
"test-child-process-kill.js",
|
"test-child-process-kill.js",
|
||||||
|
"test-child-process-send-type-error.js",
|
||||||
"test-child-process-set-blocking.js",
|
"test-child-process-set-blocking.js",
|
||||||
"test-child-process-spawn-args.js",
|
"test-child-process-spawn-args.js",
|
||||||
"test-child-process-spawn-event.js",
|
"test-child-process-spawn-event.js",
|
||||||
|
@ -246,49 +284,140 @@
|
||||||
"test-child-process-spawnsync-maxbuf.js",
|
"test-child-process-spawnsync-maxbuf.js",
|
||||||
"test-child-process-spawnsync-validation-errors.js",
|
"test-child-process-spawnsync-validation-errors.js",
|
||||||
"test-child-process-spawnsync.js",
|
"test-child-process-spawnsync.js",
|
||||||
// TODO(crowlKats): socket is not yet polyfilled
|
"test-child-process-stdin-ipc.js",
|
||||||
// "test-client-request-destroy.js",
|
"test-child-process-stdio-overlapped.js",
|
||||||
|
"test-client-request-destroy.js",
|
||||||
|
"test-cluster-uncaught-exception.js",
|
||||||
|
"test-console-assign-undefined.js",
|
||||||
"test-console-async-write-error.js",
|
"test-console-async-write-error.js",
|
||||||
|
"test-console-formatTime.js",
|
||||||
"test-console-group.js",
|
"test-console-group.js",
|
||||||
"test-console-log-stdio-broken-dest.js",
|
"test-console-log-stdio-broken-dest.js",
|
||||||
"test-console-log-throw-primitive.js",
|
"test-console-log-throw-primitive.js",
|
||||||
"test-console-no-swallow-stack-overflow.js",
|
"test-console-no-swallow-stack-overflow.js",
|
||||||
|
"test-console-not-call-toString.js",
|
||||||
|
"test-console-self-assign.js",
|
||||||
"test-console-sync-write-error.js",
|
"test-console-sync-write-error.js",
|
||||||
"test-console-table.js",
|
"test-console-table.js",
|
||||||
"test-console-tty-colors.js",
|
"test-console-tty-colors.js",
|
||||||
|
"test-crypto-dh-errors.js",
|
||||||
|
"test-crypto-dh-odd-key.js",
|
||||||
"test-crypto-dh-shared.js",
|
"test-crypto-dh-shared.js",
|
||||||
"test-crypto-dh.js",
|
"test-crypto-dh.js",
|
||||||
|
"test-crypto-domain.js",
|
||||||
|
"test-crypto-from-binary.js",
|
||||||
"test-crypto-hash.js",
|
"test-crypto-hash.js",
|
||||||
"test-crypto-hkdf.js",
|
"test-crypto-hkdf.js",
|
||||||
"test-crypto-hmac.js",
|
"test-crypto-hmac.js",
|
||||||
|
"test-crypto-keygen-dh-classic.js",
|
||||||
|
"test-crypto-keygen-duplicate-deprecated-option.js",
|
||||||
|
"test-crypto-keygen-empty-passphrase-no-error.js",
|
||||||
|
"test-crypto-keygen-key-objects.js",
|
||||||
|
"test-crypto-keygen-missing-oid.js",
|
||||||
|
"test-crypto-keygen-non-standard-public-exponent.js",
|
||||||
|
"test-crypto-keygen-rfc8017-9-1.js",
|
||||||
|
"test-crypto-keygen-rfc8017-a-2-3.js",
|
||||||
|
"test-crypto-lazy-transform-writable.js",
|
||||||
|
"test-crypto-no-algorithm.js",
|
||||||
|
"test-crypto-op-during-process-exit.js",
|
||||||
|
"test-crypto-padding-aes256.js",
|
||||||
"test-crypto-pbkdf2.js",
|
"test-crypto-pbkdf2.js",
|
||||||
"test-crypto-prime.js",
|
"test-crypto-prime.js",
|
||||||
|
"test-crypto-psychic-signatures.js",
|
||||||
|
"test-crypto-publicDecrypt-fails-first-time.js",
|
||||||
|
"test-crypto-randomfillsync-regression.js",
|
||||||
|
"test-crypto-scrypt.js",
|
||||||
"test-crypto-secret-keygen.js",
|
"test-crypto-secret-keygen.js",
|
||||||
"test-crypto-stream.js",
|
"test-crypto-stream.js",
|
||||||
|
"test-crypto-subtle-zero-length.js",
|
||||||
"test-crypto-update-encoding.js",
|
"test-crypto-update-encoding.js",
|
||||||
"test-crypto-x509.js",
|
"test-crypto-x509.js",
|
||||||
|
"test-dgram-address.js",
|
||||||
|
"test-dgram-bind-default-address.js",
|
||||||
|
"test-dgram-bind-error-repeat.js",
|
||||||
|
"test-dgram-bind.js",
|
||||||
|
"test-dgram-bytes-length.js",
|
||||||
"test-dgram-close-during-bind.js",
|
"test-dgram-close-during-bind.js",
|
||||||
|
"test-dgram-close-in-listening.js",
|
||||||
|
"test-dgram-close-is-not-callback.js",
|
||||||
"test-dgram-close-signal.js",
|
"test-dgram-close-signal.js",
|
||||||
|
"test-dgram-close.js",
|
||||||
|
"test-dgram-connect-send-callback-buffer-length.js",
|
||||||
|
"test-dgram-connect-send-callback-buffer.js",
|
||||||
|
"test-dgram-connect-send-callback-multi-buffer.js",
|
||||||
|
"test-dgram-connect-send-default-host.js",
|
||||||
|
"test-dgram-connect-send-empty-array.js",
|
||||||
|
"test-dgram-connect-send-empty-buffer.js",
|
||||||
|
"test-dgram-connect-send-empty-packet.js",
|
||||||
|
"test-dgram-connect-send-multi-buffer-copy.js",
|
||||||
|
"test-dgram-connect-send-multi-string-array.js",
|
||||||
|
"test-dgram-connect.js",
|
||||||
|
"test-dgram-createSocket-type.js",
|
||||||
|
"test-dgram-error-message-address.js",
|
||||||
|
"test-dgram-implicit-bind.js",
|
||||||
|
"test-dgram-listen-after-bind.js",
|
||||||
|
"test-dgram-msgsize.js",
|
||||||
|
"test-dgram-oob-buffer.js",
|
||||||
|
"test-dgram-recv-error.js",
|
||||||
|
"test-dgram-ref.js",
|
||||||
|
"test-dgram-send-bad-arguments.js",
|
||||||
|
"test-dgram-send-callback-buffer-empty-address.js",
|
||||||
|
"test-dgram-send-callback-buffer-length-empty-address.js",
|
||||||
|
"test-dgram-send-callback-buffer-length.js",
|
||||||
|
"test-dgram-send-callback-buffer.js",
|
||||||
|
"test-dgram-send-callback-multi-buffer-empty-address.js",
|
||||||
|
"test-dgram-send-callback-multi-buffer.js",
|
||||||
|
"test-dgram-send-callback-recursive.js",
|
||||||
|
"test-dgram-send-default-host.js",
|
||||||
|
"test-dgram-send-empty-array.js",
|
||||||
|
"test-dgram-send-empty-buffer.js",
|
||||||
|
"test-dgram-send-empty-packet.js",
|
||||||
|
"test-dgram-send-error.js",
|
||||||
|
"test-dgram-send-invalid-msg-type.js",
|
||||||
|
"test-dgram-send-multi-buffer-copy.js",
|
||||||
|
"test-dgram-send-multi-string-array.js",
|
||||||
|
"test-dgram-udp4.js",
|
||||||
|
"test-dgram-udp6-send-default-host.js",
|
||||||
|
"test-dgram-unref.js",
|
||||||
|
"test-diagnostics-channel-bind-store.js",
|
||||||
"test-diagnostics-channel-has-subscribers.js",
|
"test-diagnostics-channel-has-subscribers.js",
|
||||||
"test-diagnostics-channel-net.js",
|
"test-diagnostics-channel-net.js",
|
||||||
"test-diagnostics-channel-object-channel-pub-sub.js",
|
"test-diagnostics-channel-object-channel-pub-sub.js",
|
||||||
"test-diagnostics-channel-pub-sub.js",
|
"test-diagnostics-channel-pub-sub.js",
|
||||||
|
"test-diagnostics-channel-safe-subscriber-errors.js",
|
||||||
"test-diagnostics-channel-symbol-named.js",
|
"test-diagnostics-channel-symbol-named.js",
|
||||||
"test-diagnostics-channel-sync-unsubscribe.js",
|
"test-diagnostics-channel-sync-unsubscribe.js",
|
||||||
"test-diagnostics-channel-tracing-channel-args-types.js",
|
"test-diagnostics-channel-tracing-channel-args-types.js",
|
||||||
|
"test-diagnostics-channel-tracing-channel-async-error.js",
|
||||||
|
"test-diagnostics-channel-tracing-channel-async.js",
|
||||||
"test-diagnostics-channel-tracing-channel-callback-run-stores.js",
|
"test-diagnostics-channel-tracing-channel-callback-run-stores.js",
|
||||||
"test-diagnostics-channel-tracing-channel-promise-run-stores.js",
|
"test-diagnostics-channel-tracing-channel-promise-run-stores.js",
|
||||||
|
"test-diagnostics-channel-tracing-channel-run-stores.js",
|
||||||
"test-diagnostics-channel-tracing-channel-sync-error.js",
|
"test-diagnostics-channel-tracing-channel-sync-error.js",
|
||||||
"test-diagnostics-channel-tracing-channel-sync.js",
|
"test-diagnostics-channel-tracing-channel-sync.js",
|
||||||
"test-diagnostics-channel-udp.js",
|
"test-diagnostics-channel-udp.js",
|
||||||
"test-dns-lookup.js",
|
"test-dns-lookup.js",
|
||||||
"test-dns-memory-error.js",
|
"test-dns-memory-error.js",
|
||||||
|
"test-dns-multi-channel.js",
|
||||||
"test-dns-promises-exists.js",
|
"test-dns-promises-exists.js",
|
||||||
"test-dns-resolvens-typeerror.js",
|
"test-dns-resolvens-typeerror.js",
|
||||||
"test-dns-setservers-type-check.js",
|
"test-dns-setservers-type-check.js",
|
||||||
|
"test-domain-crypto.js",
|
||||||
|
"test-domain-ee-error-listener.js",
|
||||||
|
"test-domain-nested-throw.js",
|
||||||
|
"test-domain-nested.js",
|
||||||
|
"test-domain-stack.js",
|
||||||
|
"test-domain-top-level-error-handler-clears-stack.js",
|
||||||
|
"test-dsa-fips-invalid-key.js",
|
||||||
|
"test-env-newprotomethod-remove-unnecessary-prototypes.js",
|
||||||
|
"test-error-aggregateTwoErrors.js",
|
||||||
|
"test-error-prepare-stack-trace.js",
|
||||||
|
"test-errors-aborterror.js",
|
||||||
"test-eval-strict-referenceerror.js",
|
"test-eval-strict-referenceerror.js",
|
||||||
"test-eval.js",
|
"test-eval.js",
|
||||||
|
"test-event-capture-rejections.js",
|
||||||
"test-event-emitter-add-listeners.js",
|
"test-event-emitter-add-listeners.js",
|
||||||
|
"test-event-emitter-check-listener-leaks.js",
|
||||||
"test-event-emitter-emit-context.js",
|
"test-event-emitter-emit-context.js",
|
||||||
"test-event-emitter-error-monitor.js",
|
"test-event-emitter-error-monitor.js",
|
||||||
"test-event-emitter-errors.js",
|
"test-event-emitter-errors.js",
|
||||||
|
@ -297,6 +426,9 @@
|
||||||
"test-event-emitter-listener-count.js",
|
"test-event-emitter-listener-count.js",
|
||||||
"test-event-emitter-listeners-side-effects.js",
|
"test-event-emitter-listeners-side-effects.js",
|
||||||
"test-event-emitter-listeners.js",
|
"test-event-emitter-listeners.js",
|
||||||
|
"test-event-emitter-max-listeners-warning-for-null.js",
|
||||||
|
"test-event-emitter-max-listeners-warning-for-symbol.js",
|
||||||
|
"test-event-emitter-max-listeners-warning.js",
|
||||||
"test-event-emitter-max-listeners.js",
|
"test-event-emitter-max-listeners.js",
|
||||||
"test-event-emitter-method-names.js",
|
"test-event-emitter-method-names.js",
|
||||||
"test-event-emitter-modify-in-emit.js",
|
"test-event-emitter-modify-in-emit.js",
|
||||||
|
@ -315,6 +447,7 @@
|
||||||
"test-events-once.js",
|
"test-events-once.js",
|
||||||
"test-events-uncaught-exception-stack.js",
|
"test-events-uncaught-exception-stack.js",
|
||||||
"test-eventtarget-brandcheck.js",
|
"test-eventtarget-brandcheck.js",
|
||||||
|
"test-eventtarget-once-twice.js",
|
||||||
"test-exception-handler.js",
|
"test-exception-handler.js",
|
||||||
"test-exception-handler2.js",
|
"test-exception-handler2.js",
|
||||||
"test-file-read-noexist.js",
|
"test-file-read-noexist.js",
|
||||||
|
@ -325,28 +458,42 @@
|
||||||
"test-fs-access.js",
|
"test-fs-access.js",
|
||||||
"test-fs-append-file-sync.js",
|
"test-fs-append-file-sync.js",
|
||||||
"test-fs-append-file.js",
|
"test-fs-append-file.js",
|
||||||
|
"test-fs-buffertype-writesync.js",
|
||||||
"test-fs-chmod-mask.js",
|
"test-fs-chmod-mask.js",
|
||||||
"test-fs-chmod.js",
|
"test-fs-chmod.js",
|
||||||
"test-fs-chown-type-check.js",
|
"test-fs-chown-type-check.js",
|
||||||
|
"test-fs-close.js",
|
||||||
|
"test-fs-constants.js",
|
||||||
"test-fs-copyfile.js",
|
"test-fs-copyfile.js",
|
||||||
"test-fs-empty-readStream.js",
|
"test-fs-empty-readStream.js",
|
||||||
|
"test-fs-fmap.js",
|
||||||
"test-fs-lchown.js",
|
"test-fs-lchown.js",
|
||||||
|
"test-fs-long-path.js",
|
||||||
"test-fs-mkdir.js",
|
"test-fs-mkdir.js",
|
||||||
|
"test-fs-non-number-arguments-throw.js",
|
||||||
"test-fs-open-flags.js",
|
"test-fs-open-flags.js",
|
||||||
"test-fs-open-mode-mask.js",
|
"test-fs-open-mode-mask.js",
|
||||||
"test-fs-open-no-close.js",
|
"test-fs-open-no-close.js",
|
||||||
"test-fs-open-numeric-flags.js",
|
"test-fs-open-numeric-flags.js",
|
||||||
"test-fs-open.js",
|
"test-fs-open.js",
|
||||||
"test-fs-opendir.js",
|
"test-fs-opendir.js",
|
||||||
|
"test-fs-promises-exists.js",
|
||||||
"test-fs-promises-file-handle-stat.js",
|
"test-fs-promises-file-handle-stat.js",
|
||||||
|
"test-fs-promises-file-handle-write.js",
|
||||||
|
"test-fs-promises-readfile-empty.js",
|
||||||
|
"test-fs-promises-readfile-with-fd.js",
|
||||||
"test-fs-promises-writefile-with-fd.js",
|
"test-fs-promises-writefile-with-fd.js",
|
||||||
|
"test-fs-read-file-sync-hostname.js",
|
||||||
|
"test-fs-read-file-sync.js",
|
||||||
"test-fs-read-stream-autoClose.js",
|
"test-fs-read-stream-autoClose.js",
|
||||||
"test-fs-read-stream-concurrent-reads.js",
|
"test-fs-read-stream-concurrent-reads.js",
|
||||||
"test-fs-read-stream-double-close.js",
|
"test-fs-read-stream-double-close.js",
|
||||||
"test-fs-read-stream-encoding.js",
|
"test-fs-read-stream-encoding.js",
|
||||||
|
"test-fs-read-stream-fd-leak.js",
|
||||||
"test-fs-read-stream-fd.js",
|
"test-fs-read-stream-fd.js",
|
||||||
"test-fs-read-stream-inherit.js",
|
"test-fs-read-stream-inherit.js",
|
||||||
"test-fs-read-stream-patch-open.js",
|
"test-fs-read-stream-patch-open.js",
|
||||||
|
"test-fs-read-stream-pos.js",
|
||||||
"test-fs-read-stream-resume.js",
|
"test-fs-read-stream-resume.js",
|
||||||
"test-fs-read-stream-throw-type-error.js",
|
"test-fs-read-stream-throw-type-error.js",
|
||||||
"test-fs-read-stream.js",
|
"test-fs-read-stream.js",
|
||||||
|
@ -356,8 +503,12 @@
|
||||||
"test-fs-readdir-stack-overflow.js",
|
"test-fs-readdir-stack-overflow.js",
|
||||||
"test-fs-readdir.js",
|
"test-fs-readdir.js",
|
||||||
"test-fs-readfile-empty.js",
|
"test-fs-readfile-empty.js",
|
||||||
|
"test-fs-readfile-unlink.js",
|
||||||
|
"test-fs-readfile-zero-byte-liar.js",
|
||||||
|
"test-fs-readfilesync-enoent.js",
|
||||||
"test-fs-readv-sync.js",
|
"test-fs-readv-sync.js",
|
||||||
"test-fs-readv.js",
|
"test-fs-readv.js",
|
||||||
|
"test-fs-ready-event-stream.js",
|
||||||
"test-fs-realpath-native.js",
|
"test-fs-realpath-native.js",
|
||||||
"test-fs-rmdir-recursive-sync-warns-not-found.js",
|
"test-fs-rmdir-recursive-sync-warns-not-found.js",
|
||||||
"test-fs-rmdir-recursive-sync-warns-on-file.js",
|
"test-fs-rmdir-recursive-sync-warns-on-file.js",
|
||||||
|
@ -367,33 +518,122 @@
|
||||||
"test-fs-rmdir-recursive-warns-on-file.js",
|
"test-fs-rmdir-recursive-warns-on-file.js",
|
||||||
"test-fs-rmdir-recursive.js",
|
"test-fs-rmdir-recursive.js",
|
||||||
"test-fs-rmdir-type-check.js",
|
"test-fs-rmdir-type-check.js",
|
||||||
|
"test-fs-sir-writes-alot.js",
|
||||||
|
"test-fs-stream-construct-compat-error-read.js",
|
||||||
|
"test-fs-stream-construct-compat-graceful-fs.js",
|
||||||
|
"test-fs-stream-construct-compat-old-node.js",
|
||||||
|
"test-fs-stream-destroy-emit-error.js",
|
||||||
|
"test-fs-stream-double-close.js",
|
||||||
|
"test-fs-stream-fs-options.js",
|
||||||
|
"test-fs-stream-options.js",
|
||||||
|
"test-fs-symlink-dir-junction-relative.js",
|
||||||
|
"test-fs-timestamp-parsing-error.js",
|
||||||
|
"test-fs-truncate-clear-file-zero.js",
|
||||||
|
"test-fs-util-validateoffsetlength.js",
|
||||||
|
"test-fs-utimes-y2K38.js",
|
||||||
"test-fs-utimes.js",
|
"test-fs-utimes.js",
|
||||||
|
"test-fs-watch-file-enoent-after-deletion.js",
|
||||||
|
"test-fs-watch-recursive-add-file-with-url.js",
|
||||||
|
"test-fs-watch-recursive-add-file.js",
|
||||||
|
"test-fs-watch-recursive-add-folder.js",
|
||||||
|
"test-fs-watch-recursive-update-file.js",
|
||||||
"test-fs-watchfile.js",
|
"test-fs-watchfile.js",
|
||||||
"test-fs-write-buffer.js",
|
"test-fs-write-buffer.js",
|
||||||
"test-fs-write-file-buffer.js",
|
"test-fs-write-file-buffer.js",
|
||||||
"test-fs-write-file-invalid-path.js",
|
"test-fs-write-file-invalid-path.js",
|
||||||
"test-fs-write-file-sync.js",
|
"test-fs-write-file-sync.js",
|
||||||
"test-fs-write-file.js",
|
"test-fs-write-file.js",
|
||||||
|
"test-fs-write-negativeoffset.js",
|
||||||
"test-fs-write-no-fd.js",
|
"test-fs-write-no-fd.js",
|
||||||
"test-fs-write-stream-autoclose-option.js",
|
"test-fs-write-stream-autoclose-option.js",
|
||||||
"test-fs-write-stream-close-without-callback.js",
|
"test-fs-write-stream-close-without-callback.js",
|
||||||
"test-fs-write-stream-double-close.js",
|
"test-fs-write-stream-double-close.js",
|
||||||
|
"test-fs-write-stream-encoding.js",
|
||||||
"test-fs-write-stream-end.js",
|
"test-fs-write-stream-end.js",
|
||||||
"test-fs-write-stream-fs.js",
|
"test-fs-write-stream-fs.js",
|
||||||
|
"test-fs-write-stream-patch-open.js",
|
||||||
"test-fs-write-stream-throw-type-error.js",
|
"test-fs-write-stream-throw-type-error.js",
|
||||||
"test-fs-write-stream.js",
|
"test-fs-write-stream.js",
|
||||||
"test-fs-write-sync.js",
|
"test-fs-write-sync.js",
|
||||||
"test-fs-write.js",
|
"test-fs-write.js",
|
||||||
"test-fs-writev-sync.js",
|
"test-fs-writev-sync.js",
|
||||||
|
"test-fs-writev.js",
|
||||||
|
"test-global-domexception.js",
|
||||||
|
"test-global-encoder.js",
|
||||||
|
"test-global-webcrypto.js",
|
||||||
|
"test-global-webstreams.js",
|
||||||
"test-handle-wrap-close-abort.js",
|
"test-handle-wrap-close-abort.js",
|
||||||
|
"test-http-abort-before-end.js",
|
||||||
|
"test-http-addrequest-localaddress.js",
|
||||||
|
"test-http-agent-false.js",
|
||||||
"test-http-agent-getname.js",
|
"test-http-agent-getname.js",
|
||||||
|
"test-http-agent-keepalive-delay.js",
|
||||||
|
"test-http-agent-maxtotalsockets.js",
|
||||||
|
"test-http-agent-no-protocol.js",
|
||||||
|
"test-http-agent-null.js",
|
||||||
|
"test-http-allow-req-after-204-res.js",
|
||||||
|
"test-http-bind-twice.js",
|
||||||
|
"test-http-buffer-sanity.js",
|
||||||
|
"test-http-chunked-smuggling.js",
|
||||||
|
"test-http-chunked.js",
|
||||||
|
"test-http-client-abort2.js",
|
||||||
|
"test-http-client-check-http-token.js",
|
||||||
|
"test-http-client-close-with-default-agent.js",
|
||||||
|
"test-http-client-default-headers-exist.js",
|
||||||
|
"test-http-client-defaults.js",
|
||||||
|
"test-http-client-encoding.js",
|
||||||
"test-http-client-get-url.js",
|
"test-http-client-get-url.js",
|
||||||
|
"test-http-client-headers-array.js",
|
||||||
|
"test-http-client-invalid-path.js",
|
||||||
|
"test-http-client-keep-alive-hint.js",
|
||||||
|
"test-http-client-race-2.js",
|
||||||
|
"test-http-client-race.js",
|
||||||
"test-http-client-read-in-error.js",
|
"test-http-client-read-in-error.js",
|
||||||
|
"test-http-client-reject-unexpected-agent.js",
|
||||||
|
"test-http-client-timeout-connect-listener.js",
|
||||||
|
"test-http-client-timeout-with-data.js",
|
||||||
|
"test-http-client-unescaped-path.js",
|
||||||
|
"test-http-client-upload-buf.js",
|
||||||
|
"test-http-client-upload.js",
|
||||||
// TODO(lev): ClientRequest.socket is not polyfilled so this test keeps
|
// TODO(lev): ClientRequest.socket is not polyfilled so this test keeps
|
||||||
// failing
|
// failing
|
||||||
//"test-http-client-set-timeout.js",
|
//"test-http-client-set-timeout.js",
|
||||||
|
"test-http-common.js",
|
||||||
|
"test-http-contentLength0.js",
|
||||||
|
"test-http-correct-hostname.js",
|
||||||
|
"test-http-date-header.js",
|
||||||
|
"test-http-decoded-auth.js",
|
||||||
|
"test-http-default-encoding.js",
|
||||||
|
"test-http-dump-req-when-res-ends.js",
|
||||||
|
"test-http-end-throw-socket-handling.js",
|
||||||
|
"test-http-eof-on-connect.js",
|
||||||
|
"test-http-extra-response.js",
|
||||||
|
"test-http-flush-headers.js",
|
||||||
|
"test-http-full-response.js",
|
||||||
|
"test-http-head-request.js",
|
||||||
|
"test-http-head-response-has-no-body-end-implicit-headers.js",
|
||||||
|
"test-http-head-response-has-no-body-end.js",
|
||||||
|
"test-http-head-response-has-no-body.js",
|
||||||
|
"test-http-head-throw-on-response-body-write.js",
|
||||||
|
"test-http-header-obstext.js",
|
||||||
|
"test-http-header-owstext.js",
|
||||||
|
"test-http-header-read.js",
|
||||||
"test-http-header-validators.js",
|
"test-http-header-validators.js",
|
||||||
|
"test-http-hex-write.js",
|
||||||
|
"test-http-highwatermark.js",
|
||||||
|
"test-http-host-headers.js",
|
||||||
|
"test-http-hostname-typechecking.js",
|
||||||
|
"test-http-incoming-message-destroy.js",
|
||||||
|
"test-http-invalid-path-chars.js",
|
||||||
|
"test-http-invalidheaderfield.js",
|
||||||
|
"test-http-invalidheaderfield2.js",
|
||||||
|
"test-http-keep-alive-timeout-custom.js",
|
||||||
|
"test-http-listening.js",
|
||||||
|
"test-http-localaddress-bind-error.js",
|
||||||
"test-http-localaddress.js",
|
"test-http-localaddress.js",
|
||||||
|
"test-http-methods.js",
|
||||||
|
"test-http-outgoing-end-types.js",
|
||||||
|
"test-http-outgoing-finished.js",
|
||||||
// TODO(bartlomieju): temporarily disabled while we iterate on the HTTP client
|
// TODO(bartlomieju): temporarily disabled while we iterate on the HTTP client
|
||||||
// "test-http-outgoing-buffer.js",
|
// "test-http-outgoing-buffer.js",
|
||||||
"test-http-outgoing-internal-headernames-getter.js",
|
"test-http-outgoing-internal-headernames-getter.js",
|
||||||
|
@ -403,53 +643,186 @@
|
||||||
// "test-http-outgoing-message-inheritance.js",
|
// "test-http-outgoing-message-inheritance.js",
|
||||||
"test-http-outgoing-renderHeaders.js",
|
"test-http-outgoing-renderHeaders.js",
|
||||||
"test-http-outgoing-settimeout.js",
|
"test-http-outgoing-settimeout.js",
|
||||||
|
"test-http-outgoing-write-types.js",
|
||||||
|
"test-http-parser-free.js",
|
||||||
|
"test-http-pause-no-dump.js",
|
||||||
|
"test-http-pause-resume-one-end.js",
|
||||||
|
"test-http-pause.js",
|
||||||
|
"test-http-pipe-fs.js",
|
||||||
|
"test-http-pipeline-requests-connection-leak.js",
|
||||||
|
"test-http-proxy.js",
|
||||||
|
"test-http-readable-data-event.js",
|
||||||
|
"test-http-request-arguments.js",
|
||||||
|
"test-http-request-dont-override-options.js",
|
||||||
|
"test-http-request-end-twice.js",
|
||||||
|
"test-http-request-end.js",
|
||||||
|
"test-http-request-invalid-method-error.js",
|
||||||
|
"test-http-request-large-payload.js",
|
||||||
|
"test-http-request-methods.js",
|
||||||
|
"test-http-res-write-end-dont-take-array.js",
|
||||||
|
"test-http-response-multiheaders.js",
|
||||||
|
"test-http-response-readable.js",
|
||||||
|
"test-http-response-writehead-returns-this.js",
|
||||||
|
"test-http-server-delete-parser.js",
|
||||||
|
"test-http-server-write-after-end.js",
|
||||||
|
"test-http-server-write-end-after-end.js",
|
||||||
|
"test-http-set-cookies.js",
|
||||||
|
"test-http-set-header-chain.js",
|
||||||
|
"test-http-status-code.js",
|
||||||
|
"test-http-status-reason-invalid-chars.js",
|
||||||
|
"test-http-uncaught-from-request-callback.js",
|
||||||
|
"test-http-url.parse-auth.js",
|
||||||
|
"test-http-url.parse-basic.js",
|
||||||
"test-http-url.parse-https.request.js",
|
"test-http-url.parse-https.request.js",
|
||||||
"test-http-url.parse-only-support-http-https-protocol.js",
|
"test-http-url.parse-only-support-http-https-protocol.js",
|
||||||
|
"test-http-url.parse-path.js",
|
||||||
|
"test-http-url.parse-post.js",
|
||||||
|
"test-http-url.parse-search.js",
|
||||||
|
"test-http-wget.js",
|
||||||
|
"test-http-write-empty-string.js",
|
||||||
|
"test-http-zerolengthbuffer.js",
|
||||||
|
"test-http2-client-request-listeners-warning.js",
|
||||||
|
"test-http2-compat-expect-handling.js",
|
||||||
|
"test-http2-compat-socket-set.js",
|
||||||
|
"test-http2-connect-options.js",
|
||||||
|
"test-http2-date-header.js",
|
||||||
|
"test-http2-dont-override.js",
|
||||||
|
"test-http2-endafterheaders.js",
|
||||||
|
"test-http2-methods.js",
|
||||||
|
"test-http2-request-response-proto.js",
|
||||||
|
"test-http2-respond-file-204.js",
|
||||||
|
"test-http2-respond-file-compat.js",
|
||||||
|
"test-http2-session-timeout.js",
|
||||||
|
"test-http2-socket-proxy.js",
|
||||||
|
"test-http2-status-code-invalid.js",
|
||||||
|
"test-http2-status-code.js",
|
||||||
|
"test-http2-stream-removelisteners-after-close.js",
|
||||||
|
"test-http2-write-empty-string.js",
|
||||||
|
"test-https-client-renegotiation-limit.js",
|
||||||
|
"test-https-connecting-to-http.js",
|
||||||
|
"test-https-foafssl.js",
|
||||||
|
"test-https-localaddress-bind-error.js",
|
||||||
|
"test-https-localaddress.js",
|
||||||
|
"test-icu-data-dir.js",
|
||||||
|
"test-icu-env.js",
|
||||||
|
"test-icu-stringwidth.js",
|
||||||
"test-icu-transcode.js",
|
"test-icu-transcode.js",
|
||||||
|
"test-inspector-stops-no-file.js",
|
||||||
|
"test-instanceof.js",
|
||||||
|
"test-internal-fs.js",
|
||||||
|
"test-internal-util-normalizeencoding.js",
|
||||||
|
"test-kill-segfault-freebsd.js",
|
||||||
|
"test-listen-fd-detached-inherit.js",
|
||||||
|
"test-listen-fd-detached.js",
|
||||||
|
"test-memory-usage-emfile.js",
|
||||||
|
"test-memory-usage.js",
|
||||||
|
"test-messagechannel.js",
|
||||||
|
"test-microtask-queue-integration.js",
|
||||||
|
"test-microtask-queue-run-immediate.js",
|
||||||
|
"test-microtask-queue-run.js",
|
||||||
|
"test-module-cache.js",
|
||||||
|
"test-module-circular-symlinks.js",
|
||||||
|
"test-module-isBuiltin.js",
|
||||||
|
"test-module-multi-extensions.js",
|
||||||
|
"test-module-nodemodulepaths.js",
|
||||||
|
"test-module-readonly.js",
|
||||||
|
"test-module-relative-lookup.js",
|
||||||
"test-net-access-byteswritten.js",
|
"test-net-access-byteswritten.js",
|
||||||
|
"test-net-after-close.js",
|
||||||
"test-net-autoselectfamily.js",
|
"test-net-autoselectfamily.js",
|
||||||
"test-net-better-error-messages-listen-path.js",
|
"test-net-better-error-messages-listen-path.js",
|
||||||
|
"test-net-better-error-messages-listen.js",
|
||||||
"test-net-better-error-messages-path.js",
|
"test-net-better-error-messages-path.js",
|
||||||
"test-net-better-error-messages-port-hostname.js",
|
"test-net-better-error-messages-port-hostname.js",
|
||||||
|
"test-net-bind-twice.js",
|
||||||
|
"test-net-buffersize.js",
|
||||||
|
"test-net-bytes-written-large.js",
|
||||||
|
"test-net-can-reset-timeout.js",
|
||||||
"test-net-connect-after-destroy.js",
|
"test-net-connect-after-destroy.js",
|
||||||
|
"test-net-connect-call-socket-connect.js",
|
||||||
"test-net-connect-destroy.js",
|
"test-net-connect-destroy.js",
|
||||||
"test-net-connect-immediate-destroy.js",
|
"test-net-connect-immediate-destroy.js",
|
||||||
"test-net-connect-immediate-finish.js",
|
"test-net-connect-immediate-finish.js",
|
||||||
"test-net-connect-no-arg.js",
|
"test-net-connect-no-arg.js",
|
||||||
|
"test-net-connect-options-fd.js",
|
||||||
|
"test-net-connect-options-ipv6.js",
|
||||||
|
"test-net-connect-options-port.js",
|
||||||
|
"test-net-connect-paused-connection.js",
|
||||||
|
"test-net-dns-custom-lookup.js",
|
||||||
"test-net-dns-error.js",
|
"test-net-dns-error.js",
|
||||||
|
"test-net-dns-lookup-skip.js",
|
||||||
|
"test-net-dns-lookup.js",
|
||||||
"test-net-during-close.js",
|
"test-net-during-close.js",
|
||||||
|
"test-net-eaddrinuse.js",
|
||||||
"test-net-end-close.js",
|
"test-net-end-close.js",
|
||||||
"test-net-end-without-connect.js",
|
"test-net-end-without-connect.js",
|
||||||
|
"test-net-error-twice.js",
|
||||||
"test-net-isip.js",
|
"test-net-isip.js",
|
||||||
"test-net-isipv4.js",
|
"test-net-isipv4.js",
|
||||||
"test-net-isipv6.js",
|
"test-net-isipv6.js",
|
||||||
|
"test-net-keepalive.js",
|
||||||
|
"test-net-listen-after-destroying-stdin.js",
|
||||||
"test-net-listen-close-server-callback-is-not-function.js",
|
"test-net-listen-close-server-callback-is-not-function.js",
|
||||||
"test-net-listen-close-server.js",
|
"test-net-listen-close-server.js",
|
||||||
|
"test-net-listen-error.js",
|
||||||
"test-net-listen-invalid-port.js",
|
"test-net-listen-invalid-port.js",
|
||||||
"test-net-listening.js",
|
"test-net-listening.js",
|
||||||
|
"test-net-local-address-port.js",
|
||||||
"test-net-localerror.js",
|
"test-net-localerror.js",
|
||||||
"test-net-options-lookup.js",
|
"test-net-options-lookup.js",
|
||||||
|
"test-net-pause-resume-connecting.js",
|
||||||
|
"test-net-persistent-keepalive.js",
|
||||||
|
"test-net-persistent-nodelay.js",
|
||||||
|
"test-net-persistent-ref-unref.js",
|
||||||
"test-net-pipe-connect-errors.js",
|
"test-net-pipe-connect-errors.js",
|
||||||
|
"test-net-reconnect.js",
|
||||||
|
"test-net-remote-address-port.js",
|
||||||
|
"test-net-remote-address.js",
|
||||||
|
"test-net-server-capture-rejection.js",
|
||||||
|
"test-net-server-close.js",
|
||||||
"test-net-server-listen-options-signal.js",
|
"test-net-server-listen-options-signal.js",
|
||||||
"test-net-server-listen-options.js",
|
"test-net-server-listen-options.js",
|
||||||
"test-net-server-listen-path.js",
|
"test-net-server-listen-path.js",
|
||||||
"test-net-server-listen-remove-callback.js",
|
"test-net-server-listen-remove-callback.js",
|
||||||
"test-net-server-options.js",
|
"test-net-server-options.js",
|
||||||
|
"test-net-server-pause-on-connect.js",
|
||||||
"test-net-server-unref-persistent.js",
|
"test-net-server-unref-persistent.js",
|
||||||
"test-net-server-unref.js",
|
"test-net-server-unref.js",
|
||||||
|
"test-net-settimeout.js",
|
||||||
|
"test-net-socket-close-after-end.js",
|
||||||
|
"test-net-socket-connect-invalid-autoselectfamily.js",
|
||||||
|
"test-net-socket-connect-without-cb.js",
|
||||||
|
"test-net-socket-connecting.js",
|
||||||
|
"test-net-socket-destroy-send.js",
|
||||||
"test-net-socket-destroy-twice.js",
|
"test-net-socket-destroy-twice.js",
|
||||||
|
"test-net-socket-end-before-connect.js",
|
||||||
|
"test-net-socket-end-callback.js",
|
||||||
"test-net-socket-no-halfopen-enforcer.js",
|
"test-net-socket-no-halfopen-enforcer.js",
|
||||||
|
"test-net-socket-ready-without-cb.js",
|
||||||
"test-net-socket-setnodelay.js",
|
"test-net-socket-setnodelay.js",
|
||||||
|
"test-net-socket-timeout-unref.js",
|
||||||
|
"test-net-socket-write-after-close.js",
|
||||||
|
"test-net-socket-write-error.js",
|
||||||
|
"test-net-sync-cork.js",
|
||||||
"test-net-timeout-no-handle.js",
|
"test-net-timeout-no-handle.js",
|
||||||
|
"test-net-writable.js",
|
||||||
"test-net-write-arguments.js",
|
"test-net-write-arguments.js",
|
||||||
|
"test-net-write-connect-write.js",
|
||||||
|
"test-net-write-fully-async-buffer.js",
|
||||||
|
"test-net-write-fully-async-hex-string.js",
|
||||||
|
"test-net-write-slow.js",
|
||||||
"test-next-tick-doesnt-hang.js",
|
"test-next-tick-doesnt-hang.js",
|
||||||
|
"test-next-tick-domain.js",
|
||||||
|
"test-next-tick-errors.js",
|
||||||
"test-next-tick-fixed-queue-regression.js",
|
"test-next-tick-fixed-queue-regression.js",
|
||||||
"test-next-tick-intentional-starvation.js",
|
"test-next-tick-intentional-starvation.js",
|
||||||
"test-next-tick-ordering.js",
|
"test-next-tick-ordering.js",
|
||||||
"test-next-tick-ordering2.js",
|
"test-next-tick-ordering2.js",
|
||||||
"test-next-tick-when-exiting.js",
|
"test-next-tick-when-exiting.js",
|
||||||
"test-next-tick.js",
|
"test-next-tick.js",
|
||||||
|
"test-no-node-snapshot.js",
|
||||||
"test-nodeeventtarget.js",
|
"test-nodeeventtarget.js",
|
||||||
|
"test-os-homedir-no-envvar.js",
|
||||||
"test-os.js",
|
"test-os.js",
|
||||||
"test-outgoing-message-destroy.js",
|
"test-outgoing-message-destroy.js",
|
||||||
"test-outgoing-message-pipe.js",
|
"test-outgoing-message-pipe.js",
|
||||||
|
@ -468,15 +841,35 @@
|
||||||
"test-path-win32-exists.js",
|
"test-path-win32-exists.js",
|
||||||
"test-path-zero-length-strings.js",
|
"test-path-zero-length-strings.js",
|
||||||
"test-path.js",
|
"test-path.js",
|
||||||
|
"test-perf-gc-crash.js",
|
||||||
|
"test-performanceobserver-gc.js",
|
||||||
|
"test-pipe-return-val.js",
|
||||||
|
"test-pipe-writev.js",
|
||||||
|
"test-process-abort.js",
|
||||||
|
"test-process-argv-0.js",
|
||||||
"test-process-beforeexit.js",
|
"test-process-beforeexit.js",
|
||||||
"test-process-binding-internalbinding-allowlist.js",
|
"test-process-binding-internalbinding-allowlist.js",
|
||||||
|
"test-process-binding.js",
|
||||||
|
"test-process-dlopen-undefined-exports.js",
|
||||||
|
"test-process-domain-segfault.js",
|
||||||
|
"test-process-emitwarning.js",
|
||||||
"test-process-env-allowed-flags.js",
|
"test-process-env-allowed-flags.js",
|
||||||
|
"test-process-env-delete.js",
|
||||||
|
"test-process-env-windows-error-reset.js",
|
||||||
"test-process-exit-from-before-exit.js",
|
"test-process-exit-from-before-exit.js",
|
||||||
"test-process-exit-handler.js",
|
"test-process-exit-handler.js",
|
||||||
"test-process-exit-recursive.js",
|
"test-process-exit-recursive.js",
|
||||||
"test-process-exit.js",
|
"test-process-exit.js",
|
||||||
|
"test-process-getgroups.js",
|
||||||
|
"test-process-hrtime-bigint.js",
|
||||||
"test-process-kill-pid.js",
|
"test-process-kill-pid.js",
|
||||||
|
"test-process-next-tick.js",
|
||||||
|
"test-process-no-deprecation.js",
|
||||||
|
"test-process-ppid.js",
|
||||||
|
"test-process-really-exit.js",
|
||||||
"test-process-uptime.js",
|
"test-process-uptime.js",
|
||||||
|
"test-process-warning.js",
|
||||||
|
"test-promise-handled-rejection-no-warning.js",
|
||||||
"test-promise-unhandled-silent.js",
|
"test-promise-unhandled-silent.js",
|
||||||
"test-promise-unhandled-throw-handler.js",
|
"test-promise-unhandled-throw-handler.js",
|
||||||
"test-punycode.js",
|
"test-punycode.js",
|
||||||
|
@ -484,6 +877,14 @@
|
||||||
"test-querystring-maxKeys-non-finite.js",
|
"test-querystring-maxKeys-non-finite.js",
|
||||||
"test-querystring-multichar-separator.js",
|
"test-querystring-multichar-separator.js",
|
||||||
"test-querystring.js",
|
"test-querystring.js",
|
||||||
|
"test-readable-from-iterator-closing.js",
|
||||||
|
"test-readable-from.js",
|
||||||
|
"test-readable-large-hwm.js",
|
||||||
|
"test-readable-single-end.js",
|
||||||
|
"test-readline-async-iterators-destroy.js",
|
||||||
|
"test-readline-async-iterators.js",
|
||||||
|
"test-readline-carriage-return-between-chunks.js",
|
||||||
|
"test-readline-csi.js",
|
||||||
"test-readline-emit-keypress-events.js",
|
"test-readline-emit-keypress-events.js",
|
||||||
"test-readline-interface-escapecodetimeout.js",
|
"test-readline-interface-escapecodetimeout.js",
|
||||||
"test-readline-keys.js",
|
"test-readline-keys.js",
|
||||||
|
@ -492,7 +893,31 @@
|
||||||
"test-readline-set-raw-mode.js",
|
"test-readline-set-raw-mode.js",
|
||||||
"test-readline-undefined-columns.js",
|
"test-readline-undefined-columns.js",
|
||||||
"test-readline.js",
|
"test-readline.js",
|
||||||
|
"test-ref-unref-return.js",
|
||||||
|
"test-regression-object-prototype.js",
|
||||||
|
"test-require-invalid-package.js",
|
||||||
|
"test-require-long-path.js",
|
||||||
|
"test-require-nul.js",
|
||||||
|
"test-require-process.js",
|
||||||
|
"test-signal-handler-remove-on-exit.js",
|
||||||
|
"test-signal-handler.js",
|
||||||
|
"test-socket-address.js",
|
||||||
|
"test-socket-write-after-fin-error.js",
|
||||||
|
"test-source-map-enable.js",
|
||||||
|
"test-spawn-cmd-named-pipe.js",
|
||||||
"test-stdin-from-file-spawn.js",
|
"test-stdin-from-file-spawn.js",
|
||||||
|
"test-stdin-hang.js",
|
||||||
|
"test-stdin-pipe-large.js",
|
||||||
|
"test-stdin-pipe-resume.js",
|
||||||
|
"test-stdin-script-child-option.js",
|
||||||
|
"test-stdio-pipe-access.js",
|
||||||
|
"test-stdio-pipe-redirect.js",
|
||||||
|
"test-stdio-pipe-stderr.js",
|
||||||
|
"test-stdio-undestroy.js",
|
||||||
|
"test-stdout-cannot-be-closed-child-process-pipe.js",
|
||||||
|
"test-stdout-pipeline-destroy.js",
|
||||||
|
"test-stdout-stderr-reading.js",
|
||||||
|
"test-stdout-stderr-write.js",
|
||||||
"test-stream-add-abort-signal.js",
|
"test-stream-add-abort-signal.js",
|
||||||
"test-stream-aliases-legacy.js",
|
"test-stream-aliases-legacy.js",
|
||||||
"test-stream-auto-destroy.js",
|
"test-stream-auto-destroy.js",
|
||||||
|
@ -500,22 +925,30 @@
|
||||||
"test-stream-backpressure.js",
|
"test-stream-backpressure.js",
|
||||||
"test-stream-big-packet.js",
|
"test-stream-big-packet.js",
|
||||||
"test-stream-big-push.js",
|
"test-stream-big-push.js",
|
||||||
|
"test-stream-catch-rejections.js",
|
||||||
"test-stream-construct.js",
|
"test-stream-construct.js",
|
||||||
|
"test-stream-decoder-objectmode.js",
|
||||||
"test-stream-destroy-event-order.js",
|
"test-stream-destroy-event-order.js",
|
||||||
"test-stream-duplex-destroy.js",
|
"test-stream-duplex-destroy.js",
|
||||||
"test-stream-duplex-end.js",
|
"test-stream-duplex-end.js",
|
||||||
"test-stream-duplex-from.js",
|
"test-stream-duplex-from.js",
|
||||||
"test-stream-duplex-props.js",
|
"test-stream-duplex-props.js",
|
||||||
"test-stream-duplex-readable-end.js",
|
"test-stream-duplex-readable-end.js",
|
||||||
|
"test-stream-duplex-readable-writable.js",
|
||||||
"test-stream-duplex-writable-finished.js",
|
"test-stream-duplex-writable-finished.js",
|
||||||
"test-stream-duplex.js",
|
"test-stream-duplex.js",
|
||||||
|
"test-stream-end-of-streams.js",
|
||||||
"test-stream-end-paused.js",
|
"test-stream-end-paused.js",
|
||||||
"test-stream-error-once.js",
|
"test-stream-error-once.js",
|
||||||
"test-stream-events-prepend.js",
|
"test-stream-events-prepend.js",
|
||||||
|
"test-stream-filter.js",
|
||||||
|
"test-stream-flatMap.js",
|
||||||
|
"test-stream-forEach.js",
|
||||||
"test-stream-inheritance.js",
|
"test-stream-inheritance.js",
|
||||||
"test-stream-ispaused.js",
|
"test-stream-ispaused.js",
|
||||||
"test-stream-objectmode-undefined.js",
|
"test-stream-objectmode-undefined.js",
|
||||||
"test-stream-once-readable-pipe.js",
|
"test-stream-once-readable-pipe.js",
|
||||||
|
"test-stream-passthrough-drain.js",
|
||||||
"test-stream-pipe-after-end.js",
|
"test-stream-pipe-after-end.js",
|
||||||
"test-stream-pipe-await-drain-manual-resume.js",
|
"test-stream-pipe-await-drain-manual-resume.js",
|
||||||
"test-stream-pipe-await-drain-push-while-write.js",
|
"test-stream-pipe-await-drain-push-while-write.js",
|
||||||
|
@ -523,6 +956,7 @@
|
||||||
"test-stream-pipe-cleanup-pause.js",
|
"test-stream-pipe-cleanup-pause.js",
|
||||||
"test-stream-pipe-cleanup.js",
|
"test-stream-pipe-cleanup.js",
|
||||||
"test-stream-pipe-error-handling.js",
|
"test-stream-pipe-error-handling.js",
|
||||||
|
"test-stream-pipe-error-unhandled.js",
|
||||||
"test-stream-pipe-event.js",
|
"test-stream-pipe-event.js",
|
||||||
"test-stream-pipe-flow-after-unpipe.js",
|
"test-stream-pipe-flow-after-unpipe.js",
|
||||||
"test-stream-pipe-flow.js",
|
"test-stream-pipe-flow.js",
|
||||||
|
@ -533,8 +967,12 @@
|
||||||
"test-stream-pipe-unpipe-streams.js",
|
"test-stream-pipe-unpipe-streams.js",
|
||||||
"test-stream-pipe-without-listenerCount.js",
|
"test-stream-pipe-without-listenerCount.js",
|
||||||
"test-stream-pipeline-async-iterator.js",
|
"test-stream-pipeline-async-iterator.js",
|
||||||
|
"test-stream-pipeline-duplex.js",
|
||||||
|
"test-stream-pipeline-listeners.js",
|
||||||
"test-stream-pipeline-queued-end-in-destroy.js",
|
"test-stream-pipeline-queued-end-in-destroy.js",
|
||||||
|
"test-stream-pipeline-uncaught.js",
|
||||||
"test-stream-pipeline-with-empty-string.js",
|
"test-stream-pipeline-with-empty-string.js",
|
||||||
|
"test-stream-push-order.js",
|
||||||
"test-stream-push-strings.js",
|
"test-stream-push-strings.js",
|
||||||
"test-stream-readable-aborted.js",
|
"test-stream-readable-aborted.js",
|
||||||
"test-stream-readable-add-chunk-during-data.js",
|
"test-stream-readable-add-chunk-during-data.js",
|
||||||
|
@ -566,15 +1004,21 @@
|
||||||
"test-stream-readable-resumeScheduled.js",
|
"test-stream-readable-resumeScheduled.js",
|
||||||
"test-stream-readable-setEncoding-existing-buffers.js",
|
"test-stream-readable-setEncoding-existing-buffers.js",
|
||||||
"test-stream-readable-setEncoding-null.js",
|
"test-stream-readable-setEncoding-null.js",
|
||||||
|
"test-stream-readable-strategy-option.js",
|
||||||
|
"test-stream-readable-unpipe-resume.js",
|
||||||
"test-stream-readable-unshift.js",
|
"test-stream-readable-unshift.js",
|
||||||
"test-stream-readable-with-unimplemented-_read.js",
|
"test-stream-readable-with-unimplemented-_read.js",
|
||||||
"test-stream-readableListening-state.js",
|
"test-stream-readableListening-state.js",
|
||||||
|
"test-stream-reduce.js",
|
||||||
|
"test-stream-toArray.js",
|
||||||
|
"test-stream-toWeb-allows-server-response.js",
|
||||||
"test-stream-transform-callback-twice.js",
|
"test-stream-transform-callback-twice.js",
|
||||||
"test-stream-transform-constructor-set-methods.js",
|
"test-stream-transform-constructor-set-methods.js",
|
||||||
"test-stream-transform-destroy.js",
|
"test-stream-transform-destroy.js",
|
||||||
"test-stream-transform-final-sync.js",
|
"test-stream-transform-final-sync.js",
|
||||||
"test-stream-transform-final.js",
|
"test-stream-transform-final.js",
|
||||||
"test-stream-transform-flush-data.js",
|
"test-stream-transform-flush-data.js",
|
||||||
|
"test-stream-transform-hwm0.js",
|
||||||
"test-stream-transform-objectmode-falsey-value.js",
|
"test-stream-transform-objectmode-falsey-value.js",
|
||||||
"test-stream-transform-split-highwatermark.js",
|
"test-stream-transform-split-highwatermark.js",
|
||||||
"test-stream-transform-split-objectmode.js",
|
"test-stream-transform-split-objectmode.js",
|
||||||
|
@ -589,6 +1033,7 @@
|
||||||
"test-stream-writable-decoded-encoding.js",
|
"test-stream-writable-decoded-encoding.js",
|
||||||
"test-stream-writable-destroy.js",
|
"test-stream-writable-destroy.js",
|
||||||
"test-stream-writable-end-cb-error.js",
|
"test-stream-writable-end-cb-error.js",
|
||||||
|
"test-stream-writable-end-cb-uncaught.js",
|
||||||
"test-stream-writable-end-multiple.js",
|
"test-stream-writable-end-multiple.js",
|
||||||
"test-stream-writable-ended-state.js",
|
"test-stream-writable-ended-state.js",
|
||||||
"test-stream-writable-final-async.js",
|
"test-stream-writable-final-async.js",
|
||||||
|
@ -616,6 +1061,7 @@
|
||||||
"test-stream2-basic.js",
|
"test-stream2-basic.js",
|
||||||
"test-stream2-compatibility.js",
|
"test-stream2-compatibility.js",
|
||||||
"test-stream2-decode-partial.js",
|
"test-stream2-decode-partial.js",
|
||||||
|
"test-stream2-finish-pipe-error.js",
|
||||||
"test-stream2-finish-pipe.js",
|
"test-stream2-finish-pipe.js",
|
||||||
"test-stream2-large-read-stall.js",
|
"test-stream2-large-read-stall.js",
|
||||||
"test-stream2-objects.js",
|
"test-stream2-objects.js",
|
||||||
|
@ -638,24 +1084,60 @@
|
||||||
"test-stream3-cork-end.js",
|
"test-stream3-cork-end.js",
|
||||||
"test-stream3-cork-uncork.js",
|
"test-stream3-cork-uncork.js",
|
||||||
"test-stream3-pause-then-read.js",
|
"test-stream3-pause-then-read.js",
|
||||||
|
"test-stream3-pipeline-async-iterator.js",
|
||||||
"test-streams-highwatermark.js",
|
"test-streams-highwatermark.js",
|
||||||
"test-string-decoder.js",
|
"test-string-decoder.js",
|
||||||
|
"test-stringbytes-external.js",
|
||||||
|
"test-sync-fileread.js",
|
||||||
|
"test-sys.js",
|
||||||
|
"test-tick-processor-arguments.js",
|
||||||
"test-timers-api-refs.js",
|
"test-timers-api-refs.js",
|
||||||
"test-timers-args.js",
|
"test-timers-args.js",
|
||||||
"test-timers-clear-null-does-not-throw-error.js",
|
"test-timers-clear-null-does-not-throw-error.js",
|
||||||
"test-timers-clear-object-does-not-throw-error.js",
|
"test-timers-clear-object-does-not-throw-error.js",
|
||||||
"test-timers-clear-timeout-interval-equivalent.js",
|
"test-timers-clear-timeout-interval-equivalent.js",
|
||||||
|
"test-timers-clearImmediate-als.js",
|
||||||
"test-timers-clearImmediate.js",
|
"test-timers-clearImmediate.js",
|
||||||
|
"test-timers-immediate-queue.js",
|
||||||
|
"test-timers-immediate.js",
|
||||||
"test-timers-interval-throw.js",
|
"test-timers-interval-throw.js",
|
||||||
"test-timers-non-integer-delay.js",
|
"test-timers-non-integer-delay.js",
|
||||||
|
"test-timers-refresh-in-callback.js",
|
||||||
"test-timers-refresh.js",
|
"test-timers-refresh.js",
|
||||||
"test-timers-same-timeout-wrong-list-deleted.js",
|
"test-timers-same-timeout-wrong-list-deleted.js",
|
||||||
|
"test-timers-setimmediate-infinite-loop.js",
|
||||||
|
"test-timers-socket-timeout-removes-other-socket-unref-timer.js",
|
||||||
"test-timers-timeout-with-non-integer.js",
|
"test-timers-timeout-with-non-integer.js",
|
||||||
"test-timers-uncaught-exception.js",
|
"test-timers-uncaught-exception.js",
|
||||||
"test-timers-unref-throw-then-ref.js",
|
"test-timers-unref-throw-then-ref.js",
|
||||||
|
"test-timers-unref.js",
|
||||||
|
"test-timers-unrefd-interval-still-fires.js",
|
||||||
|
"test-timers-unrefed-in-beforeexit.js",
|
||||||
|
"test-timers-unrefed-in-callback.js",
|
||||||
"test-timers-user-call.js",
|
"test-timers-user-call.js",
|
||||||
"test-timers-zero-timeout.js",
|
"test-timers-zero-timeout.js",
|
||||||
|
"test-timers.js",
|
||||||
|
"test-tls-alert-handling.js",
|
||||||
|
"test-tls-alert.js",
|
||||||
|
"test-tls-client-renegotiation-limit.js",
|
||||||
|
"test-tls-dhe.js",
|
||||||
|
"test-tls-ecdh-auto.js",
|
||||||
|
"test-tls-ecdh-multiple.js",
|
||||||
|
"test-tls-ecdh.js",
|
||||||
|
"test-tls-enable-trace-cli.js",
|
||||||
|
"test-tls-enable-trace.js",
|
||||||
|
"test-tls-env-extra-ca-no-crypto.js",
|
||||||
|
"test-tls-ocsp-callback.js",
|
||||||
|
"test-tls-psk-server.js",
|
||||||
|
"test-tls-securepair-server.js",
|
||||||
|
"test-tls-server-verify.js",
|
||||||
|
"test-tls-session-cache.js",
|
||||||
|
"test-tls-set-ciphers.js",
|
||||||
|
"test-tls-transport-destroy-after-own-gc.js",
|
||||||
|
"test-trace-events-async-hooks-dynamic.js",
|
||||||
|
"test-trace-events-async-hooks-worker.js",
|
||||||
"test-tty-stdin-end.js",
|
"test-tty-stdin-end.js",
|
||||||
|
"test-tz-version.js",
|
||||||
"test-url-domain-ascii-unicode.js",
|
"test-url-domain-ascii-unicode.js",
|
||||||
"test-url-fileurltopath.js",
|
"test-url-fileurltopath.js",
|
||||||
"test-url-format-invalid-input.js",
|
"test-url-format-invalid-input.js",
|
||||||
|
@ -666,19 +1148,31 @@
|
||||||
"test-url-pathtofileurl.js",
|
"test-url-pathtofileurl.js",
|
||||||
"test-url-relative.js",
|
"test-url-relative.js",
|
||||||
"test-url-urltooptions.js",
|
"test-url-urltooptions.js",
|
||||||
|
"test-utf8-scripts.js",
|
||||||
"test-util-deprecate-invalid-code.js",
|
"test-util-deprecate-invalid-code.js",
|
||||||
"test-util-deprecate.js",
|
"test-util-deprecate.js",
|
||||||
"test-util-format.js",
|
"test-util-format.js",
|
||||||
"test-util-inherits.js",
|
"test-util-inherits.js",
|
||||||
|
"test-util-inspect-getters-accessing-this.js",
|
||||||
"test-util-inspect-long-running.js",
|
"test-util-inspect-long-running.js",
|
||||||
"test-util-inspect-namespace.js",
|
"test-util-inspect-namespace.js",
|
||||||
"test-util-inspect-proxy.js",
|
"test-util-inspect-proxy.js",
|
||||||
"test-util-inspect.js",
|
"test-util-inspect.js",
|
||||||
"test-util-isDeepStrictEqual.js",
|
"test-util-isDeepStrictEqual.js",
|
||||||
|
"test-util-primordial-monkeypatching.js",
|
||||||
"test-util-promisify.js",
|
"test-util-promisify.js",
|
||||||
"test-util-types-exists.js",
|
"test-util-types-exists.js",
|
||||||
"test-util-types.js",
|
"test-util-types.js",
|
||||||
"test-util.js",
|
"test-util.js",
|
||||||
|
"test-uv-binding-constant.js",
|
||||||
|
"test-uv-unmapped-exception.js",
|
||||||
|
"test-v8-coverage.js",
|
||||||
|
"test-v8-deserialize-buffer.js",
|
||||||
|
"test-v8-flag-pool-size-0.js",
|
||||||
|
"test-v8-global-setter.js",
|
||||||
|
"test-v8-stop-coverage.js",
|
||||||
|
"test-v8-take-coverage-noop.js",
|
||||||
|
"test-v8-take-coverage.js",
|
||||||
"test-vm-access-process-env.js",
|
"test-vm-access-process-env.js",
|
||||||
"test-vm-attributes-property-not-on-sandbox.js",
|
"test-vm-attributes-property-not-on-sandbox.js",
|
||||||
"test-vm-codegen.js",
|
"test-vm-codegen.js",
|
||||||
|
@ -723,28 +1217,39 @@
|
||||||
"test-vm-timeout-escape-promise-2.js",
|
"test-vm-timeout-escape-promise-2.js",
|
||||||
"test-vm-timeout-escape-promise.js",
|
"test-vm-timeout-escape-promise.js",
|
||||||
"test-vm-timeout.js",
|
"test-vm-timeout.js",
|
||||||
|
"test-weakref.js",
|
||||||
|
"test-webcrypto-encrypt-decrypt.js",
|
||||||
"test-webcrypto-sign-verify.js",
|
"test-webcrypto-sign-verify.js",
|
||||||
|
"test-websocket.js",
|
||||||
|
"test-webstream-string-tag.js",
|
||||||
"test-whatwg-encoding-custom-api-basics.js",
|
"test-whatwg-encoding-custom-api-basics.js",
|
||||||
"test-whatwg-encoding-custom-textdecoder-ignorebom.js",
|
"test-whatwg-encoding-custom-textdecoder-ignorebom.js",
|
||||||
"test-whatwg-encoding-custom-textdecoder-streaming.js",
|
"test-whatwg-encoding-custom-textdecoder-streaming.js",
|
||||||
"test-whatwg-events-add-event-listener-options-passive.js",
|
"test-whatwg-events-add-event-listener-options-passive.js",
|
||||||
"test-whatwg-events-add-event-listener-options-signal.js",
|
"test-whatwg-events-add-event-listener-options-signal.js",
|
||||||
"test-whatwg-events-customevent.js",
|
"test-whatwg-events-customevent.js",
|
||||||
|
"test-whatwg-readablebytestreambyob.js",
|
||||||
"test-whatwg-url-custom-deepequal.js",
|
"test-whatwg-url-custom-deepequal.js",
|
||||||
"test-whatwg-url-custom-global.js",
|
"test-whatwg-url-custom-global.js",
|
||||||
"test-whatwg-url-custom-href-side-effect.js",
|
"test-whatwg-url-custom-href-side-effect.js",
|
||||||
"test-whatwg-url-custom-tostringtag.js",
|
"test-whatwg-url-custom-tostringtag.js",
|
||||||
"test-whatwg-url-override-hostname.js",
|
"test-whatwg-url-override-hostname.js",
|
||||||
"test-whatwg-url-properties.js",
|
"test-whatwg-url-properties.js",
|
||||||
|
"test-worker-cleanexit-with-js.js",
|
||||||
"test-worker-message-port-infinite-message-loop.js",
|
"test-worker-message-port-infinite-message-loop.js",
|
||||||
"test-worker-message-port-multiple-sharedarraybuffers.js",
|
"test-worker-message-port-multiple-sharedarraybuffers.js",
|
||||||
"test-worker-message-port-receive-message.js",
|
"test-worker-message-port-receive-message.js",
|
||||||
|
"test-worker-on-process-exit.js",
|
||||||
|
"test-worker-ref-onexit.js",
|
||||||
|
"test-worker-terminate-unrefed.js",
|
||||||
"test-zlib-close-after-error.js",
|
"test-zlib-close-after-error.js",
|
||||||
"test-zlib-close-after-write.js",
|
"test-zlib-close-after-write.js",
|
||||||
"test-zlib-convenience-methods.js",
|
"test-zlib-convenience-methods.js",
|
||||||
|
"test-zlib-create-raw.js",
|
||||||
"test-zlib-deflate-raw-inherits.js",
|
"test-zlib-deflate-raw-inherits.js",
|
||||||
"test-zlib-destroy-pipe.js",
|
"test-zlib-destroy-pipe.js",
|
||||||
"test-zlib-empty-buffer.js",
|
"test-zlib-empty-buffer.js",
|
||||||
|
"test-zlib-flush-write-sync-interleaved.js",
|
||||||
"test-zlib-from-string.js",
|
"test-zlib-from-string.js",
|
||||||
"test-zlib-invalid-input.js",
|
"test-zlib-invalid-input.js",
|
||||||
"test-zlib-no-stream.js",
|
"test-zlib-no-stream.js",
|
||||||
|
@ -762,14 +1267,41 @@
|
||||||
"console-dumb-tty.js",
|
"console-dumb-tty.js",
|
||||||
"no_dropped_stdio.js",
|
"no_dropped_stdio.js",
|
||||||
"no_interleaved_stdio.js",
|
"no_interleaved_stdio.js",
|
||||||
|
"test-set-raw-mode-reset-process-exit.js",
|
||||||
|
"test-set-raw-mode-reset.js",
|
||||||
"test-tty-color-support-warning-2.js",
|
"test-tty-color-support-warning-2.js",
|
||||||
"test-tty-color-support-warning.js",
|
"test-tty-color-support-warning.js",
|
||||||
|
"test-tty-stdin-call-end.js",
|
||||||
"test-tty-stdin-end.js",
|
"test-tty-stdin-end.js",
|
||||||
"test-tty-stdout-end.js"
|
"test-tty-stdout-end.js"
|
||||||
],
|
],
|
||||||
"pummel": [],
|
"pummel": [
|
||||||
|
"test-crypto-dh-hash.js",
|
||||||
|
"test-crypto-timing-safe-equal-benchmarks.js",
|
||||||
|
"test-dh-regr.js",
|
||||||
|
"test-fs-largefile.js",
|
||||||
|
"test-fs-readfile-tostring-fail.js",
|
||||||
|
"test-fs-watch-system-limit.js",
|
||||||
|
"test-heapsnapshot-near-heap-limit-big.js",
|
||||||
|
"test-net-many-clients.js",
|
||||||
|
"test-net-pingpong-delay.js",
|
||||||
|
"test-process-cpuUsage.js",
|
||||||
|
"test-stream-pipe-multi.js"
|
||||||
|
],
|
||||||
"sequential": [
|
"sequential": [
|
||||||
"test-child-process-exit.js"
|
"test-buffer-creation-regression.js",
|
||||||
|
"test-child-process-exit.js",
|
||||||
|
"test-http-server-keep-alive-timeout-slow-server.js",
|
||||||
|
"test-net-better-error-messages-port.js",
|
||||||
|
"test-net-connect-handle-econnrefused.js",
|
||||||
|
"test-net-connect-local-error.js",
|
||||||
|
"test-net-reconnect-error.js",
|
||||||
|
"test-net-response-size.js",
|
||||||
|
"test-net-server-bind.js",
|
||||||
|
"test-tls-lookup.js",
|
||||||
|
"test-tls-psk-client.js",
|
||||||
|
"test-tls-securepair-client.js",
|
||||||
|
"test-tls-session-timeout.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"windowsIgnore": {
|
"windowsIgnore": {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
143
tests/node_compat/test/abort/test-addon-uv-handle-leak.js
Normal file
143
tests/node_compat/test/abort/test-addon-uv-handle-leak.js
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const cp = require('child_process');
|
||||||
|
const { spawnSync } = require('child_process');
|
||||||
|
|
||||||
|
// This is a sibling test to test/addons/uv-handle-leak.
|
||||||
|
|
||||||
|
const bindingPath = path.resolve(
|
||||||
|
__dirname, '..', 'addons', 'uv-handle-leak', 'build',
|
||||||
|
`${common.buildType}/binding.node`);
|
||||||
|
|
||||||
|
if (!fs.existsSync(bindingPath))
|
||||||
|
common.skip('binding not built yet');
|
||||||
|
|
||||||
|
if (process.argv[2] === 'child') {
|
||||||
|
|
||||||
|
const { Worker } = require('worker_threads');
|
||||||
|
|
||||||
|
// The worker thread loads and then unloads `bindingPath`. Because of this the
|
||||||
|
// symbols in `bindingPath` are lost when the worker thread quits, but the
|
||||||
|
// number of open handles in the worker thread's event loop is assessed in the
|
||||||
|
// main thread afterwards, and the names of the callbacks associated with the
|
||||||
|
// open handles is retrieved at that time as well. Thus, we require
|
||||||
|
// `bindingPath` here so that the symbols and their names survive the life
|
||||||
|
// cycle of the worker thread.
|
||||||
|
require(bindingPath);
|
||||||
|
|
||||||
|
new Worker(`
|
||||||
|
const binding = require(${JSON.stringify(bindingPath)});
|
||||||
|
|
||||||
|
binding.leakHandle();
|
||||||
|
binding.leakHandle(0);
|
||||||
|
binding.leakHandle(0x42);
|
||||||
|
`, { eval: true });
|
||||||
|
} else {
|
||||||
|
const child = cp.spawnSync(process.execPath, [__filename, 'child']);
|
||||||
|
const stderr = child.stderr.toString();
|
||||||
|
|
||||||
|
assert.strictEqual(child.stdout.toString(), '');
|
||||||
|
|
||||||
|
const lines = stderr.split('\n');
|
||||||
|
|
||||||
|
let state = 'initial';
|
||||||
|
|
||||||
|
// Parse output that is formatted like this:
|
||||||
|
|
||||||
|
// uv loop at [0x559b65ed5770] has open handles:
|
||||||
|
// [0x7f2de0018430] timer (active)
|
||||||
|
// Close callback: 0x7f2df31de220 CloseCallback(uv_handle_s*) [...]
|
||||||
|
// Data: 0x7f2df33df140 example_instance [...]
|
||||||
|
// (First field): 0x7f2df33dedc0 vtable for ExampleOwnerClass [...]
|
||||||
|
// [0x7f2de000b870] timer
|
||||||
|
// Close callback: 0x7f2df31de220 CloseCallback(uv_handle_s*) [...]
|
||||||
|
// Data: (nil)
|
||||||
|
// [0x7f2de000b910] timer
|
||||||
|
// Close callback: 0x7f2df31de220 CloseCallback(uv_handle_s*) [...]
|
||||||
|
// Data: 0x42
|
||||||
|
// uv loop at [0x559b65ed5770] has 3 open handles in total
|
||||||
|
|
||||||
|
function isGlibc() {
|
||||||
|
try {
|
||||||
|
const lddOut = spawnSync('ldd', [process.execPath]).stdout;
|
||||||
|
const libcInfo = lddOut.toString().split('\n').map(
|
||||||
|
(line) => line.match(/libc\.so.+=>\s*(\S+)\s/)).filter((info) => info);
|
||||||
|
if (libcInfo.length === 0)
|
||||||
|
return false;
|
||||||
|
const nmOut = spawnSync('nm', ['-D', libcInfo[0][1]]).stdout;
|
||||||
|
if (/gnu_get_libc_version/.test(nmOut))
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!(common.isFreeBSD ||
|
||||||
|
common.isAIX ||
|
||||||
|
common.isIBMi ||
|
||||||
|
(common.isLinux && !isGlibc()) ||
|
||||||
|
common.isWindows)) {
|
||||||
|
assert(stderr.includes('ExampleOwnerClass'), stderr);
|
||||||
|
assert(stderr.includes('CloseCallback'), stderr);
|
||||||
|
assert(stderr.includes('example_instance'), stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (lines.length > 0) {
|
||||||
|
const line = lines.shift().trim();
|
||||||
|
if (line.length === 0) {
|
||||||
|
continue; // Skip empty lines.
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case 'initial':
|
||||||
|
assert.match(line, /^uv loop at \[.+\] has open handles:$/);
|
||||||
|
state = 'handle-start';
|
||||||
|
break;
|
||||||
|
case 'handle-start':
|
||||||
|
if (/^uv loop at \[.+\] has \d+ open handles in total$/.test(line)) {
|
||||||
|
state = 'source-line';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
assert.match(line, /^\[.+\] timer( \(active\))?$/);
|
||||||
|
state = 'close-callback';
|
||||||
|
break;
|
||||||
|
case 'close-callback':
|
||||||
|
assert.match(line, /^Close callback:/);
|
||||||
|
state = 'data';
|
||||||
|
break;
|
||||||
|
case 'data':
|
||||||
|
assert.match(line, /^Data: .+$/);
|
||||||
|
state = 'maybe-first-field';
|
||||||
|
break;
|
||||||
|
case 'maybe-first-field':
|
||||||
|
if (!/^\(First field\)/.test(line)) {
|
||||||
|
lines.unshift(line);
|
||||||
|
}
|
||||||
|
state = 'handle-start';
|
||||||
|
break;
|
||||||
|
case 'source-line':
|
||||||
|
assert.match(line, /CheckedUvLoopClose/);
|
||||||
|
state = 'assertion-failure';
|
||||||
|
break;
|
||||||
|
case 'assertion-failure':
|
||||||
|
assert.match(line, /Assertion failed:/);
|
||||||
|
state = 'done';
|
||||||
|
break;
|
||||||
|
case 'done':
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.strictEqual(state, 'done');
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
if (!common.enoughTestMem)
|
||||||
|
common.skip('Insufficient memory for async_hooks benchmark test');
|
||||||
|
|
||||||
|
const runBenchmark = require('../common/benchmark');
|
||||||
|
|
||||||
|
runBenchmark('async_hooks');
|
21
tests/node_compat/test/benchmark/test-benchmark-http.js
Normal file
21
tests/node_compat/test/benchmark/test-benchmark-http.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
if (!common.enoughTestMem)
|
||||||
|
common.skip('Insufficient memory for HTTP benchmark test');
|
||||||
|
|
||||||
|
// Because the http benchmarks use hardcoded ports, this should be in sequential
|
||||||
|
// rather than parallel to make sure it does not conflict with tests that choose
|
||||||
|
// random available ports.
|
||||||
|
|
||||||
|
const runBenchmark = require('../common/benchmark');
|
||||||
|
|
||||||
|
runBenchmark('http', { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
|
23
tests/node_compat/test/benchmark/test-benchmark-http2.js
Normal file
23
tests/node_compat/test/benchmark/test-benchmark-http2.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
if (!common.enoughTestMem)
|
||||||
|
common.skip('Insufficient memory for HTTP/2 benchmark test');
|
||||||
|
|
||||||
|
// Because the http benchmarks use hardcoded ports, this should be in sequential
|
||||||
|
// rather than parallel to make sure it does not conflict with tests that choose
|
||||||
|
// random available ports.
|
||||||
|
|
||||||
|
const runBenchmark = require('../common/benchmark');
|
||||||
|
|
||||||
|
runBenchmark('http2', { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
|
24
tests/node_compat/test/benchmark/test-benchmark-tls.js
Normal file
24
tests/node_compat/test/benchmark/test-benchmark-tls.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
if (!common.enoughTestMem)
|
||||||
|
common.skip('Insufficient memory for TLS benchmark test');
|
||||||
|
|
||||||
|
// Because the TLS benchmarks use hardcoded ports, this should be in sequential
|
||||||
|
// rather than parallel to make sure it does not conflict with tests that choose
|
||||||
|
// random available ports.
|
||||||
|
|
||||||
|
const runBenchmark = require('../common/benchmark');
|
||||||
|
|
||||||
|
runBenchmark('tls', { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
|
21
tests/node_compat/test/benchmark/test-benchmark-worker.js
Normal file
21
tests/node_compat/test/benchmark/test-benchmark-worker.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
if (!common.enoughTestMem)
|
||||||
|
common.skip('Insufficient memory for Worker benchmark test');
|
||||||
|
|
||||||
|
// Because the worker benchmarks can run on different threads,
|
||||||
|
// this should be in sequential rather than parallel to make sure
|
||||||
|
// it does not conflict with tests that choose random available ports.
|
||||||
|
|
||||||
|
const runBenchmark = require('../common/benchmark');
|
||||||
|
|
||||||
|
runBenchmark('worker', { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });
|
|
@ -0,0 +1,19 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { mustNotCall, mustCall } = require('../common');
|
||||||
|
|
||||||
|
Object.defineProperties(Object.prototype, {
|
||||||
|
then: {
|
||||||
|
set: mustNotCall('set %Object.prototype%.then'),
|
||||||
|
get: mustNotCall('get %Object.prototype%.then'),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
import('data:text/javascript,').then(mustCall());
|
|
@ -0,0 +1,29 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const tmpdir = require('../common/tmpdir');
|
||||||
|
|
||||||
|
const assert = require('node:assert');
|
||||||
|
const fs = require('node:fs/promises');
|
||||||
|
|
||||||
|
tmpdir.refresh();
|
||||||
|
const target = tmpdir.fileURL(`${Math.random()}.mjs`);
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
|
||||||
|
await assert.rejects(import(target), { code: 'ERR_MODULE_NOT_FOUND' });
|
||||||
|
|
||||||
|
await fs.writeFile(target, 'export default "actual target"\n');
|
||||||
|
|
||||||
|
const moduleRecord = await import(target);
|
||||||
|
|
||||||
|
await fs.rm(target);
|
||||||
|
|
||||||
|
assert.strictEqual(await import(target), moduleRecord);
|
||||||
|
})().then(common.mustCall());
|
|
@ -0,0 +1,17 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
require('../common');
|
||||||
|
|
||||||
|
const { cache } = require;
|
||||||
|
|
||||||
|
Object.keys(cache).forEach((key) => {
|
||||||
|
delete cache[key];
|
||||||
|
});
|
||||||
|
// Require the same module again triggers the crash
|
||||||
|
require('../common');
|
54
tests/node_compat/test/es-module/test-esm-windows.js
Normal file
54
tests/node_compat/test/es-module/test-esm-windows.js
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// This test ensures that JavaScript file that includes
|
||||||
|
// a reserved Windows word can be loaded as ESM module
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const tmpdir = require('../common/tmpdir');
|
||||||
|
const assert = require('assert');
|
||||||
|
const fs = require('fs').promises;
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
const imp = (file) => {
|
||||||
|
return import(path.relative(__dirname, file).replace(/\\/g, '/'));
|
||||||
|
};
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
tmpdir.refresh();
|
||||||
|
const rel = (file) => tmpdir.resolve(file);
|
||||||
|
|
||||||
|
{ // Load a single script
|
||||||
|
const file = rel('con.mjs');
|
||||||
|
await fs.writeFile(file, 'export default "ok"');
|
||||||
|
assert.strictEqual((await imp(file)).default, 'ok');
|
||||||
|
await fs.unlink(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // Load a module
|
||||||
|
const entry = rel('entry.mjs');
|
||||||
|
const nmDir = rel('node_modules');
|
||||||
|
const mDir = rel('node_modules/con');
|
||||||
|
const pkg = rel('node_modules/con/package.json');
|
||||||
|
const script = rel('node_modules/con/index.mjs');
|
||||||
|
|
||||||
|
await fs.writeFile(entry, 'export {default} from "con"');
|
||||||
|
await fs.mkdir(nmDir);
|
||||||
|
await fs.mkdir(mDir);
|
||||||
|
await fs.writeFile(pkg, '{"main":"index.mjs"}');
|
||||||
|
await fs.writeFile(script, 'export default "ok"');
|
||||||
|
|
||||||
|
assert.strictEqual((await imp(entry)).default, 'ok');
|
||||||
|
await fs.unlink(script);
|
||||||
|
await fs.unlink(pkg);
|
||||||
|
await fs.rmdir(mDir);
|
||||||
|
await fs.rmdir(nmDir);
|
||||||
|
await fs.unlink(entry);
|
||||||
|
}
|
||||||
|
})().then(common.mustCall());
|
|
@ -0,0 +1,41 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const { compileFunction } = require('node:vm');
|
||||||
|
|
||||||
|
const min = -2147483648;
|
||||||
|
const max = 2147483647;
|
||||||
|
|
||||||
|
compileFunction('', [], { lineOffset: min, columnOffset: min });
|
||||||
|
compileFunction('', [], { lineOffset: max, columnOffset: max });
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => {
|
||||||
|
compileFunction('', [], { lineOffset: min - 1, columnOffset: max });
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'ERR_OUT_OF_RANGE',
|
||||||
|
name: 'RangeError',
|
||||||
|
message: /The value of "options\.lineOffset" is out of range/,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => {
|
||||||
|
compileFunction('', [], { lineOffset: min, columnOffset: min - 1 });
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'ERR_OUT_OF_RANGE',
|
||||||
|
name: 'RangeError',
|
||||||
|
message: /The value of "options\.columnOffset" is out of range/,
|
||||||
|
}
|
||||||
|
);
|
60
tests/node_compat/test/message/eval_messages.js
Normal file
60
tests/node_compat/test/message/eval_messages.js
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
|
||||||
|
const spawn = require('child_process').spawn;
|
||||||
|
|
||||||
|
function run(cmd, strict, cb) {
|
||||||
|
const args = [];
|
||||||
|
if (strict) args.push('--use_strict');
|
||||||
|
args.push('-pe', cmd);
|
||||||
|
const child = spawn(process.execPath, args);
|
||||||
|
child.stdout.pipe(process.stdout);
|
||||||
|
child.stderr.pipe(process.stdout);
|
||||||
|
child.on('close', cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
const queue =
|
||||||
|
[ 'with(this){__filename}',
|
||||||
|
'42',
|
||||||
|
'throw new Error("hello")',
|
||||||
|
'var x = 100; y = x;',
|
||||||
|
'var ______________________________________________; throw 10' ];
|
||||||
|
|
||||||
|
function go() {
|
||||||
|
const c = queue.shift();
|
||||||
|
if (!c) return console.log('done');
|
||||||
|
run(c, false, function() {
|
||||||
|
run(c, true, go);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
go();
|
38
tests/node_compat/test/message/max_tick_depth.js
Normal file
38
tests/node_compat/test/message/max_tick_depth.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
require('../common');
|
||||||
|
|
||||||
|
process.maxTickDepth = 10;
|
||||||
|
let i = 20;
|
||||||
|
process.nextTick(function f() {
|
||||||
|
console.error(`tick ${i}`);
|
||||||
|
if (i-- > 0)
|
||||||
|
process.nextTick(f);
|
||||||
|
});
|
61
tests/node_compat/test/message/stdin_messages.js
Normal file
61
tests/node_compat/test/message/stdin_messages.js
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
|
||||||
|
const spawn = require('child_process').spawn;
|
||||||
|
|
||||||
|
function run(cmd, strict, cb) {
|
||||||
|
const args = [];
|
||||||
|
if (strict) args.push('--use_strict');
|
||||||
|
args.push('-p');
|
||||||
|
const child = spawn(process.execPath, args);
|
||||||
|
child.stdout.pipe(process.stdout);
|
||||||
|
child.stderr.pipe(process.stdout);
|
||||||
|
child.stdin.end(cmd);
|
||||||
|
child.on('close', cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
const queue =
|
||||||
|
[ 'with(this){__filename}',
|
||||||
|
'42',
|
||||||
|
'throw new Error("hello")',
|
||||||
|
'let x = 100; y = x;',
|
||||||
|
'let ______________________________________________; throw 10' ];
|
||||||
|
|
||||||
|
function go() {
|
||||||
|
const c = queue.shift();
|
||||||
|
if (!c) return console.log('done');
|
||||||
|
run(c, false, function() {
|
||||||
|
run(c, true, go);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
go();
|
19
tests/node_compat/test/message/util_inspect_error.js
Normal file
19
tests/node_compat/test/message/util_inspect_error.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
const util = require('util');
|
||||||
|
|
||||||
|
const err = new Error('foo\nbar');
|
||||||
|
|
||||||
|
console.log(util.inspect({ err, nested: { err } }, { compact: true }));
|
||||||
|
console.log(util.inspect({ err, nested: { err } }, { compact: false }));
|
||||||
|
|
||||||
|
err.foo = 'bar';
|
||||||
|
console.log(util.inspect(err, { compact: true, breakLength: 5 }));
|
|
@ -0,0 +1,22 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
require('../common');
|
||||||
|
|
||||||
|
// This test ensures Math functions don't fail with an "illegal instruction"
|
||||||
|
// error on ARM devices (primarily on the Raspberry Pi 1)
|
||||||
|
// See https://github.com/nodejs/node/issues/1376
|
||||||
|
// and https://code.google.com/p/v8/issues/detail?id=4019
|
||||||
|
|
||||||
|
// Iterate over all Math functions
|
||||||
|
Object.getOwnPropertyNames(Math).forEach((functionName) => {
|
||||||
|
if (!/[A-Z]/.test(functionName)) {
|
||||||
|
// The function names don't have capital letters.
|
||||||
|
Math[functionName](-0.5);
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,18 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
const { AsyncResource } = require('async_hooks');
|
||||||
|
|
||||||
|
try {
|
||||||
|
new AsyncResource('foo').runInAsyncScope(() => { throw new Error('bar'); });
|
||||||
|
} catch {
|
||||||
|
// Continue regardless of error.
|
||||||
|
}
|
||||||
|
// Should abort (fail the case) if async id is not matching.
|
|
@ -0,0 +1,24 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Test that passing thisArg to runInAsyncScope() works.
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const { AsyncResource } = require('async_hooks');
|
||||||
|
|
||||||
|
const thisArg = {};
|
||||||
|
|
||||||
|
const res = new AsyncResource('fhqwhgads');
|
||||||
|
|
||||||
|
function callback() {
|
||||||
|
assert.strictEqual(this, thisArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
res.runInAsyncScope(common.mustCall(callback), thisArg);
|
|
@ -0,0 +1,24 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const { AsyncLocalStorage } = require('async_hooks');
|
||||||
|
|
||||||
|
[1, false, '', {}, []].forEach((i) => {
|
||||||
|
assert.throws(() => AsyncLocalStorage.bind(i), {
|
||||||
|
code: 'ERR_INVALID_ARG_TYPE'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const fn = common.mustCall(AsyncLocalStorage.bind(() => 123));
|
||||||
|
assert.strictEqual(fn(), 123);
|
||||||
|
|
||||||
|
const fn2 = AsyncLocalStorage.bind(common.mustCall((arg) => assert.strictEqual(arg, 'test')));
|
||||||
|
fn2('test');
|
|
@ -0,0 +1,42 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const vm = require('vm');
|
||||||
|
const { AsyncLocalStorage } = require('async_hooks');
|
||||||
|
|
||||||
|
// Regression test for https://github.com/nodejs/node/issues/38781
|
||||||
|
|
||||||
|
const context = vm.createContext({
|
||||||
|
AsyncLocalStorage,
|
||||||
|
assert
|
||||||
|
});
|
||||||
|
|
||||||
|
vm.runInContext(`
|
||||||
|
const storage = new AsyncLocalStorage()
|
||||||
|
async function test() {
|
||||||
|
return storage.run({ test: 'vm' }, async () => {
|
||||||
|
assert.strictEqual(storage.getStore().test, 'vm');
|
||||||
|
await 42;
|
||||||
|
assert.strictEqual(storage.getStore().test, 'vm');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
test()
|
||||||
|
`, context);
|
||||||
|
|
||||||
|
const storage = new AsyncLocalStorage();
|
||||||
|
async function test() {
|
||||||
|
return storage.run({ test: 'main context' }, async () => {
|
||||||
|
assert.strictEqual(storage.getStore().test, 'main context');
|
||||||
|
await 42;
|
||||||
|
assert.strictEqual(storage.getStore().test, 'main context');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
test();
|
|
@ -0,0 +1,22 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const { AsyncLocalStorage } = require('async_hooks');
|
||||||
|
|
||||||
|
// Regression test for: https://github.com/nodejs/node/issues/34556
|
||||||
|
|
||||||
|
const als = new AsyncLocalStorage();
|
||||||
|
|
||||||
|
const done = common.mustCall();
|
||||||
|
|
||||||
|
function run(count) {
|
||||||
|
if (count !== 0) return als.run({}, run, --count);
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
run(1000);
|
|
@ -0,0 +1,72 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const Countdown = require('../common/countdown');
|
||||||
|
const assert = require('assert');
|
||||||
|
const { AsyncLocalStorage } = require('async_hooks');
|
||||||
|
const http = require('http');
|
||||||
|
const cls = new AsyncLocalStorage();
|
||||||
|
const NUM_CLIENTS = 10;
|
||||||
|
|
||||||
|
// Run multiple clients that receive data from a server
|
||||||
|
// in multiple chunks, in a single non-closure function.
|
||||||
|
// Use the AsyncLocalStorage (ALS) APIs to maintain the context
|
||||||
|
// and data download. Make sure that individual clients
|
||||||
|
// receive their respective data, with no conflicts.
|
||||||
|
|
||||||
|
// Set up a server that sends large buffers of data, filled
|
||||||
|
// with cardinal numbers, increasing per request
|
||||||
|
let index = 0;
|
||||||
|
const server = http.createServer((q, r) => {
|
||||||
|
// Send a large chunk as response, otherwise the data
|
||||||
|
// may be sent in a single chunk, and the callback in the
|
||||||
|
// client may be called only once, defeating the purpose of test
|
||||||
|
r.end((index++ % 10).toString().repeat(1024 * 1024));
|
||||||
|
});
|
||||||
|
|
||||||
|
const countdown = new Countdown(NUM_CLIENTS, () => {
|
||||||
|
server.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
server.listen(0, common.mustCall(() => {
|
||||||
|
for (let i = 0; i < NUM_CLIENTS; i++) {
|
||||||
|
cls.run(new Map(), common.mustCall(() => {
|
||||||
|
const options = { port: server.address().port };
|
||||||
|
const req = http.get(options, common.mustCall((res) => {
|
||||||
|
const store = cls.getStore();
|
||||||
|
store.set('data', '');
|
||||||
|
|
||||||
|
// Make ondata and onend non-closure
|
||||||
|
// functions and fully dependent on ALS
|
||||||
|
res.setEncoding('utf8');
|
||||||
|
res.on('data', ondata);
|
||||||
|
res.on('end', common.mustCall(onend));
|
||||||
|
}));
|
||||||
|
req.end();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Accumulate the current data chunk with the store data
|
||||||
|
function ondata(d) {
|
||||||
|
const store = cls.getStore();
|
||||||
|
assert.notStrictEqual(store, undefined);
|
||||||
|
let chunk = store.get('data');
|
||||||
|
chunk += d;
|
||||||
|
store.set('data', chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the store data, and test for homogeneity
|
||||||
|
function onend() {
|
||||||
|
const store = cls.getStore();
|
||||||
|
assert.notStrictEqual(store, undefined);
|
||||||
|
const data = store.get('data');
|
||||||
|
assert.strictEqual(data, data[0].repeat(data.length));
|
||||||
|
countdown.dec();
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const { strictEqual } = require('assert');
|
||||||
|
const { AsyncLocalStorage } = require('async_hooks');
|
||||||
|
|
||||||
|
const asyncLocalStorage = new AsyncLocalStorage();
|
||||||
|
const runInAsyncScope =
|
||||||
|
asyncLocalStorage.run(123, common.mustCall(() => AsyncLocalStorage.snapshot()));
|
||||||
|
const result =
|
||||||
|
asyncLocalStorage.run(321, common.mustCall(() => {
|
||||||
|
return runInAsyncScope(() => {
|
||||||
|
return asyncLocalStorage.getStore();
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
strictEqual(result, 123);
|
14
tests/node_compat/test/parallel/test-atomics-wake.js
Normal file
14
tests/node_compat/test/parallel/test-atomics-wake.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
// https://github.com/nodejs/node/issues/21219
|
||||||
|
assert.strictEqual(Atomics.wake, undefined);
|
|
@ -0,0 +1,34 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const { mustNotCall } = require('../common');
|
||||||
|
|
||||||
|
process.on('beforeExit', mustNotCall('exit should not allow this to occur'));
|
||||||
|
|
||||||
|
process.exit();
|
|
@ -0,0 +1,31 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Flags: --no-warnings
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const { Blob, kMaxLength } = require('buffer');
|
||||||
|
|
||||||
|
if (common.isFreeBSD)
|
||||||
|
common.skip('Oversized buffer make the FreeBSD CI runner crash');
|
||||||
|
|
||||||
|
try {
|
||||||
|
new Blob([new Uint8Array(kMaxLength), [1]]);
|
||||||
|
} catch (e) {
|
||||||
|
if (
|
||||||
|
e.message === 'Array buffer allocation failed' ||
|
||||||
|
e.message === `Invalid typed array length: ${kMaxLength}`
|
||||||
|
) {
|
||||||
|
common.skip(
|
||||||
|
'Insufficient memory on this platform for oversized buffer test.'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
assert.strictEqual(e.code, 'ERR_BUFFER_TOO_LARGE');
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const sab = new SharedArrayBuffer(24);
|
||||||
|
const arr1 = new Uint16Array(sab);
|
||||||
|
const arr2 = new Uint16Array(12);
|
||||||
|
arr2[0] = 5000;
|
||||||
|
arr1[0] = 5000;
|
||||||
|
arr1[1] = 4000;
|
||||||
|
arr2[1] = 4000;
|
||||||
|
|
||||||
|
const arr_buf = Buffer.from(arr1.buffer);
|
||||||
|
const ar_buf = Buffer.from(arr2.buffer);
|
||||||
|
|
||||||
|
assert.deepStrictEqual(arr_buf, ar_buf);
|
||||||
|
|
||||||
|
arr1[1] = 6000;
|
||||||
|
arr2[1] = 6000;
|
||||||
|
|
||||||
|
assert.deepStrictEqual(arr_buf, ar_buf);
|
||||||
|
|
||||||
|
// Checks for calling Buffer.byteLength on a SharedArrayBuffer.
|
||||||
|
assert.strictEqual(Buffer.byteLength(sab), sab.byteLength);
|
||||||
|
|
||||||
|
Buffer.from({ buffer: sab }); // Should not throw.
|
115
tests/node_compat/test/parallel/test-buffer-write.js
Normal file
115
tests/node_compat/test/parallel/test-buffer-write.js
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
[-1, 10].forEach((offset) => {
|
||||||
|
assert.throws(
|
||||||
|
() => Buffer.alloc(9).write('foo', offset),
|
||||||
|
{
|
||||||
|
code: 'ERR_OUT_OF_RANGE',
|
||||||
|
name: 'RangeError',
|
||||||
|
message: 'The value of "offset" is out of range. ' +
|
||||||
|
`It must be >= 0 && <= 9. Received ${offset}`
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const resultMap = new Map([
|
||||||
|
['utf8', Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])],
|
||||||
|
['ucs2', Buffer.from([102, 0, 111, 0, 111, 0, 0, 0, 0])],
|
||||||
|
['ascii', Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])],
|
||||||
|
['latin1', Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])],
|
||||||
|
['binary', Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])],
|
||||||
|
['utf16le', Buffer.from([102, 0, 111, 0, 111, 0, 0, 0, 0])],
|
||||||
|
['base64', Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])],
|
||||||
|
['base64url', Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])],
|
||||||
|
['hex', Buffer.from([102, 111, 111, 0, 0, 0, 0, 0, 0])],
|
||||||
|
]);
|
||||||
|
|
||||||
|
// utf8, ucs2, ascii, latin1, utf16le
|
||||||
|
const encodings = ['utf8', 'utf-8', 'ucs2', 'ucs-2', 'ascii', 'latin1',
|
||||||
|
'binary', 'utf16le', 'utf-16le'];
|
||||||
|
|
||||||
|
encodings
|
||||||
|
.reduce((es, e) => es.concat(e, e.toUpperCase()), [])
|
||||||
|
.forEach((encoding) => {
|
||||||
|
const buf = Buffer.alloc(9);
|
||||||
|
const len = Buffer.byteLength('foo', encoding);
|
||||||
|
assert.strictEqual(buf.write('foo', 0, len, encoding), len);
|
||||||
|
|
||||||
|
if (encoding.includes('-'))
|
||||||
|
encoding = encoding.replace('-', '');
|
||||||
|
|
||||||
|
assert.deepStrictEqual(buf, resultMap.get(encoding.toLowerCase()));
|
||||||
|
});
|
||||||
|
|
||||||
|
// base64
|
||||||
|
['base64', 'BASE64', 'base64url', 'BASE64URL'].forEach((encoding) => {
|
||||||
|
const buf = Buffer.alloc(9);
|
||||||
|
const len = Buffer.byteLength('Zm9v', encoding);
|
||||||
|
|
||||||
|
assert.strictEqual(buf.write('Zm9v', 0, len, encoding), len);
|
||||||
|
assert.deepStrictEqual(buf, resultMap.get(encoding.toLowerCase()));
|
||||||
|
});
|
||||||
|
|
||||||
|
// hex
|
||||||
|
['hex', 'HEX'].forEach((encoding) => {
|
||||||
|
const buf = Buffer.alloc(9);
|
||||||
|
const len = Buffer.byteLength('666f6f', encoding);
|
||||||
|
|
||||||
|
assert.strictEqual(buf.write('666f6f', 0, len, encoding), len);
|
||||||
|
assert.deepStrictEqual(buf, resultMap.get(encoding.toLowerCase()));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Invalid encodings
|
||||||
|
for (let i = 1; i < 10; i++) {
|
||||||
|
const encoding = String(i).repeat(i);
|
||||||
|
const error = common.expectsError({
|
||||||
|
code: 'ERR_UNKNOWN_ENCODING',
|
||||||
|
name: 'TypeError',
|
||||||
|
message: `Unknown encoding: ${encoding}`
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.ok(!Buffer.isEncoding(encoding));
|
||||||
|
assert.throws(() => Buffer.alloc(9).write('foo', encoding), error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// UCS-2 overflow CVE-2018-12115
|
||||||
|
for (let i = 1; i < 4; i++) {
|
||||||
|
// Allocate two Buffers sequentially off the pool. Run more than once in case
|
||||||
|
// we hit the end of the pool and don't get sequential allocations
|
||||||
|
const x = Buffer.allocUnsafe(4).fill(0);
|
||||||
|
const y = Buffer.allocUnsafe(4).fill(1);
|
||||||
|
// Should not write anything, pos 3 doesn't have enough room for a 16-bit char
|
||||||
|
assert.strictEqual(x.write('ыыыыыы', 3, 'ucs2'), 0);
|
||||||
|
// CVE-2018-12115 experienced via buffer overrun to next block in the pool
|
||||||
|
assert.strictEqual(Buffer.compare(y, Buffer.alloc(4, 1)), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should not write any data when there is no space for 16-bit chars
|
||||||
|
const z = Buffer.alloc(4, 0);
|
||||||
|
assert.strictEqual(z.write('\u0001', 3, 'ucs2'), 0);
|
||||||
|
assert.strictEqual(Buffer.compare(z, Buffer.alloc(4, 0)), 0);
|
||||||
|
// Make sure longer strings are written up to the buffer end.
|
||||||
|
assert.strictEqual(z.write('abcd', 2), 2);
|
||||||
|
assert.deepStrictEqual([...z], [0, 0, 0x61, 0x62]);
|
||||||
|
|
||||||
|
// Large overrun could corrupt the process
|
||||||
|
assert.strictEqual(Buffer.alloc(4)
|
||||||
|
.write('ыыыыыы'.repeat(100), 3, 'utf16le'), 0);
|
||||||
|
|
||||||
|
{
|
||||||
|
// .write() does not affect the byte after the written-to slice of the Buffer.
|
||||||
|
// Refs: https://github.com/nodejs/node/issues/26422
|
||||||
|
const buf = Buffer.alloc(8);
|
||||||
|
assert.strictEqual(buf.write('ыы', 1, 'utf16le'), 4);
|
||||||
|
assert.deepStrictEqual([...buf], [0, 0x4b, 0x04, 0x4b, 0x04, 0, 0, 0]);
|
||||||
|
}
|
34
tests/node_compat/test/parallel/test-child-process-fork3.js
Normal file
34
tests/node_compat/test/parallel/test-child-process-fork3.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
require('../common');
|
||||||
|
const child_process = require('child_process');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
|
child_process.fork(fixtures.path('empty.js')); // should not hang
|
|
@ -0,0 +1,36 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const cp = require('child_process');
|
||||||
|
|
||||||
|
function fail(proc, args) {
|
||||||
|
assert.throws(() => {
|
||||||
|
proc.send.apply(proc, args);
|
||||||
|
}, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' });
|
||||||
|
}
|
||||||
|
|
||||||
|
let target = process;
|
||||||
|
|
||||||
|
if (process.argv[2] !== 'child') {
|
||||||
|
target = cp.fork(__filename, ['child']);
|
||||||
|
target.on('exit', common.mustCall((code, signal) => {
|
||||||
|
assert.strictEqual(code, 0);
|
||||||
|
assert.strictEqual(signal, null);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
fail(target, ['msg', null, null]);
|
||||||
|
fail(target, ['msg', null, '']);
|
||||||
|
fail(target, ['msg', null, 'foo']);
|
||||||
|
fail(target, ['msg', null, 0]);
|
||||||
|
fail(target, ['msg', null, NaN]);
|
||||||
|
fail(target, ['msg', null, 1]);
|
||||||
|
fail(target, ['msg', null, null, common.mustNotCall()]);
|
|
@ -0,0 +1,47 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const spawn = require('child_process').spawn;
|
||||||
|
|
||||||
|
if (process.argv[2] === 'child') {
|
||||||
|
// Just reference stdin, it should start it
|
||||||
|
process.stdin; // eslint-disable-line no-unused-expressions
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const proc = spawn(process.execPath, [__filename, 'child'], {
|
||||||
|
stdio: ['ipc', 'inherit', 'inherit']
|
||||||
|
});
|
||||||
|
|
||||||
|
proc.on('exit', common.mustCall(function(code) {
|
||||||
|
assert.strictEqual(code, 0);
|
||||||
|
}));
|
|
@ -0,0 +1,86 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Test for "overlapped" stdio option. This test uses the "overlapped-checker"
|
||||||
|
// helper program which basically a specialized echo program.
|
||||||
|
//
|
||||||
|
// The test has two goals:
|
||||||
|
//
|
||||||
|
// - Verify that overlapped I/O works on windows. The test program will deadlock
|
||||||
|
// if stdin doesn't have the FILE_FLAG_OVERLAPPED flag set on startup (see
|
||||||
|
// test/overlapped-checker/main_win.c for more details).
|
||||||
|
// - Verify that "overlapped" stdio option works transparently as a pipe (on
|
||||||
|
// unix/windows)
|
||||||
|
//
|
||||||
|
// This is how the test works:
|
||||||
|
//
|
||||||
|
// - This script assumes only numeric strings are written to the test program
|
||||||
|
// stdout.
|
||||||
|
// - The test program will be spawned with "overlapped" set on stdin and "pipe"
|
||||||
|
// set on stdout/stderr and at startup writes a number to its stdout
|
||||||
|
// - When this script receives some data, it will parse the number, add 50 and
|
||||||
|
// write to the test program's stdin.
|
||||||
|
// - The test program will then echo the number back to us which will repeat the
|
||||||
|
// cycle until the number reaches 200, at which point we send the "exit"
|
||||||
|
// string, which causes the test program to exit.
|
||||||
|
// - Extra assertion: Every time the test program writes a string to its stdout,
|
||||||
|
// it will write the number of bytes written to stderr.
|
||||||
|
// - If overlapped I/O is not setup correctly, this test is going to hang.
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const path = require('path');
|
||||||
|
const child_process = require('child_process');
|
||||||
|
|
||||||
|
const exeExtension = process.platform === 'win32' ? '.exe' : '';
|
||||||
|
const exe = 'overlapped-checker' + exeExtension;
|
||||||
|
const exePath = path.join(path.dirname(process.execPath), exe);
|
||||||
|
|
||||||
|
if (!require('fs').existsSync(exePath)) {
|
||||||
|
common.skip(exe + ' binary is not available');
|
||||||
|
}
|
||||||
|
|
||||||
|
const child = child_process.spawn(exePath, [], {
|
||||||
|
stdio: ['overlapped', 'pipe', 'pipe']
|
||||||
|
});
|
||||||
|
|
||||||
|
child.stdin.setEncoding('utf8');
|
||||||
|
child.stdout.setEncoding('utf8');
|
||||||
|
child.stderr.setEncoding('utf8');
|
||||||
|
|
||||||
|
function writeNext(n) {
|
||||||
|
child.stdin.write((n + 50).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
child.stdout.on('data', (s) => {
|
||||||
|
const n = Number(s);
|
||||||
|
if (n >= 200) {
|
||||||
|
child.stdin.write('exit');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
writeNext(n);
|
||||||
|
});
|
||||||
|
|
||||||
|
let stderr = '';
|
||||||
|
child.stderr.on('data', (s) => {
|
||||||
|
stderr += s;
|
||||||
|
});
|
||||||
|
|
||||||
|
child.stderr.on('end', common.mustCall(() => {
|
||||||
|
// This is the sequence of numbers sent to us:
|
||||||
|
// - 0 (1 byte written)
|
||||||
|
// - 50 (2 bytes written)
|
||||||
|
// - 100 (3 bytes written)
|
||||||
|
// - 150 (3 bytes written)
|
||||||
|
// - 200 (3 bytes written)
|
||||||
|
assert.strictEqual(stderr, '12333');
|
||||||
|
}));
|
||||||
|
|
||||||
|
child.on('exit', common.mustCall((status) => {
|
||||||
|
// The test program will return the number of writes as status code.
|
||||||
|
assert.strictEqual(status, 0);
|
||||||
|
}));
|
|
@ -0,0 +1,20 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Test that http.ClientRequest,prototype.destroy() returns `this`.
|
||||||
|
require('../common');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const http = require('http');
|
||||||
|
const clientRequest = new http.ClientRequest({ createConnection: () => {} });
|
||||||
|
|
||||||
|
assert.strictEqual(clientRequest.destroyed, false);
|
||||||
|
assert.strictEqual(clientRequest.destroy(), clientRequest);
|
||||||
|
assert.strictEqual(clientRequest.destroyed, true);
|
||||||
|
assert.strictEqual(clientRequest.destroy(), clientRequest);
|
|
@ -0,0 +1,56 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
// Installing a custom uncaughtException handler should override the default
|
||||||
|
// one that the cluster module installs.
|
||||||
|
// https://github.com/joyent/node/issues/2556
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const cluster = require('cluster');
|
||||||
|
const fork = require('child_process').fork;
|
||||||
|
|
||||||
|
const MAGIC_EXIT_CODE = 42;
|
||||||
|
|
||||||
|
const isTestRunner = process.argv[2] !== 'child';
|
||||||
|
|
||||||
|
if (isTestRunner) {
|
||||||
|
const primary = fork(__filename, ['child']);
|
||||||
|
primary.on('exit', common.mustCall((code) => {
|
||||||
|
assert.strictEqual(code, MAGIC_EXIT_CODE);
|
||||||
|
}));
|
||||||
|
} else if (cluster.isPrimary) {
|
||||||
|
process.on('uncaughtException', common.mustCall(() => {
|
||||||
|
process.nextTick(() => process.exit(MAGIC_EXIT_CODE));
|
||||||
|
}));
|
||||||
|
cluster.fork();
|
||||||
|
throw new Error('kill primary');
|
||||||
|
} else { // worker
|
||||||
|
process.exit();
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Patch global.console before importing modules that may modify the console
|
||||||
|
// object.
|
||||||
|
|
||||||
|
const tmp = global.console;
|
||||||
|
global.console = 42;
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
// Originally the console had a getter. Test twice to verify it had no side
|
||||||
|
// effect.
|
||||||
|
assert.strictEqual(global.console, 42);
|
||||||
|
assert.strictEqual(global.console, 42);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => console.log('foo'),
|
||||||
|
{ name: 'TypeError' }
|
||||||
|
);
|
||||||
|
|
||||||
|
global.console = 1;
|
||||||
|
assert.strictEqual(global.console, 1);
|
||||||
|
assert.strictEqual(console, 1);
|
||||||
|
|
||||||
|
// Reset the console
|
||||||
|
global.console = tmp;
|
||||||
|
console.log('foo');
|
21
tests/node_compat/test/parallel/test-console-formatTime.js
Normal file
21
tests/node_compat/test/parallel/test-console-formatTime.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
// Flags: --expose-internals
|
||||||
|
require('../common');
|
||||||
|
const { formatTime } = require('internal/console/constructor');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
assert.strictEqual(formatTime(100.0096), '100.01ms');
|
||||||
|
assert.strictEqual(formatTime(100.0115), '100.011ms');
|
||||||
|
assert.strictEqual(formatTime(1500.04), '1.500s');
|
||||||
|
assert.strictEqual(formatTime(1000.056), '1.000s');
|
||||||
|
assert.strictEqual(formatTime(60300.3), '1:00.300 (m:ss.mmm)');
|
||||||
|
assert.strictEqual(formatTime(4000457.4), '1:06:40.457 (h:mm:ss.mmm)');
|
||||||
|
assert.strictEqual(formatTime(3601310.4), '1:00:01.310 (h:mm:ss.mmm)');
|
||||||
|
assert.strictEqual(formatTime(3213601017.6), '892:40:01.018 (h:mm:ss.mmm)');
|
|
@ -0,0 +1,41 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
function func() {}
|
||||||
|
let toStringCalled = false;
|
||||||
|
func.toString = function() {
|
||||||
|
toStringCalled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
require('util').inspect(func);
|
||||||
|
|
||||||
|
assert.ok(!toStringCalled);
|
13
tests/node_compat/test/parallel/test-console-self-assign.js
Normal file
13
tests/node_compat/test/parallel/test-console-self-assign.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
require('../common');
|
||||||
|
|
||||||
|
// Assigning to itself should not throw.
|
||||||
|
global.console = global.console; // eslint-disable-line no-self-assign
|
118
tests/node_compat/test/parallel/test-crypto-dh-errors.js
Normal file
118
tests/node_compat/test/parallel/test-crypto-dh-errors.js
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
// https://github.com/nodejs/node/issues/32738
|
||||||
|
// XXX(bnoordhuis) validateInt32() throwing ERR_OUT_OF_RANGE and RangeError
|
||||||
|
// instead of ERR_INVALID_ARG_TYPE and TypeError is questionable, IMO.
|
||||||
|
assert.throws(() => crypto.createDiffieHellman(13.37), {
|
||||||
|
code: 'ERR_OUT_OF_RANGE',
|
||||||
|
name: 'RangeError',
|
||||||
|
message: 'The value of "sizeOrKey" is out of range. ' +
|
||||||
|
'It must be an integer. Received 13.37',
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(() => crypto.createDiffieHellman('abcdef', 13.37), {
|
||||||
|
code: 'ERR_OUT_OF_RANGE',
|
||||||
|
name: 'RangeError',
|
||||||
|
message: 'The value of "generator" is out of range. ' +
|
||||||
|
'It must be an integer. Received 13.37',
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const bits of [-1, 0, 1]) {
|
||||||
|
if (common.hasOpenSSL3) {
|
||||||
|
assert.throws(() => crypto.createDiffieHellman(bits), {
|
||||||
|
code: 'ERR_OSSL_DH_MODULUS_TOO_SMALL',
|
||||||
|
name: 'Error',
|
||||||
|
message: /modulus too small/,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
assert.throws(() => crypto.createDiffieHellman(bits), {
|
||||||
|
code: 'ERR_OSSL_BN_BITS_TOO_SMALL',
|
||||||
|
name: 'Error',
|
||||||
|
message: /bits too small/,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const g of [-1, 1]) {
|
||||||
|
const ex = {
|
||||||
|
code: 'ERR_OSSL_DH_BAD_GENERATOR',
|
||||||
|
name: 'Error',
|
||||||
|
message: /bad generator/,
|
||||||
|
};
|
||||||
|
assert.throws(() => crypto.createDiffieHellman('abcdef', g), ex);
|
||||||
|
assert.throws(() => crypto.createDiffieHellman('abcdef', 'hex', g), ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const g of [Buffer.from([]),
|
||||||
|
Buffer.from([0]),
|
||||||
|
Buffer.from([1])]) {
|
||||||
|
const ex = {
|
||||||
|
code: 'ERR_OSSL_DH_BAD_GENERATOR',
|
||||||
|
name: 'Error',
|
||||||
|
message: /bad generator/,
|
||||||
|
};
|
||||||
|
assert.throws(() => crypto.createDiffieHellman('abcdef', g), ex);
|
||||||
|
assert.throws(() => crypto.createDiffieHellman('abcdef', 'hex', g), ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
[
|
||||||
|
[0x1, 0x2],
|
||||||
|
() => { },
|
||||||
|
/abc/,
|
||||||
|
{},
|
||||||
|
].forEach((input) => {
|
||||||
|
assert.throws(
|
||||||
|
() => crypto.createDiffieHellman(input),
|
||||||
|
{
|
||||||
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
|
name: 'TypeError',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Invalid test: curve argument is undefined
|
||||||
|
assert.throws(
|
||||||
|
() => crypto.createECDH(),
|
||||||
|
{
|
||||||
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
|
name: 'TypeError',
|
||||||
|
message: 'The "curve" argument must be of type string. ' +
|
||||||
|
'Received undefined'
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
function() {
|
||||||
|
crypto.getDiffieHellman('unknown-group');
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Error',
|
||||||
|
code: 'ERR_CRYPTO_UNKNOWN_DH_GROUP',
|
||||||
|
message: 'Unknown DH group'
|
||||||
|
},
|
||||||
|
'crypto.getDiffieHellman(\'unknown-group\') ' +
|
||||||
|
'failed to throw the expected error.'
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => crypto.createDiffieHellman('', true),
|
||||||
|
{
|
||||||
|
code: 'ERR_INVALID_ARG_TYPE'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
[true, Symbol(), {}, () => {}, []].forEach((generator) => assert.throws(
|
||||||
|
() => crypto.createDiffieHellman('', 'base64', generator),
|
||||||
|
{ code: 'ERR_INVALID_ARG_TYPE' }
|
||||||
|
));
|
50
tests/node_compat/test/parallel/test-crypto-dh-odd-key.js
Normal file
50
tests/node_compat/test/parallel/test-crypto-dh-odd-key.js
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
const odd = Buffer.alloc(39, 'A');
|
||||||
|
|
||||||
|
const c = crypto.createDiffieHellman(common.hasOpenSSL3 ? 1024 : 32);
|
||||||
|
c.setPrivateKey(odd);
|
||||||
|
c.generateKeys();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIPS requires a length of at least 1024
|
||||||
|
if (!common.hasFipsCrypto) {
|
||||||
|
test();
|
||||||
|
} else {
|
||||||
|
assert.throws(function() { test(); }, /key size too small/);
|
||||||
|
}
|
56
tests/node_compat/test/parallel/test-crypto-domain.js
Normal file
56
tests/node_compat/test/parallel/test-crypto-domain.js
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const domain = require('domain');
|
||||||
|
|
||||||
|
const test = (fn) => {
|
||||||
|
const ex = new Error('BAM');
|
||||||
|
const d = domain.create();
|
||||||
|
d.on('error', common.mustCall(function(err) {
|
||||||
|
assert.strictEqual(err, ex);
|
||||||
|
}));
|
||||||
|
const cb = common.mustCall(function() {
|
||||||
|
throw ex;
|
||||||
|
});
|
||||||
|
d.run(cb);
|
||||||
|
};
|
||||||
|
|
||||||
|
test(function(cb) {
|
||||||
|
crypto.pbkdf2('password', 'salt', 1, 8, cb);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(function(cb) {
|
||||||
|
crypto.randomBytes(32, cb);
|
||||||
|
});
|
72
tests/node_compat/test/parallel/test-crypto-from-binary.js
Normal file
72
tests/node_compat/test/parallel/test-crypto-from-binary.js
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
// This is the same as test/simple/test-crypto, but from before the shift
|
||||||
|
// to use buffers by default.
|
||||||
|
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
const EXTERN_APEX = 0xFBEE9;
|
||||||
|
|
||||||
|
// Manually controlled string for checking binary output
|
||||||
|
let ucs2_control = 'a\u0000';
|
||||||
|
|
||||||
|
// Grow the strings to proper length
|
||||||
|
while (ucs2_control.length <= EXTERN_APEX) {
|
||||||
|
ucs2_control = ucs2_control.repeat(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check resultant buffer and output string
|
||||||
|
const b = Buffer.from(ucs2_control + ucs2_control, 'ucs2');
|
||||||
|
|
||||||
|
//
|
||||||
|
// Test updating from birant data
|
||||||
|
//
|
||||||
|
{
|
||||||
|
const datum1 = b.slice(700000);
|
||||||
|
const hash1_converted = crypto.createHash('sha1')
|
||||||
|
.update(datum1.toString('base64'), 'base64')
|
||||||
|
.digest('hex');
|
||||||
|
const hash1_direct = crypto.createHash('sha1').update(datum1).digest('hex');
|
||||||
|
assert.strictEqual(hash1_direct, hash1_converted);
|
||||||
|
|
||||||
|
const datum2 = b;
|
||||||
|
const hash2_converted = crypto.createHash('sha1')
|
||||||
|
.update(datum2.toString('base64'), 'base64')
|
||||||
|
.digest('hex');
|
||||||
|
const hash2_direct = crypto.createHash('sha1').update(datum2).digest('hex');
|
||||||
|
assert.strictEqual(hash2_direct, hash2_converted);
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const {
|
||||||
|
generateKeyPair,
|
||||||
|
} = require('crypto');
|
||||||
|
|
||||||
|
// Test classic Diffie-Hellman key generation.
|
||||||
|
{
|
||||||
|
generateKeyPair('dh', {
|
||||||
|
primeLength: 512
|
||||||
|
}, common.mustSucceed((publicKey, privateKey) => {
|
||||||
|
assert.strictEqual(publicKey.type, 'public');
|
||||||
|
assert.strictEqual(publicKey.asymmetricKeyType, 'dh');
|
||||||
|
|
||||||
|
assert.strictEqual(privateKey.type, 'private');
|
||||||
|
assert.strictEqual(privateKey.asymmetricKeyType, 'dh');
|
||||||
|
}));
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const {
|
||||||
|
generateKeyPair,
|
||||||
|
} = require('crypto');
|
||||||
|
|
||||||
|
// This test makes sure deprecated and new options may be used
|
||||||
|
// simultaneously so long as they're identical values.
|
||||||
|
{
|
||||||
|
generateKeyPair('rsa-pss', {
|
||||||
|
modulusLength: 512,
|
||||||
|
saltLength: 16,
|
||||||
|
hash: 'sha256',
|
||||||
|
hashAlgorithm: 'sha256',
|
||||||
|
mgf1Hash: 'sha256',
|
||||||
|
mgf1HashAlgorithm: 'sha256'
|
||||||
|
}, common.mustSucceed((publicKey, privateKey) => {
|
||||||
|
assert.strictEqual(publicKey.type, 'public');
|
||||||
|
assert.strictEqual(publicKey.asymmetricKeyType, 'rsa-pss');
|
||||||
|
assert.deepStrictEqual(publicKey.asymmetricKeyDetails, {
|
||||||
|
modulusLength: 512,
|
||||||
|
publicExponent: 65537n,
|
||||||
|
hashAlgorithm: 'sha256',
|
||||||
|
mgf1HashAlgorithm: 'sha256',
|
||||||
|
saltLength: 16
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.strictEqual(privateKey.type, 'private');
|
||||||
|
assert.strictEqual(privateKey.asymmetricKeyType, 'rsa-pss');
|
||||||
|
assert.deepStrictEqual(privateKey.asymmetricKeyDetails, {
|
||||||
|
modulusLength: 512,
|
||||||
|
publicExponent: 65537n,
|
||||||
|
hashAlgorithm: 'sha256',
|
||||||
|
mgf1HashAlgorithm: 'sha256',
|
||||||
|
saltLength: 16
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const {
|
||||||
|
generateKeyPair,
|
||||||
|
} = require('crypto');
|
||||||
|
|
||||||
|
// Passing an empty passphrase string should not throw ERR_OSSL_CRYPTO_MALLOC_FAILURE even on OpenSSL 3.
|
||||||
|
// Regression test for https://github.com/nodejs/node/issues/41428.
|
||||||
|
generateKeyPair('rsa', {
|
||||||
|
modulusLength: 1024,
|
||||||
|
publicKeyEncoding: {
|
||||||
|
type: 'spki',
|
||||||
|
format: 'pem'
|
||||||
|
},
|
||||||
|
privateKeyEncoding: {
|
||||||
|
type: 'pkcs8',
|
||||||
|
format: 'pem',
|
||||||
|
cipher: 'aes-256-cbc',
|
||||||
|
passphrase: ''
|
||||||
|
}
|
||||||
|
}, common.mustSucceed((publicKey, privateKey) => {
|
||||||
|
assert.strictEqual(typeof publicKey, 'string');
|
||||||
|
assert.strictEqual(typeof privateKey, 'string');
|
||||||
|
}));
|
|
@ -0,0 +1,40 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const {
|
||||||
|
generateKeyPairSync,
|
||||||
|
} = require('crypto');
|
||||||
|
|
||||||
|
// Test sync key generation with key objects.
|
||||||
|
{
|
||||||
|
const { publicKey, privateKey } = generateKeyPairSync('rsa', {
|
||||||
|
modulusLength: 512
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.strictEqual(typeof publicKey, 'object');
|
||||||
|
assert.strictEqual(publicKey.type, 'public');
|
||||||
|
assert.strictEqual(publicKey.asymmetricKeyType, 'rsa');
|
||||||
|
assert.deepStrictEqual(publicKey.asymmetricKeyDetails, {
|
||||||
|
modulusLength: 512,
|
||||||
|
publicExponent: 65537n
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.strictEqual(typeof privateKey, 'object');
|
||||||
|
assert.strictEqual(privateKey.type, 'private');
|
||||||
|
assert.strictEqual(privateKey.asymmetricKeyType, 'rsa');
|
||||||
|
assert.deepStrictEqual(privateKey.asymmetricKeyDetails, {
|
||||||
|
modulusLength: 512,
|
||||||
|
publicExponent: 65537n
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const {
|
||||||
|
generateKeyPair,
|
||||||
|
generateKeyPairSync,
|
||||||
|
getCurves,
|
||||||
|
} = require('crypto');
|
||||||
|
|
||||||
|
// This test creates EC key pairs on curves without associated OIDs.
|
||||||
|
// Specifying a key encoding should not crash.
|
||||||
|
{
|
||||||
|
if (process.versions.openssl >= '1.1.1i') {
|
||||||
|
for (const namedCurve of ['Oakley-EC2N-3', 'Oakley-EC2N-4']) {
|
||||||
|
if (!getCurves().includes(namedCurve))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const expectedErrorCode =
|
||||||
|
common.hasOpenSSL3 ? 'ERR_OSSL_MISSING_OID' : 'ERR_OSSL_EC_MISSING_OID';
|
||||||
|
const params = {
|
||||||
|
namedCurve,
|
||||||
|
publicKeyEncoding: {
|
||||||
|
format: 'der',
|
||||||
|
type: 'spki'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(() => {
|
||||||
|
generateKeyPairSync('ec', params);
|
||||||
|
}, {
|
||||||
|
code: expectedErrorCode
|
||||||
|
});
|
||||||
|
|
||||||
|
generateKeyPair('ec', params, common.mustCall((err) => {
|
||||||
|
assert.strictEqual(err.code, expectedErrorCode);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const {
|
||||||
|
generateKeyPairSync,
|
||||||
|
} = require('crypto');
|
||||||
|
|
||||||
|
// Test sync key generation with key objects with a non-standard
|
||||||
|
// publicExponent
|
||||||
|
{
|
||||||
|
const { publicKey, privateKey } = generateKeyPairSync('rsa', {
|
||||||
|
publicExponent: 3,
|
||||||
|
modulusLength: 512
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.strictEqual(typeof publicKey, 'object');
|
||||||
|
assert.strictEqual(publicKey.type, 'public');
|
||||||
|
assert.strictEqual(publicKey.asymmetricKeyType, 'rsa');
|
||||||
|
assert.deepStrictEqual(publicKey.asymmetricKeyDetails, {
|
||||||
|
modulusLength: 512,
|
||||||
|
publicExponent: 3n
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.strictEqual(typeof privateKey, 'object');
|
||||||
|
assert.strictEqual(privateKey.type, 'private');
|
||||||
|
assert.strictEqual(privateKey.asymmetricKeyType, 'rsa');
|
||||||
|
assert.deepStrictEqual(privateKey.asymmetricKeyDetails, {
|
||||||
|
modulusLength: 512,
|
||||||
|
publicExponent: 3n
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const {
|
||||||
|
generateKeyPair,
|
||||||
|
} = require('crypto');
|
||||||
|
|
||||||
|
// RFC 8017, 9.1.: "Assuming that the mask generation function is based on a
|
||||||
|
// hash function, it is RECOMMENDED that the hash function be the same as the
|
||||||
|
// one that is applied to the message."
|
||||||
|
{
|
||||||
|
|
||||||
|
generateKeyPair('rsa-pss', {
|
||||||
|
modulusLength: 512,
|
||||||
|
hashAlgorithm: 'sha256',
|
||||||
|
saltLength: 16
|
||||||
|
}, common.mustSucceed((publicKey, privateKey) => {
|
||||||
|
const expectedKeyDetails = {
|
||||||
|
modulusLength: 512,
|
||||||
|
publicExponent: 65537n,
|
||||||
|
hashAlgorithm: 'sha256',
|
||||||
|
mgf1HashAlgorithm: 'sha256',
|
||||||
|
saltLength: 16
|
||||||
|
};
|
||||||
|
assert.deepStrictEqual(publicKey.asymmetricKeyDetails, expectedKeyDetails);
|
||||||
|
assert.deepStrictEqual(privateKey.asymmetricKeyDetails, expectedKeyDetails);
|
||||||
|
}));
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const {
|
||||||
|
generateKeyPair,
|
||||||
|
} = require('crypto');
|
||||||
|
|
||||||
|
// RFC 8017, A.2.3.: "For a given hashAlgorithm, the default value of
|
||||||
|
// saltLength is the octet length of the hash value."
|
||||||
|
{
|
||||||
|
generateKeyPair('rsa-pss', {
|
||||||
|
modulusLength: 512,
|
||||||
|
hashAlgorithm: 'sha512'
|
||||||
|
}, common.mustSucceed((publicKey, privateKey) => {
|
||||||
|
const expectedKeyDetails = {
|
||||||
|
modulusLength: 512,
|
||||||
|
publicExponent: 65537n,
|
||||||
|
hashAlgorithm: 'sha512',
|
||||||
|
mgf1HashAlgorithm: 'sha512',
|
||||||
|
saltLength: 64
|
||||||
|
};
|
||||||
|
assert.deepStrictEqual(publicKey.asymmetricKeyDetails, expectedKeyDetails);
|
||||||
|
assert.deepStrictEqual(privateKey.asymmetricKeyDetails, expectedKeyDetails);
|
||||||
|
}));
|
||||||
|
|
||||||
|
// It is still possible to explicitly set saltLength to 0.
|
||||||
|
generateKeyPair('rsa-pss', {
|
||||||
|
modulusLength: 512,
|
||||||
|
hashAlgorithm: 'sha512',
|
||||||
|
saltLength: 0
|
||||||
|
}, common.mustSucceed((publicKey, privateKey) => {
|
||||||
|
const expectedKeyDetails = {
|
||||||
|
modulusLength: 512,
|
||||||
|
publicExponent: 65537n,
|
||||||
|
hashAlgorithm: 'sha512',
|
||||||
|
mgf1HashAlgorithm: 'sha512',
|
||||||
|
saltLength: 0
|
||||||
|
};
|
||||||
|
assert.deepStrictEqual(publicKey.asymmetricKeyDetails, expectedKeyDetails);
|
||||||
|
assert.deepStrictEqual(privateKey.asymmetricKeyDetails, expectedKeyDetails);
|
||||||
|
}));
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
const Stream = require('stream');
|
||||||
|
|
||||||
|
const hasher1 = crypto.createHash('sha256');
|
||||||
|
const hasher2 = crypto.createHash('sha256');
|
||||||
|
|
||||||
|
// Calculate the expected result.
|
||||||
|
hasher1.write(Buffer.from('hello world'));
|
||||||
|
hasher1.end();
|
||||||
|
|
||||||
|
const expected = hasher1.read().toString('hex');
|
||||||
|
|
||||||
|
class OldStream extends Stream {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.readable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const stream = new OldStream();
|
||||||
|
|
||||||
|
stream.pipe(hasher2).on('finish', common.mustCall(function() {
|
||||||
|
const hash = hasher2.read().toString('hex');
|
||||||
|
assert.strictEqual(hash, expected);
|
||||||
|
}));
|
||||||
|
|
||||||
|
stream.emit('data', Buffer.from('hello'));
|
||||||
|
stream.emit('data', Buffer.from(' world'));
|
||||||
|
stream.emit('end');
|
45
tests/node_compat/test/parallel/test-crypto-no-algorithm.js
Normal file
45
tests/node_compat/test/parallel/test-crypto-no-algorithm.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
if (!common.hasOpenSSL3)
|
||||||
|
common.skip('this test requires OpenSSL 3.x');
|
||||||
|
|
||||||
|
const assert = require('node:assert/strict');
|
||||||
|
const crypto = require('node:crypto');
|
||||||
|
|
||||||
|
if (common.isMainThread) {
|
||||||
|
// TODO(richardlau): Decide if `crypto.setFips` should error if the
|
||||||
|
// provider named "fips" is not available.
|
||||||
|
crypto.setFips(1);
|
||||||
|
crypto.randomBytes(20, common.mustCall((err) => {
|
||||||
|
// crypto.randomBytes should either succeed or fail but not hang.
|
||||||
|
if (err) {
|
||||||
|
assert.match(err.message, /digital envelope routines::unsupported/);
|
||||||
|
const expected = /random number generator::unable to fetch drbg/;
|
||||||
|
assert(err.opensslErrorStack.some((msg) => expected.test(msg)),
|
||||||
|
`did not find ${expected} in ${err.opensslErrorStack}`);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Startup test. Should not hang.
|
||||||
|
const { path } = require('../common/fixtures');
|
||||||
|
const { spawnSync } = require('node:child_process');
|
||||||
|
const baseConf = path('openssl3-conf', 'base_only.cnf');
|
||||||
|
const cp = spawnSync(process.execPath,
|
||||||
|
[ `--openssl-config=${baseConf}`, '-p', '"hello"' ],
|
||||||
|
{ encoding: 'utf8' });
|
||||||
|
assert(common.nodeProcessAborted(cp.status, cp.signal),
|
||||||
|
`process did not abort, code:${cp.status} signal:${cp.signal}`);
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto) { common.skip('missing crypto'); }
|
||||||
|
const assert = require('assert');
|
||||||
|
const { generateKeyPair } = require('crypto');
|
||||||
|
|
||||||
|
if (common.isWindows) {
|
||||||
|
// Remove this conditional once the libuv change is in Node.js.
|
||||||
|
common.skip('crashing due to https://github.com/libuv/libuv/pull/2983');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regression test for a race condition: process.exit() might lead to OpenSSL
|
||||||
|
// cleaning up state from the exit() call via calling its destructor, but
|
||||||
|
// running OpenSSL operations on another thread might lead to them attempting
|
||||||
|
// to initialize OpenSSL, leading to a crash.
|
||||||
|
// This test crashed consistently on x64 Linux on Node v14.9.0.
|
||||||
|
|
||||||
|
generateKeyPair('rsa', {
|
||||||
|
modulusLength: 2048,
|
||||||
|
privateKeyEncoding: {
|
||||||
|
type: 'pkcs1',
|
||||||
|
format: 'pem'
|
||||||
|
}
|
||||||
|
}, (err/* , publicKey, privateKey */) => {
|
||||||
|
assert.ifError(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => process.exit(), common.platformTimeout(10));
|
|
@ -0,0 +1,67 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
const iv = Buffer.from('00000000000000000000000000000000', 'hex');
|
||||||
|
const key = Buffer.from('0123456789abcdef0123456789abcdef' +
|
||||||
|
'0123456789abcdef0123456789abcdef', 'hex');
|
||||||
|
|
||||||
|
function encrypt(val, pad) {
|
||||||
|
const c = crypto.createCipheriv('aes256', key, iv);
|
||||||
|
c.setAutoPadding(pad);
|
||||||
|
return c.update(val, 'utf8', 'latin1') + c.final('latin1');
|
||||||
|
}
|
||||||
|
|
||||||
|
function decrypt(val, pad) {
|
||||||
|
const c = crypto.createDecipheriv('aes256', key, iv);
|
||||||
|
c.setAutoPadding(pad);
|
||||||
|
return c.update(val, 'latin1', 'utf8') + c.final('utf8');
|
||||||
|
}
|
||||||
|
|
||||||
|
// echo 0123456789abcdef0123456789abcdef \
|
||||||
|
// | openssl enc -e -aes256 -nopad -K <key> -iv <iv> \
|
||||||
|
// | openssl enc -d -aes256 -nopad -K <key> -iv <iv>
|
||||||
|
let plaintext = '0123456789abcdef0123456789abcdef'; // Multiple of block size
|
||||||
|
let encrypted = encrypt(plaintext, false);
|
||||||
|
let decrypted = decrypt(encrypted, false);
|
||||||
|
assert.strictEqual(decrypted, plaintext);
|
||||||
|
|
||||||
|
// echo 0123456789abcdef0123456789abcde \
|
||||||
|
// | openssl enc -e -aes256 -K <key> -iv <iv> \
|
||||||
|
// | openssl enc -d -aes256 -K <key> -iv <iv>
|
||||||
|
plaintext = '0123456789abcdef0123456789abcde'; // not a multiple
|
||||||
|
encrypted = encrypt(plaintext, true);
|
||||||
|
decrypted = decrypt(encrypted, true);
|
||||||
|
assert.strictEqual(decrypted, plaintext);
|
|
@ -0,0 +1,107 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
// Tests for CVE-2022-21449
|
||||||
|
// https://neilmadden.blog/2022/04/19/psychic-signatures-in-java/
|
||||||
|
// Dubbed "Psychic Signatures", these signatures bypassed the ECDSA signature
|
||||||
|
// verification implementation in Java in 15, 16, 17, and 18. OpenSSL is not
|
||||||
|
// (and was not) vulnerable so these are a precaution.
|
||||||
|
|
||||||
|
const vectors = {
|
||||||
|
'ieee-p1363': [
|
||||||
|
Buffer.from('0000000000000000000000000000000000000000000000000000000000000000' +
|
||||||
|
'0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
|
||||||
|
Buffer.from('ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551' +
|
||||||
|
'ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551', 'hex'),
|
||||||
|
],
|
||||||
|
'der': [
|
||||||
|
Buffer.from('3046022100' +
|
||||||
|
'0000000000000000000000000000000000000000000000000000000000000000' +
|
||||||
|
'022100' +
|
||||||
|
'0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
|
||||||
|
Buffer.from('3046022100' +
|
||||||
|
'ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551' +
|
||||||
|
'022100' +
|
||||||
|
'ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551', 'hex'),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const keyPair = crypto.generateKeyPairSync('ec', {
|
||||||
|
namedCurve: 'P-256',
|
||||||
|
publicKeyEncoding: {
|
||||||
|
format: 'der',
|
||||||
|
type: 'spki'
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = Buffer.from('Hello!');
|
||||||
|
|
||||||
|
for (const [encoding, signatures] of Object.entries(vectors)) {
|
||||||
|
for (const signature of signatures) {
|
||||||
|
const key = {
|
||||||
|
key: keyPair.publicKey,
|
||||||
|
format: 'der',
|
||||||
|
type: 'spki',
|
||||||
|
dsaEncoding: encoding,
|
||||||
|
};
|
||||||
|
|
||||||
|
// one-shot sync
|
||||||
|
assert.strictEqual(
|
||||||
|
crypto.verify(
|
||||||
|
'sha256',
|
||||||
|
data,
|
||||||
|
key,
|
||||||
|
signature,
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
// one-shot async
|
||||||
|
crypto.verify(
|
||||||
|
'sha256',
|
||||||
|
data,
|
||||||
|
key,
|
||||||
|
signature,
|
||||||
|
common.mustSucceed((verified) => assert.strictEqual(verified, false)),
|
||||||
|
);
|
||||||
|
|
||||||
|
// stream
|
||||||
|
assert.strictEqual(
|
||||||
|
crypto.createVerify('sha256')
|
||||||
|
.update(data)
|
||||||
|
.verify(key, signature),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
// webcrypto
|
||||||
|
globalThis.crypto.subtle.importKey(
|
||||||
|
'spki',
|
||||||
|
keyPair.publicKey,
|
||||||
|
{ name: 'ECDSA', namedCurve: 'P-256' },
|
||||||
|
false,
|
||||||
|
['verify'],
|
||||||
|
).then((publicKey) => {
|
||||||
|
return globalThis.crypto.subtle.verify(
|
||||||
|
{ name: 'ECDSA', hash: 'SHA-256' },
|
||||||
|
publicKey,
|
||||||
|
signature,
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}).then(common.mustCall((verified) => {
|
||||||
|
assert.strictEqual(verified, false);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
// Test for https://github.com/nodejs/node/issues/40814
|
||||||
|
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
if (!common.hasOpenSSL3)
|
||||||
|
common.skip('only openssl3'); // https://github.com/nodejs/node/pull/42793#issuecomment-1107491901
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', {
|
||||||
|
modulusLength: 2048,
|
||||||
|
publicKeyEncoding: {
|
||||||
|
type: 'spki',
|
||||||
|
format: 'pem'
|
||||||
|
},
|
||||||
|
privateKeyEncoding: {
|
||||||
|
type: 'pkcs8',
|
||||||
|
format: 'pem',
|
||||||
|
cipher: 'aes-128-ecb',
|
||||||
|
passphrase: 'abcdef'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assert.notStrictEqual(privateKey.toString(), '');
|
||||||
|
|
||||||
|
const msg = 'The quick brown fox jumps over the lazy dog';
|
||||||
|
|
||||||
|
const encryptedString = crypto.privateEncrypt({
|
||||||
|
key: privateKey,
|
||||||
|
passphrase: 'abcdef'
|
||||||
|
}, Buffer.from(msg)).toString('base64');
|
||||||
|
const decryptedString = crypto.publicDecrypt(publicKey, Buffer.from(encryptedString, 'base64')).toString();
|
||||||
|
console.log(`Encrypted: ${encryptedString}`);
|
||||||
|
console.log(`Decrypted: ${decryptedString}`);
|
||||||
|
|
||||||
|
assert.notStrictEqual(encryptedString, '');
|
||||||
|
assert.strictEqual(decryptedString, msg);
|
|
@ -0,0 +1,25 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const { randomFillSync } = require('crypto');
|
||||||
|
const { notStrictEqual } = require('assert');
|
||||||
|
|
||||||
|
const ab = new ArrayBuffer(20);
|
||||||
|
const buf = Buffer.from(ab, 10);
|
||||||
|
|
||||||
|
const before = buf.toString('hex');
|
||||||
|
|
||||||
|
randomFillSync(buf);
|
||||||
|
|
||||||
|
const after = buf.toString('hex');
|
||||||
|
|
||||||
|
notStrictEqual(before, after);
|
266
tests/node_compat/test/parallel/test-crypto-scrypt.js
Normal file
266
tests/node_compat/test/parallel/test-crypto-scrypt.js
Normal file
|
@ -0,0 +1,266 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Flags: --expose-internals
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const crypto = require('crypto');
|
||||||
|
|
||||||
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
if (typeof internalBinding('crypto').ScryptJob !== 'function')
|
||||||
|
common.skip('no scrypt support');
|
||||||
|
|
||||||
|
const good = [
|
||||||
|
// Zero-length key is legal, functions as a parameter validation check.
|
||||||
|
{
|
||||||
|
pass: '',
|
||||||
|
salt: '',
|
||||||
|
keylen: 0,
|
||||||
|
N: 16,
|
||||||
|
p: 1,
|
||||||
|
r: 1,
|
||||||
|
expected: '',
|
||||||
|
},
|
||||||
|
// Test vectors from https://tools.ietf.org/html/rfc7914#page-13 that
|
||||||
|
// should pass. Note that the test vector with N=1048576 is omitted
|
||||||
|
// because it takes too long to complete and uses over 1 GiB of memory.
|
||||||
|
{
|
||||||
|
pass: '',
|
||||||
|
salt: '',
|
||||||
|
keylen: 64,
|
||||||
|
N: 16,
|
||||||
|
p: 1,
|
||||||
|
r: 1,
|
||||||
|
expected:
|
||||||
|
'77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442' +
|
||||||
|
'fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pass: 'password',
|
||||||
|
salt: 'NaCl',
|
||||||
|
keylen: 64,
|
||||||
|
N: 1024,
|
||||||
|
p: 16,
|
||||||
|
r: 8,
|
||||||
|
expected:
|
||||||
|
'fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b373162' +
|
||||||
|
'2eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pass: 'pleaseletmein',
|
||||||
|
salt: 'SodiumChloride',
|
||||||
|
keylen: 64,
|
||||||
|
N: 16384,
|
||||||
|
p: 1,
|
||||||
|
r: 8,
|
||||||
|
expected:
|
||||||
|
'7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2' +
|
||||||
|
'd5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pass: '',
|
||||||
|
salt: '',
|
||||||
|
keylen: 64,
|
||||||
|
cost: 16,
|
||||||
|
parallelization: 1,
|
||||||
|
blockSize: 1,
|
||||||
|
expected:
|
||||||
|
'77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442' +
|
||||||
|
'fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pass: 'password',
|
||||||
|
salt: 'NaCl',
|
||||||
|
keylen: 64,
|
||||||
|
cost: 1024,
|
||||||
|
parallelization: 16,
|
||||||
|
blockSize: 8,
|
||||||
|
expected:
|
||||||
|
'fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b373162' +
|
||||||
|
'2eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pass: 'pleaseletmein',
|
||||||
|
salt: 'SodiumChloride',
|
||||||
|
keylen: 64,
|
||||||
|
cost: 16384,
|
||||||
|
parallelization: 1,
|
||||||
|
blockSize: 8,
|
||||||
|
expected:
|
||||||
|
'7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2' +
|
||||||
|
'd5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// Test vectors that should fail.
|
||||||
|
const bad = [
|
||||||
|
{ N: 1, p: 1, r: 1 }, // N < 2
|
||||||
|
{ N: 3, p: 1, r: 1 }, // Not power of 2.
|
||||||
|
{ N: 1, cost: 1 }, // Both N and cost
|
||||||
|
{ p: 1, parallelization: 1 }, // Both p and parallelization
|
||||||
|
{ r: 1, blockSize: 1 }, // Both r and blocksize
|
||||||
|
];
|
||||||
|
|
||||||
|
// Test vectors where 128*N*r exceeds maxmem.
|
||||||
|
const toobig = [
|
||||||
|
{ N: 2 ** 16, p: 1, r: 1 }, // N >= 2**(r*16)
|
||||||
|
{ N: 2, p: 2 ** 30, r: 1 }, // p > (2**30-1)/r
|
||||||
|
{ N: 2 ** 20, p: 1, r: 8 },
|
||||||
|
{ N: 2 ** 10, p: 1, r: 8, maxmem: 2 ** 20 },
|
||||||
|
];
|
||||||
|
|
||||||
|
const badargs = [
|
||||||
|
{
|
||||||
|
args: [],
|
||||||
|
expected: { code: 'ERR_INVALID_ARG_TYPE', message: /"password"/ },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: [null],
|
||||||
|
expected: { code: 'ERR_INVALID_ARG_TYPE', message: /"password"/ },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: [''],
|
||||||
|
expected: { code: 'ERR_INVALID_ARG_TYPE', message: /"salt"/ },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: ['', null],
|
||||||
|
expected: { code: 'ERR_INVALID_ARG_TYPE', message: /"salt"/ },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: ['', ''],
|
||||||
|
expected: { code: 'ERR_INVALID_ARG_TYPE', message: /"keylen"/ },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: ['', '', null],
|
||||||
|
expected: { code: 'ERR_INVALID_ARG_TYPE', message: /"keylen"/ },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: ['', '', .42],
|
||||||
|
expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: ['', '', -42],
|
||||||
|
expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: ['', '', 2 ** 31],
|
||||||
|
expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: ['', '', 2147485780],
|
||||||
|
expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
args: ['', '', 2 ** 32],
|
||||||
|
expected: { code: 'ERR_OUT_OF_RANGE', message: /"keylen"/ },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const options of good) {
|
||||||
|
const { pass, salt, keylen, expected } = options;
|
||||||
|
const actual = crypto.scryptSync(pass, salt, keylen, options);
|
||||||
|
assert.strictEqual(actual.toString('hex'), expected);
|
||||||
|
crypto.scrypt(pass, salt, keylen, options, common.mustSucceed((actual) => {
|
||||||
|
assert.strictEqual(actual.toString('hex'), expected);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const options of bad) {
|
||||||
|
const expected = {
|
||||||
|
message: /Invalid scrypt param/,
|
||||||
|
};
|
||||||
|
assert.throws(() => crypto.scrypt('pass', 'salt', 1, options, () => {}),
|
||||||
|
expected);
|
||||||
|
assert.throws(() => crypto.scryptSync('pass', 'salt', 1, options),
|
||||||
|
expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const options of toobig) {
|
||||||
|
const expected = {
|
||||||
|
message: /Invalid scrypt param/
|
||||||
|
};
|
||||||
|
assert.throws(() => crypto.scrypt('pass', 'salt', 1, options, () => {}),
|
||||||
|
expected);
|
||||||
|
assert.throws(() => crypto.scryptSync('pass', 'salt', 1, options),
|
||||||
|
expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const defaults = { N: 16384, p: 1, r: 8 };
|
||||||
|
const expected = crypto.scryptSync('pass', 'salt', 1, defaults);
|
||||||
|
const actual = crypto.scryptSync('pass', 'salt', 1);
|
||||||
|
assert.deepStrictEqual(actual.toString('hex'), expected.toString('hex'));
|
||||||
|
crypto.scrypt('pass', 'salt', 1, common.mustSucceed((actual) => {
|
||||||
|
assert.deepStrictEqual(actual.toString('hex'), expected.toString('hex'));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const { args, expected } of badargs) {
|
||||||
|
assert.throws(() => crypto.scrypt(...args), expected);
|
||||||
|
assert.throws(() => crypto.scryptSync(...args), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const expected = { code: 'ERR_INVALID_ARG_TYPE' };
|
||||||
|
assert.throws(() => crypto.scrypt('', '', 42, null), expected);
|
||||||
|
assert.throws(() => crypto.scrypt('', '', 42, {}, null), expected);
|
||||||
|
assert.throws(() => crypto.scrypt('', '', 42, {}), expected);
|
||||||
|
assert.throws(() => crypto.scrypt('', '', 42, {}, {}), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Values for maxmem that do not fit in 32 bits but that are still safe
|
||||||
|
// integers should be allowed.
|
||||||
|
crypto.scrypt('', '', 4, { maxmem: 2 ** 52 },
|
||||||
|
common.mustSucceed((actual) => {
|
||||||
|
assert.strictEqual(actual.toString('hex'), 'd72c87d0');
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Values that exceed Number.isSafeInteger should not be allowed.
|
||||||
|
assert.throws(() => crypto.scryptSync('', '', 0, { maxmem: 2 ** 53 }), {
|
||||||
|
code: 'ERR_OUT_OF_RANGE'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Regression test for https://github.com/nodejs/node/issues/28836.
|
||||||
|
|
||||||
|
function testParameter(name, value) {
|
||||||
|
let accessCount = 0;
|
||||||
|
|
||||||
|
// Find out how often the value is accessed.
|
||||||
|
crypto.scryptSync('', '', 1, {
|
||||||
|
get [name]() {
|
||||||
|
accessCount++;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Try to crash the process on the last access.
|
||||||
|
assert.throws(() => {
|
||||||
|
crypto.scryptSync('', '', 1, {
|
||||||
|
get [name]() {
|
||||||
|
if (--accessCount === 0)
|
||||||
|
return '';
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, {
|
||||||
|
code: 'ERR_INVALID_ARG_TYPE'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[
|
||||||
|
['N', 16384], ['cost', 16384],
|
||||||
|
['r', 8], ['blockSize', 8],
|
||||||
|
['p', 1], ['parallelization', 1],
|
||||||
|
].forEach((arg) => testParameter(...arg));
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
if (!common.hasCrypto)
|
||||||
|
common.skip('missing crypto');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const { subtle } = globalThis.crypto;
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const k = await subtle.importKey(
|
||||||
|
'raw',
|
||||||
|
new Uint8Array(32),
|
||||||
|
{ name: 'AES-GCM' },
|
||||||
|
false,
|
||||||
|
[ 'encrypt', 'decrypt' ]);
|
||||||
|
assert(k instanceof CryptoKey);
|
||||||
|
|
||||||
|
const e = await subtle.encrypt({
|
||||||
|
name: 'AES-GCM',
|
||||||
|
iv: new Uint8Array(12),
|
||||||
|
}, k, new Uint8Array(0));
|
||||||
|
assert(e instanceof ArrayBuffer);
|
||||||
|
assert.deepStrictEqual(
|
||||||
|
Buffer.from(e),
|
||||||
|
Buffer.from([
|
||||||
|
0x53, 0x0f, 0x8a, 0xfb, 0xc7, 0x45, 0x36, 0xb9,
|
||||||
|
0xa9, 0x63, 0xb4, 0xf1, 0xc4, 0xcb, 0x73, 0x8b ]));
|
||||||
|
|
||||||
|
const v = await subtle.decrypt({
|
||||||
|
name: 'AES-GCM',
|
||||||
|
iv: new Uint8Array(12),
|
||||||
|
}, k, e);
|
||||||
|
assert(v instanceof ArrayBuffer);
|
||||||
|
assert.strictEqual(v.byteLength, 0);
|
||||||
|
})().then(common.mustCall()).catch((e) => {
|
||||||
|
assert.ifError(e);
|
||||||
|
});
|
88
tests/node_compat/test/parallel/test-dgram-address.js
Normal file
88
tests/node_compat/test/parallel/test-dgram-address.js
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
{
|
||||||
|
// IPv4 Test
|
||||||
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
socket.on('listening', common.mustCall(() => {
|
||||||
|
const address = socket.address();
|
||||||
|
|
||||||
|
assert.strictEqual(address.address, common.localhostIPv4);
|
||||||
|
assert.strictEqual(typeof address.port, 'number');
|
||||||
|
assert.ok(isFinite(address.port));
|
||||||
|
assert.ok(address.port > 0);
|
||||||
|
assert.strictEqual(address.family, 'IPv4');
|
||||||
|
socket.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
socket.on('error', (err) => {
|
||||||
|
socket.close();
|
||||||
|
assert.fail(`Unexpected error on udp4 socket. ${err.toString()}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.bind(0, common.localhostIPv4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (common.hasIPv6) {
|
||||||
|
// IPv6 Test
|
||||||
|
const socket = dgram.createSocket('udp6');
|
||||||
|
const localhost = '::1';
|
||||||
|
|
||||||
|
socket.on('listening', common.mustCall(() => {
|
||||||
|
const address = socket.address();
|
||||||
|
|
||||||
|
assert.strictEqual(address.address, localhost);
|
||||||
|
assert.strictEqual(typeof address.port, 'number');
|
||||||
|
assert.ok(isFinite(address.port));
|
||||||
|
assert.ok(address.port > 0);
|
||||||
|
assert.strictEqual(address.family, 'IPv6');
|
||||||
|
socket.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
socket.on('error', (err) => {
|
||||||
|
socket.close();
|
||||||
|
assert.fail(`Unexpected error on udp6 socket. ${err.toString()}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.bind(0, localhost);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Verify that address() throws if the socket is not bound.
|
||||||
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
assert.throws(() => {
|
||||||
|
socket.address();
|
||||||
|
}, /^Error: getsockname EBADF$/);
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
// Skip test in FreeBSD jails since 0.0.0.0 will resolve to default interface
|
||||||
|
if (common.inFreeBSDJail)
|
||||||
|
common.skip('In a FreeBSD jail');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
dgram.createSocket('udp4').bind(0, common.mustCall(function() {
|
||||||
|
assert.strictEqual(typeof this.address().port, 'number');
|
||||||
|
assert.ok(isFinite(this.address().port));
|
||||||
|
assert.ok(this.address().port > 0);
|
||||||
|
assert.strictEqual(this.address().address, '0.0.0.0');
|
||||||
|
this.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (!common.hasIPv6) {
|
||||||
|
common.printSkipMessage('udp6 part of test, because no IPv6 support');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dgram.createSocket('udp6').bind(0, common.mustCall(function() {
|
||||||
|
assert.strictEqual(typeof this.address().port, 'number');
|
||||||
|
assert.ok(isFinite(this.address().port));
|
||||||
|
assert.ok(this.address().port > 0);
|
||||||
|
let address = this.address().address;
|
||||||
|
if (address === '::ffff:0.0.0.0')
|
||||||
|
address = '::';
|
||||||
|
assert.strictEqual(address, '::');
|
||||||
|
this.close();
|
||||||
|
}));
|
|
@ -0,0 +1,34 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
// Regression test for https://github.com/nodejs/node/issues/30209
|
||||||
|
// No warning should be emitted when re-trying `.bind()` on UDP sockets
|
||||||
|
// repeatedly.
|
||||||
|
|
||||||
|
process.on('warning', common.mustNotCall());
|
||||||
|
|
||||||
|
const reservePortSocket = dgram.createSocket('udp4');
|
||||||
|
reservePortSocket.bind(() => {
|
||||||
|
const { port } = reservePortSocket.address();
|
||||||
|
|
||||||
|
const newSocket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
let errors = 0;
|
||||||
|
newSocket.on('error', common.mustCall(() => {
|
||||||
|
if (++errors < 20) {
|
||||||
|
newSocket.bind(port, common.mustNotCall());
|
||||||
|
} else {
|
||||||
|
newSocket.close();
|
||||||
|
reservePortSocket.close();
|
||||||
|
}
|
||||||
|
}, 20));
|
||||||
|
newSocket.bind(port, common.mustNotCall());
|
||||||
|
});
|
50
tests/node_compat/test/parallel/test-dgram-bind.js
Normal file
50
tests/node_compat/test/parallel/test-dgram-bind.js
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
socket.on('listening', common.mustCall(() => {
|
||||||
|
assert.throws(() => {
|
||||||
|
socket.bind();
|
||||||
|
}, {
|
||||||
|
code: 'ERR_SOCKET_ALREADY_BOUND',
|
||||||
|
name: 'Error',
|
||||||
|
message: /^Socket is already bound$/
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result = socket.bind(); // Should not throw.
|
||||||
|
|
||||||
|
assert.strictEqual(result, socket); // Should have returned itself.
|
46
tests/node_compat/test/parallel/test-dgram-bytes-length.js
Normal file
46
tests/node_compat/test/parallel/test-dgram-bytes-length.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const message = Buffer.from('Some bytes');
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
client.send(
|
||||||
|
message,
|
||||||
|
0,
|
||||||
|
message.length,
|
||||||
|
41234,
|
||||||
|
'localhost',
|
||||||
|
function(err, bytes) {
|
||||||
|
assert.strictEqual(bytes, message.length);
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
|
);
|
|
@ -0,0 +1,33 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
// Ensure that if a dgram socket is closed before the sendQueue is drained
|
||||||
|
// will not crash
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const buf = Buffer.alloc(1024, 42);
|
||||||
|
|
||||||
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
socket.on('listening', function() {
|
||||||
|
socket.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get a random port for send
|
||||||
|
const portGetter = dgram.createSocket('udp4')
|
||||||
|
.bind(0, 'localhost', common.mustCall(() => {
|
||||||
|
// Adds a listener to 'listening' to send the data when
|
||||||
|
// the socket is available
|
||||||
|
socket.send(buf, 0, buf.length,
|
||||||
|
portGetter.address().port,
|
||||||
|
portGetter.address().address);
|
||||||
|
|
||||||
|
portGetter.close();
|
||||||
|
}));
|
|
@ -0,0 +1,28 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const buf = Buffer.alloc(1024, 42);
|
||||||
|
|
||||||
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
// Get a random port for send
|
||||||
|
const portGetter = dgram.createSocket('udp4')
|
||||||
|
.bind(0, 'localhost', common.mustCall(() => {
|
||||||
|
socket.send(buf, 0, buf.length,
|
||||||
|
portGetter.address().port,
|
||||||
|
portGetter.address().address);
|
||||||
|
|
||||||
|
// If close callback is not function, ignore the argument.
|
||||||
|
socket.close('bad argument');
|
||||||
|
portGetter.close();
|
||||||
|
|
||||||
|
socket.on('close', common.mustCall());
|
||||||
|
}));
|
63
tests/node_compat/test/parallel/test-dgram-close.js
Normal file
63
tests/node_compat/test/parallel/test-dgram-close.js
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
// Flags: --expose-internals
|
||||||
|
'use strict';
|
||||||
|
// Ensure that if a dgram socket is closed before the DNS lookup completes, it
|
||||||
|
// won't crash.
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
const { kStateSymbol } = require('internal/dgram');
|
||||||
|
|
||||||
|
const buf = Buffer.alloc(1024, 42);
|
||||||
|
|
||||||
|
let socket = dgram.createSocket('udp4');
|
||||||
|
const { handle } = socket[kStateSymbol];
|
||||||
|
|
||||||
|
// Get a random port for send
|
||||||
|
const portGetter = dgram.createSocket('udp4')
|
||||||
|
.bind(0, 'localhost', common.mustCall(() => {
|
||||||
|
socket.send(buf, 0, buf.length,
|
||||||
|
portGetter.address().port,
|
||||||
|
portGetter.address().address);
|
||||||
|
|
||||||
|
assert.strictEqual(socket.close(common.mustCall()), socket);
|
||||||
|
socket.on('close', common.mustCall());
|
||||||
|
socket = null;
|
||||||
|
|
||||||
|
// Verify that accessing handle after closure doesn't throw
|
||||||
|
setImmediate(function() {
|
||||||
|
setImmediate(function() {
|
||||||
|
console.log('Handle fd is: ', handle.fd);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
portGetter.close();
|
||||||
|
}));
|
|
@ -0,0 +1,30 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const dgram = require('dgram');
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const buf = Buffer.allocUnsafe(256);
|
||||||
|
const offset = 20;
|
||||||
|
const len = buf.length - offset;
|
||||||
|
|
||||||
|
const messageSent = common.mustSucceed(function messageSent(bytes) {
|
||||||
|
assert.notStrictEqual(bytes, buf.length);
|
||||||
|
assert.strictEqual(bytes, buf.length - offset);
|
||||||
|
client.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
client.bind(0, common.mustCall(() => {
|
||||||
|
client.connect(client.address().port, common.mustCall(() => {
|
||||||
|
client.send(buf, offset, len, messageSent);
|
||||||
|
}));
|
||||||
|
}));
|
|
@ -0,0 +1,27 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const buf = Buffer.allocUnsafe(256);
|
||||||
|
|
||||||
|
const onMessage = common.mustSucceed((bytes) => {
|
||||||
|
assert.strictEqual(bytes, buf.length);
|
||||||
|
client.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
client.bind(0, common.mustCall(() => {
|
||||||
|
client.connect(client.address().port, common.mustCall(() => {
|
||||||
|
client.send(buf, onMessage);
|
||||||
|
}));
|
||||||
|
}));
|
|
@ -0,0 +1,36 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const messageSent = common.mustCall((err, bytes) => {
|
||||||
|
assert.strictEqual(bytes, buf1.length + buf2.length);
|
||||||
|
});
|
||||||
|
|
||||||
|
const buf1 = Buffer.alloc(256, 'x');
|
||||||
|
const buf2 = Buffer.alloc(256, 'y');
|
||||||
|
|
||||||
|
client.on('listening', common.mustCall(() => {
|
||||||
|
const port = client.address().port;
|
||||||
|
client.connect(port, common.mustCall(() => {
|
||||||
|
client.send([buf1, buf2], messageSent);
|
||||||
|
}));
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.on('message', common.mustCall((buf, info) => {
|
||||||
|
const expected = Buffer.concat([buf1, buf2]);
|
||||||
|
assert.ok(buf.equals(expected), 'message was received correctly');
|
||||||
|
client.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.bind(0);
|
|
@ -0,0 +1,55 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
const server = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const toSend = [Buffer.alloc(256, 'x'),
|
||||||
|
Buffer.alloc(256, 'y'),
|
||||||
|
Buffer.alloc(256, 'z'),
|
||||||
|
'hello'];
|
||||||
|
|
||||||
|
const received = [];
|
||||||
|
|
||||||
|
server.on('listening', common.mustCall(() => {
|
||||||
|
const port = server.address().port;
|
||||||
|
client.connect(port, (err) => {
|
||||||
|
assert.ifError(err);
|
||||||
|
client.send(toSend[0], 0, toSend[0].length);
|
||||||
|
client.send(toSend[1]);
|
||||||
|
client.send([toSend[2]]);
|
||||||
|
client.send(toSend[3], 0, toSend[3].length);
|
||||||
|
|
||||||
|
client.send(new Uint8Array(toSend[0]), 0, toSend[0].length);
|
||||||
|
client.send(new Uint8Array(toSend[1]));
|
||||||
|
client.send([new Uint8Array(toSend[2])]);
|
||||||
|
client.send(new Uint8Array(Buffer.from(toSend[3])),
|
||||||
|
0, toSend[3].length);
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
|
server.on('message', common.mustCall((buf, info) => {
|
||||||
|
received.push(buf.toString());
|
||||||
|
|
||||||
|
if (received.length === toSend.length * 2) {
|
||||||
|
// The replies may arrive out of order -> sort them before checking.
|
||||||
|
received.sort();
|
||||||
|
|
||||||
|
const expected = toSend.concat(toSend).map(String).sort();
|
||||||
|
assert.deepStrictEqual(received, expected);
|
||||||
|
client.close();
|
||||||
|
server.close();
|
||||||
|
}
|
||||||
|
}, toSend.length * 2));
|
||||||
|
|
||||||
|
server.bind(0);
|
|
@ -0,0 +1,29 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
client.on('message', common.mustCall((buf, info) => {
|
||||||
|
const expected = Buffer.alloc(0);
|
||||||
|
assert.ok(buf.equals(expected), `Expected empty message but got ${buf}`);
|
||||||
|
client.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.on('listening', common.mustCall(() => {
|
||||||
|
client.connect(client.address().port,
|
||||||
|
common.localhostIPv4,
|
||||||
|
common.mustCall(() => client.send([])));
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.bind(0);
|
|
@ -0,0 +1,27 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
client.bind(0, common.mustCall(function() {
|
||||||
|
const port = this.address().port;
|
||||||
|
client.connect(port, common.mustCall(() => {
|
||||||
|
const buf = Buffer.alloc(0);
|
||||||
|
client.send(buf, 0, 0, common.mustSucceed());
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.on('message', common.mustCall((buffer) => {
|
||||||
|
assert.strictEqual(buffer.length, 0);
|
||||||
|
client.close();
|
||||||
|
}));
|
||||||
|
}));
|
|
@ -0,0 +1,35 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
client.bind(0, common.mustCall(function() {
|
||||||
|
client.connect(client.address().port, common.mustCall(() => {
|
||||||
|
client.on('message', common.mustCall(callback));
|
||||||
|
const buf = Buffer.alloc(1);
|
||||||
|
|
||||||
|
const interval = setInterval(function() {
|
||||||
|
client.send(buf, 0, 0, common.mustCall(callback));
|
||||||
|
}, 10);
|
||||||
|
|
||||||
|
function callback(firstArg) {
|
||||||
|
// If client.send() callback, firstArg should be null.
|
||||||
|
// If client.on('message') listener, firstArg should be a 0-length buffer.
|
||||||
|
if (firstArg instanceof Buffer) {
|
||||||
|
assert.strictEqual(firstArg.length, 0);
|
||||||
|
clearInterval(interval);
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}));
|
|
@ -0,0 +1,36 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const onMessage = common.mustCall(common.mustSucceed((bytes) => {
|
||||||
|
assert.strictEqual(bytes, buf1.length + buf2.length);
|
||||||
|
}));
|
||||||
|
|
||||||
|
const buf1 = Buffer.alloc(256, 'x');
|
||||||
|
const buf2 = Buffer.alloc(256, 'y');
|
||||||
|
|
||||||
|
client.on('listening', common.mustCall(function() {
|
||||||
|
const toSend = [buf1, buf2];
|
||||||
|
client.connect(client.address().port, common.mustCall(() => {
|
||||||
|
client.send(toSend, onMessage);
|
||||||
|
}));
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.on('message', common.mustCall(function onMessage(buf, info) {
|
||||||
|
const expected = Buffer.concat([buf1, buf2]);
|
||||||
|
assert.ok(buf.equals(expected), 'message was received correctly');
|
||||||
|
client.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.bind(0);
|
|
@ -0,0 +1,24 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
const socket = dgram.createSocket('udp4');
|
||||||
|
const data = ['foo', 'bar', 'baz'];
|
||||||
|
|
||||||
|
socket.on('message', common.mustCall((msg, rinfo) => {
|
||||||
|
socket.close();
|
||||||
|
assert.deepStrictEqual(msg.toString(), data.join(''));
|
||||||
|
}));
|
||||||
|
|
||||||
|
socket.bind(0, () => {
|
||||||
|
socket.connect(socket.address().port, common.mustCall(() => {
|
||||||
|
socket.send(data);
|
||||||
|
}));
|
||||||
|
});
|
73
tests/node_compat/test/parallel/test-dgram-connect.js
Normal file
73
tests/node_compat/test/parallel/test-dgram-connect.js
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const PORT = 12345;
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
client.connect(PORT, common.mustCall(() => {
|
||||||
|
const remoteAddr = client.remoteAddress();
|
||||||
|
assert.strictEqual(remoteAddr.port, PORT);
|
||||||
|
assert.throws(() => {
|
||||||
|
client.connect(PORT, common.mustNotCall());
|
||||||
|
}, {
|
||||||
|
name: 'Error',
|
||||||
|
message: 'Already connected',
|
||||||
|
code: 'ERR_SOCKET_DGRAM_IS_CONNECTED'
|
||||||
|
});
|
||||||
|
|
||||||
|
client.disconnect();
|
||||||
|
assert.throws(() => {
|
||||||
|
client.disconnect();
|
||||||
|
}, {
|
||||||
|
name: 'Error',
|
||||||
|
message: 'Not connected',
|
||||||
|
code: 'ERR_SOCKET_DGRAM_NOT_CONNECTED'
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(() => {
|
||||||
|
client.remoteAddress();
|
||||||
|
}, {
|
||||||
|
name: 'Error',
|
||||||
|
message: 'Not connected',
|
||||||
|
code: 'ERR_SOCKET_DGRAM_NOT_CONNECTED'
|
||||||
|
});
|
||||||
|
|
||||||
|
client.once('connect', common.mustCall(() => client.close()));
|
||||||
|
client.connect(PORT);
|
||||||
|
}));
|
||||||
|
|
||||||
|
assert.throws(() => {
|
||||||
|
client.connect(PORT);
|
||||||
|
}, {
|
||||||
|
name: 'Error',
|
||||||
|
message: 'Already connected',
|
||||||
|
code: 'ERR_SOCKET_DGRAM_IS_CONNECTED'
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.throws(() => {
|
||||||
|
client.disconnect();
|
||||||
|
}, {
|
||||||
|
name: 'Error',
|
||||||
|
message: 'Not connected',
|
||||||
|
code: 'ERR_SOCKET_DGRAM_NOT_CONNECTED'
|
||||||
|
});
|
||||||
|
|
||||||
|
[ 0, null, 78960, undefined ].forEach((port) => {
|
||||||
|
assert.throws(() => {
|
||||||
|
client.connect(port);
|
||||||
|
}, {
|
||||||
|
name: 'RangeError',
|
||||||
|
message: /^Port should be > 0 and < 65536/,
|
||||||
|
code: 'ERR_SOCKET_BAD_PORT'
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,68 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
const invalidTypes = [
|
||||||
|
'test',
|
||||||
|
['udp4'],
|
||||||
|
new String('udp4'),
|
||||||
|
1,
|
||||||
|
{},
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
null,
|
||||||
|
undefined,
|
||||||
|
];
|
||||||
|
const validTypes = [
|
||||||
|
'udp4',
|
||||||
|
'udp6',
|
||||||
|
{ type: 'udp4' },
|
||||||
|
{ type: 'udp6' },
|
||||||
|
];
|
||||||
|
const errMessage = /^Bad socket type specified\. Valid types are: udp4, udp6$/;
|
||||||
|
|
||||||
|
// Error must be thrown with invalid types
|
||||||
|
invalidTypes.forEach((invalidType) => {
|
||||||
|
assert.throws(() => {
|
||||||
|
dgram.createSocket(invalidType);
|
||||||
|
}, {
|
||||||
|
code: 'ERR_SOCKET_BAD_TYPE',
|
||||||
|
name: 'TypeError',
|
||||||
|
message: errMessage
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Error must not be thrown with valid types
|
||||||
|
validTypes.forEach((validType) => {
|
||||||
|
const socket = dgram.createSocket(validType);
|
||||||
|
socket.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure buffer sizes can be set
|
||||||
|
{
|
||||||
|
const socket = dgram.createSocket({
|
||||||
|
type: 'udp4',
|
||||||
|
recvBufferSize: 10000,
|
||||||
|
sendBufferSize: 15000
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.bind(common.mustCall(() => {
|
||||||
|
// note: linux will double the buffer size
|
||||||
|
assert.ok(socket.getRecvBufferSize() === 10000 ||
|
||||||
|
socket.getRecvBufferSize() === 20000,
|
||||||
|
'SO_RCVBUF not 10000 or 20000, ' +
|
||||||
|
`was ${socket.getRecvBufferSize()}`);
|
||||||
|
assert.ok(socket.getSendBufferSize() === 15000 ||
|
||||||
|
socket.getSendBufferSize() === 30000,
|
||||||
|
'SO_SNDBUF not 15000 or 30000, ' +
|
||||||
|
`was ${socket.getRecvBufferSize()}`);
|
||||||
|
socket.close();
|
||||||
|
}));
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
// IPv4 Test
|
||||||
|
const socket_ipv4 = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
socket_ipv4.on('listening', common.mustNotCall());
|
||||||
|
|
||||||
|
socket_ipv4.on('error', common.mustCall(function(e) {
|
||||||
|
assert.strictEqual(e.port, undefined);
|
||||||
|
assert.strictEqual(e.message, 'bind EADDRNOTAVAIL 1.1.1.1');
|
||||||
|
assert.strictEqual(e.address, '1.1.1.1');
|
||||||
|
assert.strictEqual(e.code, 'EADDRNOTAVAIL');
|
||||||
|
socket_ipv4.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
socket_ipv4.bind(0, '1.1.1.1');
|
||||||
|
|
||||||
|
// IPv6 Test
|
||||||
|
const socket_ipv6 = dgram.createSocket('udp6');
|
||||||
|
|
||||||
|
socket_ipv6.on('listening', common.mustNotCall());
|
||||||
|
|
||||||
|
socket_ipv6.on('error', common.mustCall(function(e) {
|
||||||
|
// EAFNOSUPPORT or EPROTONOSUPPORT means IPv6 is disabled on this system.
|
||||||
|
const allowed = ['EADDRNOTAVAIL', 'EAFNOSUPPORT', 'EPROTONOSUPPORT'];
|
||||||
|
assert(allowed.includes(e.code), `'${e.code}' was not one of ${allowed}.`);
|
||||||
|
assert.strictEqual(e.port, undefined);
|
||||||
|
assert.strictEqual(e.message, `bind ${e.code} 111::1`);
|
||||||
|
assert.strictEqual(e.address, '111::1');
|
||||||
|
socket_ipv6.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
socket_ipv6.bind(0, '111::1');
|
53
tests/node_compat/test/parallel/test-dgram-implicit-bind.js
Normal file
53
tests/node_compat/test/parallel/test-dgram-implicit-bind.js
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const source = dgram.createSocket('udp4');
|
||||||
|
const target = dgram.createSocket('udp4');
|
||||||
|
let messages = 0;
|
||||||
|
|
||||||
|
target.on('message', common.mustCall(function(buf) {
|
||||||
|
if (buf.toString() === 'abc') ++messages;
|
||||||
|
if (buf.toString() === 'def') ++messages;
|
||||||
|
if (messages === 2) {
|
||||||
|
source.close();
|
||||||
|
target.close();
|
||||||
|
}
|
||||||
|
}, 2));
|
||||||
|
|
||||||
|
target.on('listening', common.mustCall(function() {
|
||||||
|
// Second .send() call should not throw a bind error.
|
||||||
|
const port = this.address().port;
|
||||||
|
source.send(Buffer.from('abc'), 0, 3, port, '127.0.0.1');
|
||||||
|
source.send(Buffer.from('def'), 0, 3, port, '127.0.0.1');
|
||||||
|
}));
|
||||||
|
|
||||||
|
target.bind(0);
|
|
@ -0,0 +1,52 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
require('../common');
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
socket.bind();
|
||||||
|
|
||||||
|
let fired = false;
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
socket.close();
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
socket.on('listening', common.mustCall(() => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
fired = true;
|
||||||
|
socket.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
socket.on('close', common.mustCall(() => {
|
||||||
|
assert(fired, 'listening should fire after bind');
|
||||||
|
}));
|
46
tests/node_compat/test/parallel/test-dgram-msgsize.js
Normal file
46
tests/node_compat/test/parallel/test-dgram-msgsize.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
// Send a too big datagram. The destination doesn't matter because it's
|
||||||
|
// not supposed to get sent out anyway.
|
||||||
|
const buf = Buffer.allocUnsafe(256 * 1024);
|
||||||
|
const sock = dgram.createSocket('udp4');
|
||||||
|
sock.send(buf, 0, buf.length, 12345, '127.0.0.1', common.mustCall(cb));
|
||||||
|
function cb(err) {
|
||||||
|
assert(err instanceof Error);
|
||||||
|
assert.strictEqual(err.code, 'EMSGSIZE');
|
||||||
|
assert.strictEqual(err.address, '127.0.0.1');
|
||||||
|
assert.strictEqual(err.port, 12345);
|
||||||
|
assert.strictEqual(err.message, 'send EMSGSIZE 127.0.0.1:12345');
|
||||||
|
sock.close();
|
||||||
|
}
|
52
tests/node_compat/test/parallel/test-dgram-oob-buffer.js
Normal file
52
tests/node_compat/test/parallel/test-dgram-oob-buffer.js
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
// Some operating systems report errors when an UDP message is sent to an
|
||||||
|
// unreachable host. This error can be reported by sendto() and even by
|
||||||
|
// recvfrom(). Node should not propagate this error to the user.
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const socket = dgram.createSocket('udp4');
|
||||||
|
const buf = Buffer.from([1, 2, 3, 4]);
|
||||||
|
const portGetter = dgram.createSocket('udp4')
|
||||||
|
.bind(0, 'localhost', common.mustCall(() => {
|
||||||
|
const { address, port } = portGetter.address();
|
||||||
|
portGetter.close(common.mustCall(() => {
|
||||||
|
socket.send(buf, 0, 0, port, address, common.mustNotCall());
|
||||||
|
socket.send(buf, 0, 4, port, address, common.mustNotCall());
|
||||||
|
socket.send(buf, 1, 3, port, address, common.mustNotCall());
|
||||||
|
socket.send(buf, 3, 1, port, address, common.mustNotCall());
|
||||||
|
// Since length of zero means nothing, don't error despite OOB.
|
||||||
|
socket.send(buf, 4, 0, port, address, common.mustNotCall());
|
||||||
|
|
||||||
|
socket.close();
|
||||||
|
}));
|
||||||
|
}));
|
26
tests/node_compat/test/parallel/test-dgram-recv-error.js
Normal file
26
tests/node_compat/test/parallel/test-dgram-recv-error.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Flags: --expose-internals
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
const { kStateSymbol } = require('internal/dgram');
|
||||||
|
const s = dgram.createSocket('udp4');
|
||||||
|
const { handle } = s[kStateSymbol];
|
||||||
|
|
||||||
|
s.on('error', common.mustCall((err) => {
|
||||||
|
s.close();
|
||||||
|
|
||||||
|
// Don't check the full error message, as the errno is not important here.
|
||||||
|
assert.match(String(err), /^Error: recvmsg/);
|
||||||
|
assert.strictEqual(err.syscall, 'recvmsg');
|
||||||
|
}));
|
||||||
|
|
||||||
|
s.on('message', common.mustNotCall('no message should be received.'));
|
||||||
|
s.bind(common.mustCall(() => handle.onmessage(-1, handle, null, null)));
|
42
tests/node_compat/test/parallel/test-dgram-ref.js
Normal file
42
tests/node_compat/test/parallel/test-dgram-ref.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
// Should not hang, see https://github.com/nodejs/node-v0.x-archive/issues/1282
|
||||||
|
dgram.createSocket('udp4');
|
||||||
|
dgram.createSocket('udp6');
|
||||||
|
|
||||||
|
{
|
||||||
|
// Test the case of ref()'ing a socket with no handle.
|
||||||
|
const s = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
s.close(common.mustCall(() => s.ref()));
|
||||||
|
}
|
162
tests/node_compat/test/parallel/test-dgram-send-bad-arguments.js
Normal file
162
tests/node_compat/test/parallel/test-dgram-send-bad-arguments.js
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const buf = Buffer.from('test');
|
||||||
|
const host = '127.0.0.1';
|
||||||
|
const sock = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
function checkArgs(connected) {
|
||||||
|
// First argument should be a buffer.
|
||||||
|
assert.throws(
|
||||||
|
() => { sock.send(); },
|
||||||
|
{
|
||||||
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
|
name: 'TypeError',
|
||||||
|
message: 'The "buffer" argument must be of type string or an instance ' +
|
||||||
|
'of Buffer, TypedArray, or DataView. Received undefined'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// send(buf, offset, length, port, host)
|
||||||
|
if (connected) {
|
||||||
|
assert.throws(
|
||||||
|
() => { sock.send(buf, 1, 1, -1, host); },
|
||||||
|
{
|
||||||
|
code: 'ERR_SOCKET_DGRAM_IS_CONNECTED',
|
||||||
|
name: 'Error',
|
||||||
|
message: 'Already connected'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => { sock.send(buf, 1, 1, 0, host); },
|
||||||
|
{
|
||||||
|
code: 'ERR_SOCKET_DGRAM_IS_CONNECTED',
|
||||||
|
name: 'Error',
|
||||||
|
message: 'Already connected'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => { sock.send(buf, 1, 1, 65536, host); },
|
||||||
|
{
|
||||||
|
code: 'ERR_SOCKET_DGRAM_IS_CONNECTED',
|
||||||
|
name: 'Error',
|
||||||
|
message: 'Already connected'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => { sock.send(buf, 1234, '127.0.0.1', common.mustNotCall()); },
|
||||||
|
{
|
||||||
|
code: 'ERR_SOCKET_DGRAM_IS_CONNECTED',
|
||||||
|
name: 'Error',
|
||||||
|
message: 'Already connected'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const longArray = [1, 2, 3, 4, 5, 6, 7, 8];
|
||||||
|
for (const input of ['hello',
|
||||||
|
Buffer.from('hello'),
|
||||||
|
Buffer.from('hello world').subarray(0, 5),
|
||||||
|
Buffer.from('hello world').subarray(4, 9),
|
||||||
|
Buffer.from('hello world').subarray(6),
|
||||||
|
new Uint8Array([1, 2, 3, 4, 5]),
|
||||||
|
new Uint8Array(longArray).subarray(0, 5),
|
||||||
|
new Uint8Array(longArray).subarray(2, 7),
|
||||||
|
new Uint8Array(longArray).subarray(3),
|
||||||
|
new DataView(new ArrayBuffer(5), 0),
|
||||||
|
new DataView(new ArrayBuffer(6), 1),
|
||||||
|
new DataView(new ArrayBuffer(7), 1, 5)]) {
|
||||||
|
assert.throws(
|
||||||
|
() => { sock.send(input, 6, 0); },
|
||||||
|
{
|
||||||
|
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
|
||||||
|
name: 'RangeError',
|
||||||
|
message: '"offset" is outside of buffer bounds',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => { sock.send(input, 0, 6); },
|
||||||
|
{
|
||||||
|
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
|
||||||
|
name: 'RangeError',
|
||||||
|
message: '"length" is outside of buffer bounds',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => { sock.send(input, 3, 4); },
|
||||||
|
{
|
||||||
|
code: 'ERR_BUFFER_OUT_OF_BOUNDS',
|
||||||
|
name: 'RangeError',
|
||||||
|
message: '"length" is outside of buffer bounds',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.throws(() => { sock.send(buf, 1, 1, -1, host); }, RangeError);
|
||||||
|
assert.throws(() => { sock.send(buf, 1, 1, 0, host); }, RangeError);
|
||||||
|
assert.throws(() => { sock.send(buf, 1, 1, 65536, host); }, RangeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// send(buf, port, host)
|
||||||
|
assert.throws(
|
||||||
|
() => { sock.send(23, 12345, host); },
|
||||||
|
{
|
||||||
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
|
name: 'TypeError',
|
||||||
|
message: 'The "buffer" argument must be of type string or an instance ' +
|
||||||
|
'of Buffer, TypedArray, or DataView. Received type number (23)'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// send([buf1, ..], port, host)
|
||||||
|
assert.throws(
|
||||||
|
() => { sock.send([buf, 23], 12345, host); },
|
||||||
|
{
|
||||||
|
code: 'ERR_INVALID_ARG_TYPE',
|
||||||
|
name: 'TypeError',
|
||||||
|
message: 'The "buffer list arguments" argument must be of type string ' +
|
||||||
|
'or an instance of Buffer, TypedArray, or DataView. ' +
|
||||||
|
'Received an instance of Array'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkArgs();
|
||||||
|
sock.connect(12345, common.mustCall(() => {
|
||||||
|
checkArgs(true);
|
||||||
|
sock.close();
|
||||||
|
}));
|
|
@ -0,0 +1,23 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const buf = Buffer.alloc(256, 'x');
|
||||||
|
|
||||||
|
const onMessage = common.mustSucceed((bytes) => {
|
||||||
|
assert.strictEqual(bytes, buf.length);
|
||||||
|
client.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
client.bind(0, () => client.send(buf, client.address().port, onMessage));
|
|
@ -0,0 +1,28 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const dgram = require('dgram');
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const buf = Buffer.alloc(256, 'x');
|
||||||
|
const offset = 20;
|
||||||
|
const len = buf.length - offset;
|
||||||
|
|
||||||
|
const onMessage = common.mustSucceed(function messageSent(bytes) {
|
||||||
|
assert.notStrictEqual(bytes, buf.length);
|
||||||
|
assert.strictEqual(bytes, buf.length - offset);
|
||||||
|
client.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
client.bind(0, () => client.send(buf, offset, len,
|
||||||
|
client.address().port,
|
||||||
|
onMessage));
|
|
@ -0,0 +1,50 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const dgram = require('dgram');
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const buf = Buffer.allocUnsafe(256);
|
||||||
|
const offset = 20;
|
||||||
|
const len = buf.length - offset;
|
||||||
|
|
||||||
|
const messageSent = common.mustSucceed(function messageSent(bytes) {
|
||||||
|
assert.notStrictEqual(bytes, buf.length);
|
||||||
|
assert.strictEqual(bytes, buf.length - offset);
|
||||||
|
client.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
client.bind(0, () => client.send(buf, offset, len,
|
||||||
|
client.address().port,
|
||||||
|
'127.0.0.1',
|
||||||
|
messageSent));
|
|
@ -0,0 +1,26 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const buf = Buffer.allocUnsafe(256);
|
||||||
|
|
||||||
|
const onMessage = common.mustSucceed((bytes) => {
|
||||||
|
assert.strictEqual(bytes, buf.length);
|
||||||
|
client.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
client.bind(0, () => client.send(buf,
|
||||||
|
client.address().port,
|
||||||
|
common.localhostIPv4,
|
||||||
|
onMessage));
|
|
@ -0,0 +1,34 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const messageSent = common.mustSucceed(function messageSent(bytes) {
|
||||||
|
assert.strictEqual(bytes, buf1.length + buf2.length);
|
||||||
|
});
|
||||||
|
|
||||||
|
const buf1 = Buffer.alloc(256, 'x');
|
||||||
|
const buf2 = Buffer.alloc(256, 'y');
|
||||||
|
|
||||||
|
client.on('listening', function() {
|
||||||
|
const port = this.address().port;
|
||||||
|
client.send([buf1, buf2], port, messageSent);
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('message', common.mustCall(function onMessage(buf) {
|
||||||
|
const expected = Buffer.concat([buf1, buf2]);
|
||||||
|
assert.ok(buf.equals(expected), 'message was received correctly');
|
||||||
|
client.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.bind(0);
|
|
@ -0,0 +1,34 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const messageSent = common.mustCall((err, bytes) => {
|
||||||
|
assert.strictEqual(bytes, buf1.length + buf2.length);
|
||||||
|
});
|
||||||
|
|
||||||
|
const buf1 = Buffer.alloc(256, 'x');
|
||||||
|
const buf2 = Buffer.alloc(256, 'y');
|
||||||
|
|
||||||
|
client.on('listening', () => {
|
||||||
|
const port = client.address().port;
|
||||||
|
client.send([buf1, buf2], port, common.localhostIPv4, messageSent);
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('message', common.mustCall((buf, info) => {
|
||||||
|
const expected = Buffer.concat([buf1, buf2]);
|
||||||
|
assert.ok(buf.equals(expected), 'message was received correctly');
|
||||||
|
client.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.bind(0);
|
|
@ -0,0 +1,50 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
const dgram = require('dgram');
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
const chunk = 'abc';
|
||||||
|
let received = 0;
|
||||||
|
let sent = 0;
|
||||||
|
const limit = 10;
|
||||||
|
let async = false;
|
||||||
|
let port;
|
||||||
|
|
||||||
|
function onsend() {
|
||||||
|
if (sent++ < limit) {
|
||||||
|
client.send(chunk, 0, chunk.length, port, common.localhostIPv4, onsend);
|
||||||
|
} else {
|
||||||
|
assert.strictEqual(async, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client.on('listening', function() {
|
||||||
|
port = this.address().port;
|
||||||
|
|
||||||
|
process.nextTick(() => {
|
||||||
|
async = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
onsend();
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('message', (buf, info) => {
|
||||||
|
received++;
|
||||||
|
if (received === limit) {
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('close', common.mustCall(function() {
|
||||||
|
assert.strictEqual(received, limit);
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.bind(0);
|
|
@ -0,0 +1,79 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
const toSend = [Buffer.alloc(256, 'x'),
|
||||||
|
Buffer.alloc(256, 'y'),
|
||||||
|
Buffer.alloc(256, 'z'),
|
||||||
|
'hello'];
|
||||||
|
|
||||||
|
const received = [];
|
||||||
|
let totalBytesSent = 0;
|
||||||
|
let totalBytesReceived = 0;
|
||||||
|
const arrayBufferViewsCount = common.getArrayBufferViews(
|
||||||
|
Buffer.from('')
|
||||||
|
).length;
|
||||||
|
|
||||||
|
client.on('listening', common.mustCall(() => {
|
||||||
|
const port = client.address().port;
|
||||||
|
|
||||||
|
client.send(toSend[0], 0, toSend[0].length, port);
|
||||||
|
client.send(toSend[1], port);
|
||||||
|
client.send([toSend[2]], port);
|
||||||
|
client.send(toSend[3], 0, toSend[3].length, port);
|
||||||
|
|
||||||
|
totalBytesSent += toSend.map((buf) => buf.length)
|
||||||
|
.reduce((a, b) => a + b, 0);
|
||||||
|
|
||||||
|
for (const msgBuf of common.getArrayBufferViews(toSend[0])) {
|
||||||
|
client.send(msgBuf, 0, msgBuf.byteLength, port);
|
||||||
|
totalBytesSent += msgBuf.byteLength;
|
||||||
|
}
|
||||||
|
for (const msgBuf of common.getArrayBufferViews(toSend[1])) {
|
||||||
|
client.send(msgBuf, port);
|
||||||
|
totalBytesSent += msgBuf.byteLength;
|
||||||
|
}
|
||||||
|
for (const msgBuf of common.getArrayBufferViews(toSend[2])) {
|
||||||
|
client.send([msgBuf], port);
|
||||||
|
totalBytesSent += msgBuf.byteLength;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.on('message', common.mustCall((buf, info) => {
|
||||||
|
received.push(buf.toString());
|
||||||
|
totalBytesReceived += info.size;
|
||||||
|
|
||||||
|
if (totalBytesReceived === totalBytesSent) {
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
|
// For every buffer in `toSend`, we send the raw Buffer,
|
||||||
|
// as well as every TypedArray in getArrayBufferViews()
|
||||||
|
}, toSend.length + (toSend.length - 1) * arrayBufferViewsCount));
|
||||||
|
|
||||||
|
client.on('close', common.mustCall((buf, info) => {
|
||||||
|
// The replies may arrive out of order -> sort them before checking.
|
||||||
|
received.sort();
|
||||||
|
|
||||||
|
const repeated = [...toSend];
|
||||||
|
for (let i = 0; i < arrayBufferViewsCount; i++) {
|
||||||
|
repeated.push(...toSend.slice(0, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.strictEqual(totalBytesSent, totalBytesReceived);
|
||||||
|
|
||||||
|
const expected = repeated.map(String).sort();
|
||||||
|
assert.deepStrictEqual(received, expected);
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.bind(0);
|
|
@ -0,0 +1,32 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
let interval;
|
||||||
|
|
||||||
|
client.on('message', common.mustCall(function onMessage(buf, info) {
|
||||||
|
const expected = Buffer.alloc(0);
|
||||||
|
assert.ok(buf.equals(expected), `Expected empty message but got ${buf}`);
|
||||||
|
clearInterval(interval);
|
||||||
|
client.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.on('listening', common.mustCall(function() {
|
||||||
|
interval = setInterval(function() {
|
||||||
|
client.send([], client.address().port, common.localhostIPv4);
|
||||||
|
}, 10);
|
||||||
|
}));
|
||||||
|
|
||||||
|
client.bind(0);
|
|
@ -0,0 +1,50 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Copyright Joyent, Inc. and other Node contributors.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the
|
||||||
|
// "Software"), to deal in the Software without restriction, including
|
||||||
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||||
|
// persons to whom the Software is furnished to do so, subject to the
|
||||||
|
// following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included
|
||||||
|
// in all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||||
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
client.bind(0, common.mustCall(function() {
|
||||||
|
const port = this.address().port;
|
||||||
|
|
||||||
|
client.on('message', common.mustCall(function onMessage(buffer) {
|
||||||
|
assert.strictEqual(buffer.length, 0);
|
||||||
|
clearInterval(interval);
|
||||||
|
client.close();
|
||||||
|
}));
|
||||||
|
|
||||||
|
const buf = Buffer.alloc(0);
|
||||||
|
const interval = setInterval(function() {
|
||||||
|
client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall());
|
||||||
|
}, 10);
|
||||||
|
}));
|
|
@ -0,0 +1,36 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
|
||||||
|
const client = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
client.bind(0, common.mustCall(function() {
|
||||||
|
|
||||||
|
client.on('message', common.mustCall(callback));
|
||||||
|
|
||||||
|
const port = this.address().port;
|
||||||
|
const buf = Buffer.alloc(1);
|
||||||
|
|
||||||
|
const interval = setInterval(function() {
|
||||||
|
client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall(callback));
|
||||||
|
}, 10);
|
||||||
|
|
||||||
|
function callback(firstArg) {
|
||||||
|
// If client.send() callback, firstArg should be null.
|
||||||
|
// If client.on('message') listener, firstArg should be a 0-length buffer.
|
||||||
|
if (firstArg instanceof Buffer) {
|
||||||
|
assert.strictEqual(firstArg.length, 0);
|
||||||
|
clearInterval(interval);
|
||||||
|
client.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
77
tests/node_compat/test/parallel/test-dgram-send-error.js
Normal file
77
tests/node_compat/test/parallel/test-dgram-send-error.js
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
// deno-fmt-ignore-file
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
// Taken from Node 20.11.1
|
||||||
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
||||||
|
|
||||||
|
// Flags: --expose-internals
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const dgram = require('dgram');
|
||||||
|
const { internalBinding } = require('internal/test/binding');
|
||||||
|
const { UV_UNKNOWN } = internalBinding('uv');
|
||||||
|
const { getSystemErrorName } = require('util');
|
||||||
|
const { kStateSymbol } = require('internal/dgram');
|
||||||
|
const mockError = new Error('mock DNS error');
|
||||||
|
|
||||||
|
function getSocket(callback) {
|
||||||
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
socket.on('message', common.mustNotCall('Should not receive any messages.'));
|
||||||
|
socket.bind(common.mustCall(() => {
|
||||||
|
socket[kStateSymbol].handle.lookup = function(address, callback) {
|
||||||
|
process.nextTick(callback, mockError);
|
||||||
|
};
|
||||||
|
|
||||||
|
callback(socket);
|
||||||
|
}));
|
||||||
|
return socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
getSocket((socket) => {
|
||||||
|
socket.on('error', common.mustCall((err) => {
|
||||||
|
socket.close();
|
||||||
|
assert.strictEqual(err, mockError);
|
||||||
|
}));
|
||||||
|
|
||||||
|
socket.send('foo', socket.address().port, 'localhost');
|
||||||
|
});
|
||||||
|
|
||||||
|
getSocket((socket) => {
|
||||||
|
const callback = common.mustCall((err) => {
|
||||||
|
socket.close();
|
||||||
|
assert.strictEqual(err, mockError);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.send('foo', socket.address().port, 'localhost', callback);
|
||||||
|
});
|
||||||
|
|
||||||
|
{
|
||||||
|
const socket = dgram.createSocket('udp4');
|
||||||
|
|
||||||
|
socket.on('message', common.mustNotCall('Should not receive any messages.'));
|
||||||
|
|
||||||
|
socket.bind(common.mustCall(() => {
|
||||||
|
const port = socket.address().port;
|
||||||
|
const callback = common.mustCall((err) => {
|
||||||
|
socket.close();
|
||||||
|
assert.strictEqual(err.code, 'UNKNOWN');
|
||||||
|
assert.strictEqual(getSystemErrorName(err.errno), 'UNKNOWN');
|
||||||
|
assert.strictEqual(err.syscall, 'send');
|
||||||
|
assert.strictEqual(err.address, common.localhostIPv4);
|
||||||
|
assert.strictEqual(err.port, port);
|
||||||
|
assert.strictEqual(
|
||||||
|
err.message,
|
||||||
|
`${err.syscall} ${err.code} ${err.address}:${err.port}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket[kStateSymbol].handle.send = function() {
|
||||||
|
return UV_UNKNOWN;
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.send('foo', port, common.localhostIPv4, callback);
|
||||||
|
}));
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue