@@ -80,43 +80,18 @@ process.setMaxListeners(256);
8080}
8181
8282{
83- const buf = new Uint16Array ( 10 ) ;
84- const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
85- crypto . randomFillSync ( buf ) ;
86- const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
87- assert . notStrictEqual ( before , after ) ;
88- }
89-
90- {
91- const buf = new Uint32Array ( 10 ) ;
92- const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
93- crypto . randomFillSync ( buf ) ;
94- const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
95- assert . notStrictEqual ( before , after ) ;
96- }
97-
98- {
99- const buf = new Float32Array ( 10 ) ;
100- const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
101- crypto . randomFillSync ( buf ) ;
102- const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
103- assert . notStrictEqual ( before , after ) ;
104- }
105-
106- {
107- const buf = new Float64Array ( 10 ) ;
108- const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
109- crypto . randomFillSync ( buf ) ;
110- const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
111- assert . notStrictEqual ( before , after ) ;
112- }
113-
114- {
115- const buf = new DataView ( new ArrayBuffer ( 10 ) ) ;
116- const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
117- crypto . randomFillSync ( buf ) ;
118- const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
119- assert . notStrictEqual ( before , after ) ;
83+ [
84+ new Uint16Array ( 10 ) ,
85+ new Uint32Array ( 10 ) ,
86+ new Float32Array ( 10 ) ,
87+ new Float64Array ( 10 ) ,
88+ new DataView ( new ArrayBuffer ( 10 ) )
89+ ] . forEach ( ( buf ) => {
90+ const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
91+ crypto . randomFillSync ( buf ) ;
92+ const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
93+ assert . notStrictEqual ( before , after ) ;
94+ } ) ;
12095}
12196
12297{
@@ -140,53 +115,20 @@ process.setMaxListeners(256);
140115}
141116
142117{
143- const buf = new Uint16Array ( 10 ) ;
144- const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
145- crypto . randomFill ( buf , common . mustCall ( ( err , buf ) => {
146- assert . ifError ( err ) ;
147- const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
148- assert . notStrictEqual ( before , after ) ;
149- } ) ) ;
150- }
151-
152- {
153- const buf = new Uint32Array ( 10 ) ;
154- const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
155- crypto . randomFill ( buf , common . mustCall ( ( err , buf ) => {
156- assert . ifError ( err ) ;
157- const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
158- assert . notStrictEqual ( before , after ) ;
159- } ) ) ;
160- }
161-
162- {
163- const buf = new Float32Array ( 10 ) ;
164- const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
165- crypto . randomFill ( buf , common . mustCall ( ( err , buf ) => {
166- assert . ifError ( err ) ;
167- const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
168- assert . notStrictEqual ( before , after ) ;
169- } ) ) ;
170- }
171-
172- {
173- const buf = new Float64Array ( 10 ) ;
174- const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
175- crypto . randomFill ( buf , common . mustCall ( ( err , buf ) => {
176- assert . ifError ( err ) ;
177- const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
178- assert . notStrictEqual ( before , after ) ;
179- } ) ) ;
180- }
181-
182- {
183- const buf = new DataView ( new ArrayBuffer ( 10 ) ) ;
184- const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
185- crypto . randomFill ( buf , common . mustCall ( ( err , buf ) => {
186- assert . ifError ( err ) ;
187- const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
188- assert . notStrictEqual ( before , after ) ;
189- } ) ) ;
118+ [
119+ new Uint16Array ( 10 ) ,
120+ new Uint32Array ( 10 ) ,
121+ new Float32Array ( 10 ) ,
122+ new Float64Array ( 10 ) ,
123+ new DataView ( new ArrayBuffer ( 10 ) )
124+ ] . forEach ( ( buf ) => {
125+ const before = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
126+ crypto . randomFill ( buf , common . mustCall ( ( err , buf ) => {
127+ assert . ifError ( err ) ;
128+ const after = Buffer . from ( buf . buffer ) . toString ( 'hex' ) ;
129+ assert . notStrictEqual ( before , after ) ;
130+ } ) ) ;
131+ } ) ;
190132}
191133
192134{
0 commit comments