mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test: remove unused common utilities
PR-URL: https://github.com/nodejs/node/pull/54825 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
parent
a9081b5391
commit
5116578b8a
@ -853,24 +853,6 @@ socket.write(frame.data);
|
||||
|
||||
The serialized `Buffer` may be retrieved using the `frame.data` property.
|
||||
|
||||
### Class: DataFrame extends Frame
|
||||
|
||||
The `http2.DataFrame` is a subclass of `http2.Frame` that serializes a `DATA`
|
||||
frame.
|
||||
|
||||
<!-- eslint-disable no-undef, node-core/require-common-first, node-core/required-modules -->
|
||||
|
||||
```js
|
||||
// id is the 32-bit stream identifier
|
||||
// payload is a Buffer containing the DATA payload
|
||||
// padlen is an 8-bit integer giving the number of padding bytes to include
|
||||
// final is a boolean indicating whether the End-of-stream flag should be set,
|
||||
// defaults to false.
|
||||
const frame = new http2.DataFrame(id, payload, padlen, final);
|
||||
|
||||
socket.write(frame.data);
|
||||
```
|
||||
|
||||
### Class: HeadersFrame
|
||||
|
||||
The `http2.HeadersFrame` is a subclass of `http2.Frame` that serializes a
|
||||
@ -1138,19 +1120,6 @@ are likely sufficient to hold a single file of `size` bytes. This is useful for
|
||||
skipping tests that require hundreds of megabytes or even gigabytes of temporary
|
||||
files, but it is inaccurate and susceptible to race conditions.
|
||||
|
||||
## UDP pair helper
|
||||
|
||||
The `common/udppair` module exports a function `makeUDPPair` and a class
|
||||
`FakeUDPWrap`.
|
||||
|
||||
`FakeUDPWrap` emits `'send'` events when data is to be sent on it, and provides
|
||||
an `emitReceived()` API for actin as if data has been received on it.
|
||||
|
||||
`makeUDPPair` returns an object `{ clientSide, serverSide }` where each side
|
||||
is an `FakeUDPWrap` connected to the other side.
|
||||
|
||||
There is no difference between client or server side beyond their names.
|
||||
|
||||
## WPT module
|
||||
|
||||
### `harness`
|
||||
|
@ -33,23 +33,6 @@ const modp2buf = Buffer.from([
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
]);
|
||||
|
||||
function testDH({ publicKey: alicePublicKey, privateKey: alicePrivateKey },
|
||||
{ publicKey: bobPublicKey, privateKey: bobPrivateKey },
|
||||
expectedValue) {
|
||||
const buf1 = crypto.diffieHellman({
|
||||
privateKey: alicePrivateKey,
|
||||
publicKey: bobPublicKey,
|
||||
});
|
||||
const buf2 = crypto.diffieHellman({
|
||||
privateKey: bobPrivateKey,
|
||||
publicKey: alicePublicKey,
|
||||
});
|
||||
assert.deepStrictEqual(buf1, buf2);
|
||||
|
||||
if (expectedValue !== undefined)
|
||||
assert.deepStrictEqual(buf1, expectedValue);
|
||||
}
|
||||
|
||||
// Asserts that the size of the given key (in chars or bytes) is within 10% of
|
||||
// the expected size.
|
||||
function assertApproximateSize(key, expectedSize) {
|
||||
@ -117,7 +100,6 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
|
||||
|
||||
module.exports = {
|
||||
modp2buf,
|
||||
testDH,
|
||||
assertApproximateSize,
|
||||
testEncryptDecrypt,
|
||||
testSignVerify,
|
||||
|
@ -81,24 +81,6 @@ class SettingsFrame extends Frame {
|
||||
}
|
||||
}
|
||||
|
||||
class DataFrame extends Frame {
|
||||
constructor(id, payload, padlen = 0, final = false) {
|
||||
let len = payload.length;
|
||||
let flags = 0;
|
||||
if (final) flags |= FLAG_EOS;
|
||||
const buffers = [payload];
|
||||
if (padlen > 0) {
|
||||
buffers.unshift(Buffer.from([padlen]));
|
||||
buffers.push(PADDING.slice(0, padlen));
|
||||
len += padlen + 1;
|
||||
flags |= FLAG_PADDED;
|
||||
}
|
||||
super(len, 0, flags, id);
|
||||
buffers.unshift(this[kFrameData]);
|
||||
this[kFrameData] = Buffer.concat(buffers);
|
||||
}
|
||||
}
|
||||
|
||||
class HeadersFrame extends Frame {
|
||||
constructor(id, payload, padlen = 0, final = false) {
|
||||
let len = payload.length;
|
||||
@ -138,7 +120,6 @@ class AltSvcFrame extends Frame {
|
||||
module.exports = {
|
||||
Frame,
|
||||
AltSvcFrame,
|
||||
DataFrame,
|
||||
HeadersFrame,
|
||||
SettingsFrame,
|
||||
PingFrame,
|
||||
|
@ -1,5 +1,4 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
|
||||
module.exports = function tick(x, cb) {
|
||||
function ontick() {
|
||||
|
@ -1,101 +0,0 @@
|
||||
'use strict';
|
||||
const { internalBinding } = require('internal/test/binding');
|
||||
const { JSUDPWrap } = internalBinding('js_udp_wrap');
|
||||
const EventEmitter = require('events');
|
||||
|
||||
// FakeUDPWrap is a testing utility that emulates a UDP connection
|
||||
// for the sake of making UDP tests more deterministic.
|
||||
class FakeUDPWrap extends EventEmitter {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this._handle = new JSUDPWrap();
|
||||
|
||||
this._handle.onreadstart = () => this._startReading();
|
||||
this._handle.onreadstop = () => this._stopReading();
|
||||
this._handle.onwrite =
|
||||
(wrap, buffers, addr) => this._write(wrap, buffers, addr);
|
||||
this._handle.getsockname = (obj) => {
|
||||
Object.assign(obj, { address: '127.0.0.1', family: 'IPv4', port: 1337 });
|
||||
return 0;
|
||||
};
|
||||
|
||||
this.reading = false;
|
||||
this.bufferedReceived = [];
|
||||
this.emitBufferedImmediate = null;
|
||||
}
|
||||
|
||||
_emitBuffered = () => {
|
||||
if (!this.reading) return;
|
||||
if (this.bufferedReceived.length > 0) {
|
||||
this.emitReceived(this.bufferedReceived.shift());
|
||||
this.emitBufferedImmediate = setImmediate(this._emitBuffered);
|
||||
} else {
|
||||
this.emit('wantRead');
|
||||
}
|
||||
};
|
||||
|
||||
_startReading() {
|
||||
this.reading = true;
|
||||
this.emitBufferedImmediate = setImmediate(this._emitBuffered);
|
||||
}
|
||||
|
||||
_stopReading() {
|
||||
this.reading = false;
|
||||
clearImmediate(this.emitBufferedImmediate);
|
||||
}
|
||||
|
||||
_write(wrap, buffers, addr) {
|
||||
this.emit('send', { buffers, addr });
|
||||
setImmediate(() => this._handle.onSendDone(wrap, 0));
|
||||
}
|
||||
|
||||
afterBind() {
|
||||
this._handle.onAfterBind();
|
||||
}
|
||||
|
||||
emitReceived(info) {
|
||||
if (!this.reading) {
|
||||
this.bufferedReceived.push(info);
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
buffers,
|
||||
addr: {
|
||||
family = 4,
|
||||
address = '127.0.0.1',
|
||||
port = 1337,
|
||||
},
|
||||
flags = 0,
|
||||
} = info;
|
||||
|
||||
let familyInt;
|
||||
switch (family) {
|
||||
case 'IPv4': familyInt = 4; break;
|
||||
case 'IPv6': familyInt = 6; break;
|
||||
default: throw new Error('bad family');
|
||||
}
|
||||
|
||||
for (const buffer of buffers) {
|
||||
this._handle.emitReceived(buffer, familyInt, address, port, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function makeUDPPair() {
|
||||
const serverSide = new FakeUDPWrap();
|
||||
const clientSide = new FakeUDPWrap();
|
||||
|
||||
serverSide.on('send',
|
||||
(chk) => setImmediate(() => clientSide.emitReceived(chk)));
|
||||
clientSide.on('send',
|
||||
(chk) => setImmediate(() => serverSide.emitReceived(chk)));
|
||||
|
||||
return { serverSide, clientSide };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
FakeUDPWrap,
|
||||
makeUDPPair,
|
||||
};
|
Loading…
Reference in New Issue
Block a user