Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix test
  • Loading branch information
islandryu committed Jan 14, 2025
commit 72eb4dc11b295d66cf05bb36e44147d6b7785077
9 changes: 6 additions & 3 deletions test/parallel/test-http2-ip-address-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const key = loadKey('agent8-key.pem');
const cert = fixtures.readKey('agent8-cert.pem');

const server = h2.createSecureServer({ key, cert });
const hasIPv6 = common.hasIPv6;
const testCount = hasIPv6 ? 2 : 1;

server.on('stream', common.mustCall((stream) => {
const session = stream.session;
assert.strictEqual(session.servername, undefined);
Expand All @@ -23,7 +26,7 @@ server.on('stream', common.mustCall((stream) => {
originSet: session.originSet
})
);
}, 2));
}, testCount));

let done = 0;

Expand All @@ -39,12 +42,12 @@ server.listen(0, common.mustCall(() => {
const originSet = req.session.originSet;
assert.strictEqual(originSet[0], url);
client.close();
if (++done === 2) server.close();
if (++done === testCount) server.close();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed that the number of tests changes if you don't test for IPv6.

}));
}

const ipv4Url = `https://127.0.0.1:${server.address().port}`;
const ipv6Url = `https://[::1]:${server.address().port}`;
handleRequest(ipv4Url);
if (common.hasIPv6) handleRequest(ipv6Url);
if (hasIPv6) handleRequest(ipv6Url);
}));