File tree 1 file changed +59
-0
lines changed
1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common' ) ;
4
+ if ( ! common . hasCrypto )
5
+ common . skip ( 'missing crypto' ) ;
6
+
7
+ const http2 = require ( 'http2' ) ;
8
+
9
+ const server = http2 . createServer ( ) ;
10
+ server . on ( 'stream' , ( stream ) => {
11
+ stream . respond ( ) ;
12
+ stream . end ( 'ok' ) ;
13
+ } ) ;
14
+
15
+ const types = {
16
+ boolean : true ,
17
+ function : ( ) => { } ,
18
+ number : 1 ,
19
+ object : { } ,
20
+ array : [ ] ,
21
+ null : null ,
22
+ symbol : Symbol ( 'test' )
23
+ } ;
24
+
25
+ server . listen ( 0 , common . mustCall ( ( ) => {
26
+ const client = http2 . connect ( `http://localhost:${ server . address ( ) . port } ` ) ;
27
+
28
+ client . on ( 'connect' , ( ) => {
29
+ const outOfRangeNum = 2 ** 31 ;
30
+ common . expectsError (
31
+ ( ) => client . setNextStreamID ( outOfRangeNum ) ,
32
+ {
33
+ type : RangeError ,
34
+ code : 'ERR_OUT_OF_RANGE' ,
35
+ message : 'The value of "id" is out of range.' +
36
+ ' It must be > 0 and <= 2147483647. Received ' + outOfRangeNum
37
+ }
38
+ ) ;
39
+
40
+ // should throw if something other than number is passed to setNextStreamID
41
+ Object . entries ( types ) . forEach ( ( [ type , value ] ) => {
42
+ if ( type === 'number' ) {
43
+ return ;
44
+ }
45
+
46
+ common . expectsError (
47
+ ( ) => client . setNextStreamID ( value ) ,
48
+ {
49
+ type : TypeError ,
50
+ code : 'ERR_INVALID_ARG_TYPE' ,
51
+ message : 'The "id" argument must be of type number'
52
+ }
53
+ ) ;
54
+ } ) ;
55
+
56
+ server . close ( ) ;
57
+ client . close ( ) ;
58
+ } ) ;
59
+ } ) ) ;
You can’t perform that action at this time.
0 commit comments