|
1 | | -// eslint-disable-next-line import/no-nodejs-modules |
2 | | -import NodeStream from 'node:stream'; |
3 | | -import ReadableStream, { Transform } from 'readable-stream'; |
| 1 | +import { Transform } from 'readable-stream'; |
4 | 2 |
|
5 | 3 | import type { JsonRpcNotification, JsonRpcRequest } from '@metamask/utils'; |
6 | 4 | import createDupeReqFilterStream, { |
@@ -323,69 +321,4 @@ describe('createDupeReqFilterStream', () => { |
323 | 321 |
|
324 | 322 | expect(output).toEqual(expectedOutputBeforeExpiryTime); |
325 | 323 | }); |
326 | | - |
327 | | - [ |
328 | | - ['node:stream', NodeStream] as [string, typeof NodeStream], |
329 | | - // Redundantly include used version twice for regression-detection purposes |
330 | | - ['readable-stream', ReadableStream] as [string, typeof ReadableStream], |
331 | | - ].forEach(([name, streamsImpl]) => { |
332 | | - describe(`Using Streams implementation: ${name}`, () => { |
333 | | - [ |
334 | | - ['Duplex', streamsImpl.Duplex] as [string, typeof streamsImpl.Duplex], |
335 | | - ['Transform', streamsImpl.Transform] as [ |
336 | | - string, |
337 | | - typeof streamsImpl.Transform, |
338 | | - ], |
339 | | - ['Writable', streamsImpl.Writable] as [ |
340 | | - string, |
341 | | - typeof streamsImpl.Writable, |
342 | | - ], |
343 | | - ].forEach(([className, S]) => { |
344 | | - it(`handles a mix of request types coming through a ${className} stream`, async () => { |
345 | | - const requests = [ |
346 | | - { id: 1, method: 'foo' }, |
347 | | - { method: 'notify1' }, |
348 | | - { id: 1, method: 'foo' }, |
349 | | - { id: 2, method: 'bar' }, |
350 | | - { method: 'notify2' }, |
351 | | - { id: 2, method: 'bar' }, |
352 | | - { id: 3, method: 'baz' }, |
353 | | - ]; |
354 | | - |
355 | | - const expectedOutput = [ |
356 | | - { id: 1, method: 'foo' }, |
357 | | - { method: 'notify1' }, |
358 | | - { id: 2, method: 'bar' }, |
359 | | - { method: 'notify2' }, |
360 | | - { id: 3, method: 'baz' }, |
361 | | - ]; |
362 | | - |
363 | | - const output: JsonRpcRequest[] = []; |
364 | | - const testStream = createDupeReqFilterStream(); |
365 | | - const testOutStream = new S({ |
366 | | - transform: (chunk: JsonRpcRequest, _, cb) => { |
367 | | - output.push(chunk); |
368 | | - cb(); |
369 | | - }, |
370 | | - objectMode: true, |
371 | | - }); |
372 | | - |
373 | | - testOutStream._write = ( |
374 | | - chunk: JsonRpcRequest, |
375 | | - _: BufferEncoding, |
376 | | - callback: (error?: Error | null) => void, |
377 | | - ) => { |
378 | | - output.push(chunk); |
379 | | - callback(); |
380 | | - }; |
381 | | - |
382 | | - testStream.pipe(testOutStream); |
383 | | - |
384 | | - requests.forEach((request) => testStream.write(request)); |
385 | | - |
386 | | - expect(output).toEqual(expectedOutput); |
387 | | - }); |
388 | | - }); |
389 | | - }); |
390 | | - }); |
391 | 324 | }); |
0 commit comments