1
- if ( process . env . INCLUDE_COMPAT_TESTS ) {
2
- const zmq = require ( "./load" )
3
- const { assert} = require ( "chai" )
4
- const { testProtos, uniqAddress} = require ( "../helpers" )
5
- const http = require ( "http" )
1
+ import * as zmq from "../../../v5-compat"
2
+ import { assert } from "chai"
3
+ import { uniqAddress } from "../helpers"
4
+ import http from "http"
6
5
6
+ if ( process . env . INCLUDE_COMPAT_TESTS ) {
7
7
describe ( "compat socket stream" , function ( ) {
8
- it ( "should support a stream socket type" , function ( done ) {
8
+ it ( "should support a stream socket type" , async function ( done ) {
9
9
const stream = zmq . socket ( "stream" )
10
- const address = uniqAddress ( "tcp" )
10
+ const address = await uniqAddress ( "tcp" )
11
11
12
- stream . on ( "message" , function ( id , msg ) {
12
+ stream . on ( "message" , function ( id : string , msg : string ) {
13
13
assert . instanceOf ( msg , Buffer )
14
14
if ( msg . length == 0 ) {
15
15
return
@@ -37,7 +37,7 @@ if (process.env.INCLUDE_COMPAT_TESTS) {
37
37
stream . send ( [ id , httpProtocolString ] )
38
38
} )
39
39
40
- stream . bind ( address , err => {
40
+ stream . bind ( address , ( err : Error | undefined ) => {
41
41
if ( err ) {
42
42
throw err
43
43
}
@@ -46,9 +46,10 @@ if (process.env.INCLUDE_COMPAT_TESTS) {
46
46
http . get (
47
47
`${ address . replace ( "tcp:" , "http:" ) } /aRandomRequestPath` ,
48
48
function ( httpMsg ) {
49
+ // @ts -expect-error
49
50
assert . equal ( httpMsg . socket . _readableState . reading , false )
50
51
51
- httpMsg . on ( "data" , function ( msg ) {
52
+ httpMsg . on ( "data" , function ( msg : string ) {
52
53
assert . instanceOf ( msg , Buffer )
53
54
assert . equal (
54
55
msg . toString ( ) ,
0 commit comments