@@ -8,14 +8,15 @@ import type { PeerId } from '@libp2p/interface-peer-id'
8
8
import { mockMultiaddrConnection } from './multiaddr-connection.js'
9
9
import type { Registrar } from '@libp2p/interface-registrar'
10
10
import { mockRegistrar } from './registrar.js'
11
- import { Dialer , Listener } from '@libp2p/multistream-select'
11
+ import * as mss from '@libp2p/multistream-select'
12
12
import { logger } from '@libp2p/logger'
13
13
import * as STATUS from '@libp2p/interface-connection/status'
14
14
import type { Multiaddr } from '@multiformats/multiaddr'
15
15
import type { StreamMuxer } from '@libp2p/interface-stream-muxer'
16
16
import type { Components } from '@libp2p/components'
17
17
import type { AbortOptions } from '@libp2p/interfaces'
18
18
import errCode from 'err-code'
19
+ import type { Uint8ArrayList } from 'uint8arraylist'
19
20
20
21
const log = logger ( 'libp2p:mock-connection' )
21
22
@@ -79,8 +80,7 @@ class MockConnection implements Connection {
79
80
80
81
const id = `${ Math . random ( ) } `
81
82
const stream : Stream = this . muxer . newStream ( id )
82
- const mss = new Dialer ( stream )
83
- const result = await mss . select ( protocols , options )
83
+ const result = await mss . select ( stream , protocols , options )
84
84
85
85
const streamWithProtocol : Stream = {
86
86
...stream ,
@@ -130,9 +130,8 @@ export function mockConnection (maConn: MultiaddrConnection, opts: MockConnectio
130
130
const muxer = muxerFactory . createStreamMuxer ( {
131
131
direction : direction ,
132
132
onIncomingStream : ( muxedStream ) => {
133
- const mss = new Listener ( muxedStream )
134
133
try {
135
- mss . handle ( registrar . getProtocols ( ) )
134
+ mss . handle ( muxedStream , registrar . getProtocols ( ) )
136
135
. then ( ( { stream, protocol } ) => {
137
136
log ( '%s: incoming stream opened on %s' , direction , protocol )
138
137
muxedStream = { ...muxedStream , ...stream }
@@ -169,7 +168,7 @@ export function mockConnection (maConn: MultiaddrConnection, opts: MockConnectio
169
168
return connection
170
169
}
171
170
172
- export function mockStream ( stream : Duplex < Uint8Array > ) : Stream {
171
+ export function mockStream ( stream : Duplex < Uint8ArrayList , Uint8ArrayList | Uint8Array > ) : Stream {
173
172
return {
174
173
...stream ,
175
174
close : ( ) => { } ,
0 commit comments