Skip to content

Commit

Permalink
test: migrate tests to use node:test module for better test structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Mert Can Altin committed Nov 27, 2024
1 parent 585f7bc commit 16b9e1e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions test/parallel/test-double-tls-server.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
'use strict';
const common = require('../common');
const assert = require('assert');
if (!common.hasCrypto) common.skip('missing crypto');
const fixtures = require('../common/fixtures');
const tls = require('tls');
const net = require('net');
const assert = require('node:assert');

if (!common.hasCrypto) common.skip('missing crypto');

const { test } = require('node:test');
const tls = require('node:tls');
const net = require('node:net');

// Sending tls data on a server TLSSocket with an active write led to a crash:
//
Expand All @@ -27,7 +30,7 @@ const net = require('net');

const serverReplaySize = 2 * 1024 * 1024;

(async function() {
test('TLS double handshake test', async (t) => {
const tlsClientHello = await getClientHello();

const subserver = tls.createServer({
Expand Down Expand Up @@ -57,8 +60,7 @@ const serverReplaySize = 2 * 1024 * 1024;
subserver.emit('connection', serverTlsSock);
});


function startClient() {
async function startClient() {
const clientTlsSock = tls.connect({
host: '127.0.0.1',
port: server.address().port,
Expand All @@ -81,7 +83,7 @@ const serverReplaySize = 2 * 1024 * 1024;
// In reality, one may want to send a HTTP CONNECT before starting this double TLS
clientTlsSock.write(tlsClientHello);
}
})().then(common.mustCall());
});

function getClientHello() {
return new Promise((resolve) => {
Expand Down

0 comments on commit 16b9e1e

Please sign in to comment.