diff --git a/cli/js/tests/net_test.ts b/cli/js/tests/net_test.ts index 788203b5a2aa99..2c077c102f12aa 100644 --- a/cli/js/tests/net_test.ts +++ b/cli/js/tests/net_test.ts @@ -3,16 +3,14 @@ import { unitTest, assert, assertEquals, - createResolvable, - randomPort + createResolvable } from "./test_util.ts"; unitTest({ perms: { net: true } }, function netTcpListenClose(): void { - const port = randomPort(); - const listener = Deno.listen({ hostname: "127.0.0.1", port }); + const listener = Deno.listen({ hostname: "127.0.0.1", port: 4500 }); assert(listener.addr.transport === "tcp"); assertEquals(listener.addr.hostname, "127.0.0.1"); - assertEquals(listener.addr.port, port); + assertEquals(listener.addr.port, 4500); listener.close(); }); @@ -23,15 +21,14 @@ unitTest( ignore: Deno.build.os === "win" }, function netUdpListenClose(): void { - const port = randomPort(); const socket = Deno.listen({ hostname: "127.0.0.1", - port, + port: 4500, transport: "udp" }); assert(socket.addr.transport === "udp"); assertEquals(socket.addr.hostname, "127.0.0.1"); - assertEquals(socket.addr.port, port); + assertEquals(socket.addr.port, 4500); socket.close(); } ); @@ -69,8 +66,7 @@ unitTest( perms: { net: true } }, async function netTcpCloseWhileAccept(): Promise { - const port = randomPort(); - const listener = Deno.listen({ port }); + const listener = Deno.listen({ port: 4501 }); const p = listener.accept(); listener.close(); let err; @@ -110,8 +106,7 @@ unitTest( unitTest( { perms: { net: true } }, async function netTcpConcurrentAccept(): Promise { - const port = randomPort(); - const listener = Deno.listen({ port }); + const listener = Deno.listen({ port: 4502 }); let acceptErrCount = 0; const checkErr = (e: Error): void => { if (e.message === "Listener has been closed") { @@ -159,22 +154,22 @@ unitTest( unitTest({ perms: { net: true } }, async function netTcpDialListen(): Promise< void > { - const port = randomPort(); - const listener = Deno.listen({ port }); + const listener = Deno.listen({ port: 4500 }); listener.accept().then( async (conn): Promise => { assert(conn.remoteAddr != null); assert(conn.localAddr.transport === "tcp"); assertEquals(conn.localAddr.hostname, "127.0.0.1"); - assertEquals(conn.localAddr.port, port); + assertEquals(conn.localAddr.port, 4500); await conn.write(new Uint8Array([1, 2, 3])); conn.close(); } ); - const conn = await Deno.connect({ hostname: "127.0.0.1", port }); + + const conn = await Deno.connect({ hostname: "127.0.0.1", port: 4500 }); assert(conn.remoteAddr.transport === "tcp"); assertEquals(conn.remoteAddr.hostname, "127.0.0.1"); - assertEquals(conn.remoteAddr.port, port); + assertEquals(conn.remoteAddr.port, 4500); assert(conn.localAddr != null); const buf = new Uint8Array(1024); const readResult = await conn.read(buf); @@ -232,16 +227,14 @@ unitTest( unitTest( { ignore: Deno.build.os === "win", perms: { net: true } }, async function netUdpSendReceive(): Promise { - const alicePort = randomPort(); - const alice = Deno.listen({ port: alicePort, transport: "udp" }); + const alice = Deno.listen({ port: 4500, transport: "udp" }); assert(alice.addr.transport === "udp"); - assertEquals(alice.addr.port, alicePort); + assertEquals(alice.addr.port, 4500); assertEquals(alice.addr.hostname, "127.0.0.1"); - const bobPort = randomPort(); - const bob = Deno.listen({ port: bobPort, transport: "udp" }); + const bob = Deno.listen({ port: 4501, transport: "udp" }); assert(bob.addr.transport === "udp"); - assertEquals(bob.addr.port, bobPort); + assertEquals(bob.addr.port, 4501); assertEquals(bob.addr.hostname, "127.0.0.1"); const sent = new Uint8Array([1, 2, 3]); @@ -249,7 +242,7 @@ unitTest( const [recvd, remote] = await bob.receive(); assert(remote.transport === "udp"); - assertEquals(remote.port, alicePort); + assertEquals(remote.port, 4500); assertEquals(recvd.length, 3); assertEquals(1, recvd[0]); assertEquals(2, recvd[1]); @@ -289,8 +282,7 @@ unitTest( unitTest( { perms: { net: true } }, async function netTcpListenCloseWhileIterating(): Promise { - const port = randomPort(); - const listener = Deno.listen({ port }); + const listener = Deno.listen({ port: 8000 }); const nextWhileClosing = listener[Symbol.asyncIterator]().next(); listener.close(); assertEquals(await nextWhileClosing, { value: undefined, done: true }); @@ -303,8 +295,7 @@ unitTest( unitTest( { ignore: Deno.build.os === "win", perms: { net: true } }, async function netUdpListenCloseWhileIterating(): Promise { - const port = randomPort(); - const socket = Deno.listen({ port, transport: "udp" }); + const socket = Deno.listen({ port: 8000, transport: "udp" }); const nextWhileClosing = socket[Symbol.asyncIterator]().next(); socket.close(); assertEquals(await nextWhileClosing, { value: undefined, done: true }); @@ -349,8 +340,7 @@ unitTest( perms: { net: true } }, async function netListenAsyncIterator(): Promise { - const port = randomPort(); - const addr = { hostname: "127.0.0.1", port }; + const addr = { hostname: "127.0.0.1", port: 4500 }; const listener = Deno.listen(addr); const runAsyncIterator = async (): Promise => { for await (const conn of listener) { @@ -385,8 +375,7 @@ unitTest( perms: { net: true } }, async function netCloseReadSuccess() { - const port = randomPort(); - const addr = { hostname: "127.0.0.1", port }; + const addr = { hostname: "127.0.0.1", port: 4500 }; const listener = Deno.listen(addr); const closeDeferred = createResolvable(); const closeReadDeferred = createResolvable(); @@ -423,8 +412,7 @@ unitTest( perms: { net: true } }, async function netDoubleCloseRead() { - const port = randomPort(); - const addr = { hostname: "127.0.0.1", port }; + const addr = { hostname: "127.0.0.1", port: 4500 }; const listener = Deno.listen(addr); const closeDeferred = createResolvable(); listener.accept().then(async conn => { @@ -456,8 +444,7 @@ unitTest( perms: { net: true } }, async function netCloseWriteSuccess() { - const port = randomPort(); - const addr = { hostname: "127.0.0.1", port }; + const addr = { hostname: "127.0.0.1", port: 4500 }; const listener = Deno.listen(addr); const closeDeferred = createResolvable(); listener.accept().then(async conn => { @@ -496,8 +483,7 @@ unitTest( perms: { net: true } }, async function netDoubleCloseWrite() { - const port = randomPort(); - const addr = { hostname: "127.0.0.1", port }; + const addr = { hostname: "127.0.0.1", port: 4500 }; const listener = Deno.listen(addr); const closeDeferred = createResolvable(); listener.accept().then(async conn => { @@ -549,8 +535,8 @@ unitTest( resolvable.resolve(); } - const port = randomPort(); - const addr = { hostname: "127.0.0.1", port }; + + const addr = { hostname: "127.0.0.1", port: 4500 }; const listener = Deno.listen(addr); iteratorReq(listener); const conn = await Deno.connect(addr); diff --git a/cli/js/tests/test_util.ts b/cli/js/tests/test_util.ts index 347a2204e89deb..980d32bac403b6 100644 --- a/cli/js/tests/test_util.ts +++ b/cli/js/tests/test_util.ts @@ -359,21 +359,3 @@ unitTest( }); } ); -function* portIterator(): IterableIterator { - // use 49152 ~ 55000 for js/cli (rest are for std) - let i = 49152; - while (true) { - yield i; - i++; - if (i > 55000) { - i = 55000; - } - } -} -const it = portIterator(); -/** Obtain (maybe) safe port number for net tests */ -export function randomPort(): number { - const { value } = it.next(); - assert(value != null); - return value; -} diff --git a/cli/js/tests/tls_test.ts b/cli/js/tests/tls_test.ts index 2e6e5afc96eb18..20dd62f9b1ef96 100644 --- a/cli/js/tests/tls_test.ts +++ b/cli/js/tests/tls_test.ts @@ -2,7 +2,6 @@ import { assert, assertEquals, - randomPort, createResolvable, unitTest } from "./test_util.ts"; @@ -44,7 +43,7 @@ unitTest( let err; const options = { hostname: "localhost", - port: randomPort(), + port: 4500, certFile: "cli/tests/tls/localhost.crt", keyFile: "cli/tests/tls/localhost.key" }; @@ -73,11 +72,10 @@ unitTest( unitTest({ perms: { net: true } }, function listenTLSNoReadPerm(): void { let err; - const port = randomPort(); try { Deno.listenTLS({ hostname: "localhost", - port, + port: 4500, certFile: "cli/tests/tls/localhost.crt", keyFile: "cli/tests/tls/localhost.key" }); @@ -96,7 +94,7 @@ unitTest( let err; const options = { hostname: "localhost", - port: randomPort(), + port: 4500, certFile: "cli/tests/tls/localhost.crt", keyFile: "cli/tests/tls/localhost.key" }; @@ -125,7 +123,7 @@ unitTest( let err; const options = { hostname: "localhost", - port: randomPort(), + port: 4500, certFile: "cli/tests/tls/localhost.crt", keyFile: "cli/tests/tls/localhost.key" }; @@ -153,7 +151,7 @@ unitTest( async function dialAndListenTLS(): Promise { const resolvable = createResolvable(); const hostname = "localhost"; - const port = randomPort(); + const port = 4500; const listener = Deno.listenTLS({ hostname, diff --git a/std/examples/chat/server.ts b/std/examples/chat/server.ts index d28f9f43fc324e..08aede05bbc6d4 100644 --- a/std/examples/chat/server.ts +++ b/std/examples/chat/server.ts @@ -29,9 +29,7 @@ async function wsHandler(ws: WebSocket): Promise { } } -const addr = Deno.args[0] ?? "127.0.0.1:8080"; - -listenAndServe(addr, async req => { +listenAndServe({ port: 8080 }, async req => { if (req.method === "GET" && req.url === "/") { //Serve with hack const u = new URL("./index.html", import.meta.url); @@ -77,4 +75,4 @@ listenAndServe(addr, async req => { } } }); -console.log(`chat server starting on ${addr}....`); +console.log("chat server starting on :8080...."); diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts index e09771e5208c6a..13a5c337c18ef5 100644 --- a/std/examples/chat/server_test.ts +++ b/std/examples/chat/server_test.ts @@ -3,22 +3,13 @@ import { assert, assertEquals } from "../../testing/asserts.ts"; import { TextProtoReader } from "../../textproto/mod.ts"; import { BufReader } from "../../io/bufio.ts"; import { connectWebSocket, WebSocket } from "../../ws/mod.ts"; -import { randomPort } from "../../http/test_util.ts"; import { delay } from "../../util/async.ts"; -const port = randomPort(); - const { test, build } = Deno; async function startServer(): Promise { const server = Deno.run({ - cmd: [ - Deno.execPath(), - "--allow-net", - "--allow-read", - "server.ts", - `127.0.0.1:${port}` - ], + cmd: [Deno.execPath(), "--allow-net", "--allow-read", "server.ts"], cwd: "examples/chat", stdout: "piped" }); @@ -44,7 +35,7 @@ test({ async fn() { const server = await startServer(); try { - const resp = await fetch(`http://127.0.0.1:${port}/`); + const resp = await fetch("http://127.0.0.1:8080/"); assertEquals(resp.status, 200); assertEquals(resp.headers.get("content-type"), "text/html"); const html = await resp.body.text(); @@ -64,7 +55,7 @@ test({ const server = await startServer(); let ws: WebSocket | undefined; try { - ws = await connectWebSocket(`http://127.0.0.1:${port}/ws`); + ws = await connectWebSocket("http://127.0.0.1:8080/ws"); const it = ws.receive(); assertEquals((await it.next()).value, "Connected: [1]"); ws.send("Hello"); diff --git a/std/examples/echo_server.ts b/std/examples/echo_server.ts index cdd98fea7244be..dbcc9b5aead8b5 100644 --- a/std/examples/echo_server.ts +++ b/std/examples/echo_server.ts @@ -1,6 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. const hostname = "0.0.0.0"; -const port = +(Deno.args[0] ?? "8080"); +const port = 8080; const listener = Deno.listen({ hostname, port }); console.log(`Listening on ${hostname}:${port}`); for await (const conn of listener) { diff --git a/std/examples/tests/curl_test.ts b/std/examples/tests/curl_test.ts index 3e3d4f78a94e2c..8d7634525363a9 100644 --- a/std/examples/tests/curl_test.ts +++ b/std/examples/tests/curl_test.ts @@ -1,13 +1,11 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { serve } from "../../http/server.ts"; import { assertStrictEq } from "../../testing/asserts.ts"; -import { randomPort } from "../../http/test_util.ts"; -const port = randomPort(); Deno.test({ name: "[examples/curl] send a request to a specified url", fn: async () => { - const server = serve({ port }); + const server = serve({ port: 8081 }); const serverPromise = (async (): Promise => { for await (const req of server) { req.respond({ body: "Hello world" }); @@ -16,12 +14,7 @@ Deno.test({ const decoder = new TextDecoder(); const process = Deno.run({ - cmd: [ - Deno.execPath(), - "--allow-net", - "curl.ts", - "http://localhost:" + port - ], + cmd: [Deno.execPath(), "--allow-net", "curl.ts", "http://localhost:8081"], cwd: "examples", stdout: "piped" }); diff --git a/std/examples/tests/echo_server_test.ts b/std/examples/tests/echo_server_test.ts index 164f65357ab03f..dd73360232ce80 100644 --- a/std/examples/tests/echo_server_test.ts +++ b/std/examples/tests/echo_server_test.ts @@ -1,14 +1,12 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { assertStrictEq, assertNotEquals } from "../../testing/asserts.ts"; import { BufReader, ReadLineResult } from "../../io/bufio.ts"; -import { randomPort } from "../../http/test_util.ts"; -const port = randomPort(); Deno.test("[examples/echo_server]", async () => { const encoder = new TextEncoder(); const decoder = new TextDecoder(); const process = Deno.run({ - cmd: [Deno.execPath(), "--allow-net", "echo_server.ts", `${port}`], + cmd: [Deno.execPath(), "--allow-net", "echo_server.ts"], cwd: "examples", stdout: "piped" }); @@ -21,10 +19,10 @@ Deno.test("[examples/echo_server]", async () => { assertNotEquals(message, Deno.EOF); assertStrictEq( decoder.decode((message as ReadLineResult).line).trim(), - "Listening on 0.0.0.0:" + port + "Listening on 0.0.0.0:8080" ); - conn = await Deno.connect({ hostname: "127.0.0.1", port }); + conn = await Deno.connect({ hostname: "127.0.0.1", port: 8080 }); const connReader = new BufReader(conn); await conn.write(encoder.encode("Hello echo_server\n")); diff --git a/std/http/file_server_test.ts b/std/http/file_server_test.ts index d7f939dad85dfb..fcf776ea29e654 100644 --- a/std/http/file_server_test.ts +++ b/std/http/file_server_test.ts @@ -2,11 +2,9 @@ import { assert, assertEquals, assertStrContains } from "../testing/asserts.ts"; import { BufReader } from "../io/bufio.ts"; import { TextProtoReader } from "../textproto/mod.ts"; -import { randomPort } from "./test_util.ts"; const { test } = Deno; let fileServer: Deno.Process; -const port = randomPort(); async function startFileServer(): Promise { fileServer = Deno.run({ cmd: [ @@ -16,9 +14,7 @@ async function startFileServer(): Promise { "--allow-net", "http/file_server.ts", ".", - "--cors", - "--port", - `${port}` + "--cors" ], stdout: "piped", stderr: "null" @@ -38,7 +34,7 @@ function killFileServer(): void { test(async function serveFile(): Promise { await startFileServer(); try { - const res = await fetch(`http://localhost:${port}/README.md`); + const res = await fetch("http://localhost:4500/README.md"); assert(res.headers.has("access-control-allow-origin")); assert(res.headers.has("access-control-allow-headers")); assert(res.headers.has("content-type")); @@ -56,7 +52,7 @@ test(async function serveFile(): Promise { test(async function serveDirectory(): Promise { await startFileServer(); try { - const res = await fetch(`http://localhost:${port}/`); + const res = await fetch("http://localhost:4500/"); assert(res.headers.has("access-control-allow-origin")); assert(res.headers.has("access-control-allow-headers")); const page = await res.text(); @@ -78,7 +74,7 @@ test(async function serveDirectory(): Promise { test(async function serveFallback(): Promise { await startFileServer(); try { - const res = await fetch(`http://localhost:${port}/badfile.txt`); + const res = await fetch("http://localhost:4500/badfile.txt"); assert(res.headers.has("access-control-allow-origin")); assert(res.headers.has("access-control-allow-headers")); assertEquals(res.status, 404); @@ -91,12 +87,12 @@ test(async function serveFallback(): Promise { test(async function serveWithUnorthodoxFilename(): Promise { await startFileServer(); try { - let res = await fetch(`http://localhost:${port}/http/testdata/%`); + let res = await fetch("http://localhost:4500/http/testdata/%"); assert(res.headers.has("access-control-allow-origin")); assert(res.headers.has("access-control-allow-headers")); assertEquals(res.status, 200); res.body.close(); - res = await fetch(`http://localhost:${port}/http/testdata/test%20file.txt`); + res = await fetch("http://localhost:4500/http/testdata/test%20file.txt"); assert(res.headers.has("access-control-allow-origin")); assert(res.headers.has("access-control-allow-headers")); assertEquals(res.status, 200); @@ -107,16 +103,8 @@ test(async function serveWithUnorthodoxFilename(): Promise { }); test(async function servePermissionDenied(): Promise { - const _port = randomPort(); const deniedServer = Deno.run({ - cmd: [ - Deno.execPath(), - "run", - "--allow-net", - "http/file_server.ts", - "-p", - `${_port}` - ], + cmd: [Deno.execPath(), "run", "--allow-net", "http/file_server.ts"], stdout: "piped", stderr: "piped" }); @@ -128,7 +116,7 @@ test(async function servePermissionDenied(): Promise { assert(s !== Deno.EOF && s.includes("server listening")); try { - const res = await fetch(`http://localhost:${_port}/`); + const res = await fetch("http://localhost:4500/"); res.body.close(); assertStrContains( (await errReader.readLine()) as string, diff --git a/std/http/http_bench.ts b/std/http/http_bench.ts index 060d0ad881af26..9d191283170cd0 100644 --- a/std/http/http_bench.ts +++ b/std/http/http_bench.ts @@ -1,8 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { serve } from "./server.ts"; -import { randomPort } from "./test_util.ts"; -const addr = Deno.args[0] || "127.0.0.1:" + randomPort(); +const addr = Deno.args[0] || "127.0.0.1:4500"; const server = serve(addr); const body = new TextEncoder().encode("Hello World"); diff --git a/std/http/racing_server.ts b/std/http/racing_server.ts index 693531a7fb7e5b..0b0e5a8a5652af 100644 --- a/std/http/racing_server.ts +++ b/std/http/racing_server.ts @@ -2,7 +2,7 @@ import { serve, ServerRequest } from "./server.ts"; import { delay } from "../util/async.ts"; -const addr = Deno.args[0] || "127.0.0.1:4501"; +const addr = Deno.args[1] || "127.0.0.1:4501"; const server = serve(addr); function body(i: number): string { diff --git a/std/http/racing_server_test.ts b/std/http/racing_server_test.ts index 76b0e872d4693b..865777599fe611 100644 --- a/std/http/racing_server_test.ts +++ b/std/http/racing_server_test.ts @@ -1,20 +1,12 @@ import { assert, assertEquals } from "../testing/asserts.ts"; import { BufReader, BufWriter } from "../io/bufio.ts"; import { TextProtoReader } from "../textproto/mod.ts"; -import { randomPort } from "./test_util.ts"; -const port = randomPort(); const { connect, run, test } = Deno; let server: Deno.Process; async function startServer(): Promise { server = run({ - cmd: [ - Deno.execPath(), - "run", - "-A", - "http/racing_server.ts", - "127.0.0.1:" + port - ], + cmd: [Deno.execPath(), "run", "-A", "http/racing_server.ts"], stdout: "piped" }); // Once racing server is ready it will write to its stdout. @@ -69,7 +61,7 @@ Step7 test(async function serverPipelineRace(): Promise { await startServer(); - const conn = await connect({ port }); + const conn = await connect({ port: 4501 }); const r = new TextProtoReader(new BufReader(conn)); const w = new BufWriter(conn); await w.write(new TextEncoder().encode(input)); diff --git a/std/http/server_test.ts b/std/http/server_test.ts index d9ce3ba970849a..f66b190b266996 100644 --- a/std/http/server_test.ts +++ b/std/http/server_test.ts @@ -18,7 +18,6 @@ import { BufReader, BufWriter } from "../io/bufio.ts"; import { delay } from "../util/async.ts"; import { encode, decode } from "../strings/mod.ts"; import { mockConn } from "./mock.ts"; -import { randomPort } from "./test_util.ts"; const { Buffer, test } = Deno; @@ -356,14 +355,8 @@ test({ ignore: true, fn: async (): Promise => { // Runs a simple server as another process - const port = randomPort(); const p = Deno.run({ - cmd: [ - Deno.execPath(), - "--allow-net", - "http/testdata/simple_server.ts", - `${port}` - ], + cmd: [Deno.execPath(), "--allow-net", "http/testdata/simple_server.ts"], stdout: "piped" }); @@ -402,15 +395,13 @@ test({ // FIXME(bartlomieju): hangs on windows, cause can't do `Deno.kill` ignore: true, fn: async (): Promise => { - const port = randomPort(); // Runs a simple server as another process const p = Deno.run({ cmd: [ Deno.execPath(), "--allow-net", "--allow-read", - "http/testdata/simple_https_server.ts", - `${port}` + "http/testdata/simple_https_server.ts" ], stdout: "piped" }); @@ -422,6 +413,7 @@ test({ serverIsRunning = false; }) .catch((_): void => {}); // Ignores the error when closing the process. + try { const r = new TextProtoReader(new BufReader(p.stdout!)); const s = await r.readLine(); @@ -432,7 +424,7 @@ test({ // Requests to the server and immediately closes the connection const conn = await Deno.connectTLS({ hostname: "localhost", - port, + port: 4503, certFile: "http/testdata/tls/RootCA.pem" }); await Deno.writeAll( @@ -456,7 +448,7 @@ test({ }); test("close server while iterating", async (): Promise => { - const server = serve({ port: randomPort() }); + const server = serve(":8123"); const nextWhileClosing = server[Symbol.asyncIterator]().next(); server.close(); assertEquals(await nextWhileClosing, { value: undefined, done: true }); @@ -499,9 +491,8 @@ test({ test({ name: "respond error closes connection", async fn(): Promise { - const port = randomPort(); const serverRoutine = async (): Promise => { - const server = serve(":" + port); + const server = serve(":8124"); // @ts-ignore for await (const req of server) { await assertThrowsAsync(async () => { @@ -518,7 +509,7 @@ test({ const p = serverRoutine(); const conn = await Deno.connect({ hostname: "127.0.0.1", - port + port: 8124 }); await Deno.writeAll( conn, diff --git a/std/http/test_util.ts b/std/http/test_util.ts deleted file mode 100644 index c86a339a7f7ff0..00000000000000 --- a/std/http/test_util.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { assert } from "../testing/asserts.ts"; - -function* portIterator(): IterableIterator { - // use 55001 ~ 65535 (rest (49152~55000) are for cli/js) - let i = 55001; - while (true) { - yield i; - i++; - if (i > 65535) { - i = 55001; - } - } -} -const it = portIterator(); -/** Obtain (maybe) safe port number for net tests */ -export function randomPort(): number { - const { value } = it.next(); - assert(value != null); - return value; -} diff --git a/std/http/testdata/simple_https_server.ts b/std/http/testdata/simple_https_server.ts index 9e30456098f81e..9330b4172bbdde 100644 --- a/std/http/testdata/simple_https_server.ts +++ b/std/http/testdata/simple_https_server.ts @@ -2,10 +2,9 @@ // This is an example of a https server import { serveTLS } from "../server.ts"; -const port = parseInt(Deno.args[0] || "4503"); const tlsOptions = { hostname: "localhost", - port, + port: 4503, certFile: "./http/testdata/tls/localhost.crt", keyFile: "./http/testdata/tls/localhost.key" }; diff --git a/std/http/testdata/simple_server.ts b/std/http/testdata/simple_server.ts index 05f169705a4270..d8ca4cc97bd72e 100644 --- a/std/http/testdata/simple_server.ts +++ b/std/http/testdata/simple_server.ts @@ -2,9 +2,8 @@ // This is an example of a server that responds with an empty body import { serve } from "../server.ts"; -const port = parseInt(Deno.args[0] || "4502"); -const addr: Deno.ListenOptions = { port }; -console.log(`Simple server listening on ${port}`); +const addr = "0.0.0.0:4502"; +console.log(`Simple server listening on ${addr}`); for await (const req of serve(addr)) { req.respond({}); }