Skip to content

Commit adc6776

Browse files
aduh95RafaelGSS
authored andcommitted
test: ensure assertions are reached on HTTP2 tests
PR-URL: #60730 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 3dae49c commit adc6776

84 files changed

Lines changed: 315 additions & 324 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎test/eslint.config_partial.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export default [
195195
`test/parallel/test-{${
196196
// 0x61 is code for 'a', this generates a string enumerating latin letters: 'a*,b*,…'
197197
Array.from({length: 4},(_,i)=>String.fromCharCode(0x61+i,42)).join(',')
198-
},http-*,${
198+
},http-*,http2-*,${
199199
// 0x61 is code for 'a', this generates a string enumerating latin letters: 'z*,y*,…'
200200
Array.from({length: 5},(_,i)=>String.fromCharCode(0x61+25-i,42)).join(',')
201201
}}.{js,mjs,cjs}`,

‎test/parallel/test-http2-alpn.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const tls = require('tls');
3434
})
3535
);
3636

37-
server.listen(0,function(){
37+
server.listen(0,common.mustCall(()=>{
3838
constclient=tls.connect({
3939
port: server.address().port,
4040
rejectUnauthorized: false,
@@ -43,5 +43,5 @@ const tls = require('tls');
4343
assert.strictEqual(client.alpnProtocol,'a');
4444
client.end();
4545
}));
46-
});
46+
}));
4747
}

‎test/parallel/test-http2-async-local-storage.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ server.on('stream', (stream) => {
2525
stream.end('data');
2626
});
2727

28-
server.listen(0,async()=>{
28+
server.listen(0,common.mustCall(async()=>{
2929
constclient=storage.run({id: 0},()=>http2.connect(`http://localhost:${server.address().port}`));
3030

3131
asyncfunctiondoReq(id){
@@ -52,4 +52,4 @@ server.listen(0, async () => {
5252

5353
doReqWith(1);
5454
doReqWith(2);
55-
});
55+
}));

‎test/parallel/test-http2-backpressure.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { duplexPair } = require('stream');
1212
{
1313
letreq;
1414
constserver=http2.createServer();
15-
server.on('stream',mustCallAsync(async(stream,headers)=>{
15+
server.on('stream',mustCall(async(stream,headers)=>{
1616
stream.respond({
1717
'content-type': 'text/html',
1818
':status': 200
@@ -46,7 +46,7 @@ function event(ee, eventName) {
4646
});
4747
}
4848

49-
functionmustCallAsync(fn,exact){
49+
functionmustCall(fn,exact){
5050
returncommon.mustCall((...args)=>{
5151
returnPromise.resolve(fn(...args)).then(common.mustCall((val)=>val));
5252
},exact);

‎test/parallel/test-http2-cancel-while-client-reading.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ server.on('stream', common.mustCall(function(stream) {
2323
stream.on('error',()=>{});
2424
}));
2525

26-
server.listen(0,function(){
26+
server.listen(0,common.mustCall(()=>{
2727
constclient=http2.connect(`https://localhost:${server.address().port}`,
2828
{rejectUnauthorized: false}
2929
);
@@ -34,4 +34,4 @@ server.listen(0, function() {
3434
}));
3535
client_stream.resume();
3636
client_stream.write(Buffer.alloc(1024*1024));
37-
});
37+
}));

‎test/parallel/test-http2-clean-output.js‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ const {
88
if(!hasCrypto)
99
skip('missing crypto');
1010

11-
const{
12-
strictEqual
13-
}=require('assert');
11+
constassert=require('assert');
1412
const{
1513
createServer,
1614
connect
@@ -25,9 +23,9 @@ if (process.argv[2] !== 'child') {
2523
const{
2624
stdout, stderr, status
2725
}=spawnSync(process.execPath,[__filename,'child'],{encoding: 'utf8'});
28-
strictEqual(stderr,'');
29-
strictEqual(stdout,'');
30-
strictEqual(status,0);
26+
assert.strictEqual(stderr,'');
27+
assert.strictEqual(stdout,'');
28+
assert.strictEqual(status,0);
3129
}else{
3230
constserver=createServer();
3331
server.listen(0,mustCall(()=>{

‎test/parallel/test-http2-client-data-end.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ const Countdown = require('../common/countdown');
1010
constserver=http2.createServer();
1111
server.on('stream',common.mustCall((stream,headers,flags)=>{
1212
if(headers[':path']==='/'){
13-
stream.pushStream({':path': '/foobar'},(err,push,headers)=>{
14-
assert.ifError(err);
13+
stream.pushStream({':path': '/foobar'},common.mustSucceed((push,headers)=>{
1514
push.respond({
1615
'content-type': 'text/html',
1716
'x-push-data': 'pushed by server',
1817
});
1918
push.write('pushed by server ');
2019
setImmediate(()=>push.end('data'));
2120
stream.end('st');
22-
});
21+
}));
2322
}
2423
stream.respond({'content-type': 'text/html'});
2524
stream.write('te');

‎test/parallel/test-http2-client-destroy.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ const { getEventListeners } = require('events');
8686

8787
// Wait for setImmediate call from destroy() to complete
8888
// so that state.destroyed is set to true
89-
setImmediate(()=>{
89+
setImmediate(common.mustCall(()=>{
9090
assert.throws(()=>client.setNextStreamID(),sessionError);
9191
assert.throws(()=>client.setLocalWindowSize(),sessionError);
9292
assert.throws(()=>client.ping(),sessionError);
9393
assert.throws(()=>client.settings({}),sessionError);
9494
assert.throws(()=>client.goaway(),sessionError);
9595
assert.throws(()=>client.request(),sessionError);
9696
client.close();// Should be a non-op at this point
97-
});
97+
}));
9898

9999
req.resume();
100100
req.on('end',common.mustNotCall());

‎test/parallel/test-http2-client-jsstream-destroy.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ server.listen(0, common.mustCall(function() {
3939
host: 'localhost',
4040
port: this.address().port,
4141
ALPNProtocols: ['h2']
42-
},()=>{
42+
},common.mustCall(()=>{
4343
constproxy=newJSSocket(socket);
4444
constclient=h2.connect(`https://localhost:${this.address().port}`,{
4545
createConnection: ()=>proxy
@@ -54,5 +54,5 @@ server.listen(0, common.mustCall(function() {
5454
client.close();
5555
server.close();
5656
}));
57-
});
57+
}));
5858
}));

‎test/parallel/test-http2-client-request-options-errors.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ server.listen(0, common.mustCall(() => {
3232
constport=server.address().port;
3333
constclient=http2.connect(`http://localhost:${port}`);
3434

35-
client.on('connect',()=>{
35+
client.on('connect',common.mustCall(()=>{
3636
Object.keys(optionsToTest).forEach((option)=>{
3737
Object.keys(types).forEach((type)=>{
3838
if(type===optionsToTest[option])
@@ -52,5 +52,5 @@ server.listen(0, common.mustCall(() => {
5252
});
5353
server.close();
5454
client.close();
55-
});
55+
}));
5656
}));

0 commit comments

Comments
 (0)