Skip to content

Commit ca97be5

Browse files
BridgeARtargos
authored andcommitted
test: fix wrong error classes passed in as type
Backport-PR-URL: #19579 PR-URL: #13686 Fixes: #13682 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 44b12c1 commit ca97be5

10 files changed

+35
-11
lines changed

test/parallel/test-crypto-sign-verify.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ common.expectsError(
3636
}, ''),
3737
{
3838
code: 'ERR_INVALID_OPT_VALUE',
39-
type: Error,
39+
type: TypeError,
4040
message: 'The value "undefined" is invalid for option "padding"'
4141
});
4242

@@ -47,7 +47,7 @@ common.expectsError(
4747
}, ''),
4848
{
4949
code: 'ERR_INVALID_OPT_VALUE',
50-
type: Error,
50+
type: TypeError,
5151
message: 'The value "undefined" is invalid for option "saltLength"'
5252
});
5353

test/parallel/test-http2-client-http1-server.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
'use strict';
2+
// Flags: --expose-internals
23

34
const common = require('../common');
45
if (!common.hasCrypto)
56
common.skip('missing crypto');
67

78
const http = require('http');
89
const http2 = require('http2');
10+
const { NghttpError } = require('internal/http2/util');
911

1012
// Creating an http1 server here...
1113
const server = http.createServer(common.mustNotCall());
@@ -18,13 +20,14 @@ server.listen(0, common.mustCall(() => {
1820

1921
req.on('error', common.expectsError({
2022
code: 'ERR_HTTP2_ERROR',
21-
type: Error,
23+
type: NghttpError,
2224
message: 'Protocol error'
2325
}));
2426

2527
client.on('error', common.expectsError({
2628
code: 'ERR_HTTP2_ERROR',
27-
type: Error,
29+
type: NghttpError,
30+
name: 'Error [ERR_HTTP2_ERROR]',
2831
message: 'Protocol error'
2932
}));
3033

test/parallel/test-http2-client-onconnect-errors.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
// Flags: --expose-internals
23

34
const common = require('../common');
45
if (!common.hasCrypto)
@@ -10,6 +11,7 @@ const {
1011
nghttp2ErrorString
1112
} = process.binding('http2');
1213
const http2 = require('http2');
14+
const { NghttpError } = require('internal/http2/util');
1315

1416
// tests error handling within requestOnConnect
1517
// - NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE (should emit session error)
@@ -51,7 +53,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
5153
ngError: constants[key],
5254
error: {
5355
code: 'ERR_HTTP2_ERROR',
54-
type: Error,
56+
type: NghttpError,
57+
name: 'Error [ERR_HTTP2_ERROR]',
5558
message: nghttp2ErrorString(constants[key])
5659
},
5760
type: 'session'

test/parallel/test-http2-info-headers-errors.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
// Flags: --expose-internals
23

34
const common = require('../common');
45
if (!common.hasCrypto)
@@ -9,6 +10,7 @@ const {
910
Http2Stream,
1011
nghttp2ErrorString
1112
} = process.binding('http2');
13+
const { NghttpError } = require('internal/http2/util');
1214

1315
// tests error handling within additionalHeaders
1416
// - every other NGHTTP2 error from binding (should emit stream error)
@@ -24,7 +26,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
2426
ngError: constants[key],
2527
error: {
2628
code: 'ERR_HTTP2_ERROR',
27-
type: Error,
29+
type: NghttpError,
30+
name: 'Error [ERR_HTTP2_ERROR]',
2831
message: nghttp2ErrorString(constants[key])
2932
},
3033
type: 'stream'

test/parallel/test-http2-misbehaving-multiplex.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
// Flags: --expose-internals
23

34
const common = require('../common');
45

@@ -7,6 +8,7 @@ if (!common.hasCrypto)
78

89
const h2 = require('http2');
910
const net = require('net');
11+
const { NghttpError } = require('internal/http2/util');
1012
const h2test = require('../common/http2');
1113
let client;
1214

@@ -25,7 +27,7 @@ server.on('stream', common.mustCall((stream) => {
2527
server.on('session', common.mustCall((session) => {
2628
session.on('error', common.expectsError({
2729
code: 'ERR_HTTP2_ERROR',
28-
type: Error,
30+
type: NghttpError,
2931
message: 'Stream was already closed or invalid'
3032
}));
3133
}));

test/parallel/test-http2-respond-errors.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
// Flags: --expose-internals
23

34
const common = require('../common');
45
if (!common.hasCrypto)
@@ -9,6 +10,7 @@ const {
910
Http2Stream,
1011
nghttp2ErrorString
1112
} = process.binding('http2');
13+
const { NghttpError } = require('internal/http2/util');
1214

1315
// tests error handling within respond
1416
// - every other NGHTTP2 error from binding (should emit stream error)
@@ -25,7 +27,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
2527
ngError: constants[key],
2628
error: {
2729
code: 'ERR_HTTP2_ERROR',
28-
type: Error,
30+
type: NghttpError,
31+
name: 'Error [ERR_HTTP2_ERROR]',
2932
message: nghttp2ErrorString(constants[key])
3033
},
3134
type: 'stream'

test/parallel/test-http2-respond-with-fd-errors.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
// Flags: --expose-internals
23

34
const common = require('../common');
45

@@ -14,6 +15,7 @@ const {
1415
Http2Stream,
1516
nghttp2ErrorString
1617
} = process.binding('http2');
18+
const { NghttpError } = require('internal/http2/util');
1719

1820
// tests error handling within processRespondWithFD
1921
// (called by respondWithFD & respondWithFile)
@@ -32,7 +34,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
3234
ngError: constants[key],
3335
error: {
3436
code: 'ERR_HTTP2_ERROR',
35-
type: Error,
37+
type: NghttpError,
38+
name: 'Error [ERR_HTTP2_ERROR]',
3639
message: nghttp2ErrorString(constants[key])
3740
},
3841
type: 'stream'

test/parallel/test-http2-server-http1-client.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
// Flags: --expose-internals
23

34
const common = require('../common');
45

@@ -7,14 +8,15 @@ if (!common.hasCrypto)
78

89
const http = require('http');
910
const http2 = require('http2');
11+
const { NghttpError } = require('internal/http2/util');
1012

1113
const server = http2.createServer();
1214
server.on('stream', common.mustNotCall());
1315
server.on('session', common.mustCall((session) => {
1416
session.on('close', common.mustCall());
1517
session.on('error', common.expectsError({
1618
code: 'ERR_HTTP2_ERROR',
17-
type: Error,
19+
type: NghttpError,
1820
message: 'Received bad client magic byte string'
1921
}));
2022
}));

test/parallel/test-http2-server-push-stream-errors.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
// Flags: --expose-internals
23

34
const common = require('../common');
45
if (!common.hasCrypto)
@@ -9,6 +10,7 @@ const {
910
Http2Stream,
1011
nghttp2ErrorString
1112
} = process.binding('http2');
13+
const { NghttpError } = require('internal/http2/util');
1214

1315
// tests error handling within pushStream
1416
// - NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE (should emit session error)
@@ -49,7 +51,8 @@ const genericTests = Object.getOwnPropertyNames(constants)
4951
ngError: constants[key],
5052
error: {
5153
code: 'ERR_HTTP2_ERROR',
52-
type: Error,
54+
type: NghttpError,
55+
name: 'Error [ERR_HTTP2_ERROR]',
5356
message: nghttp2ErrorString(constants[key])
5457
},
5558
type: 'stream'

test/parallel/test-ttywrap-invalid-fd.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
'use strict';
2+
// Flags: --expose-internals
3+
24
const common = require('../common');
35
const assert = require('assert');
46
const fs = require('fs');

0 commit comments

Comments
 (0)