File tree Expand file tree Collapse file tree 6 files changed +22
-9
lines changed
packages/webrtc-star-transport Expand file tree Collapse file tree 6 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ class WebRTCStarDiscovery extends EventEmitter<PeerDiscoveryEvents> implements P
43
43
this . started = false
44
44
}
45
45
46
- dispatchEvent ( event : Event ) {
46
+ dispatchEvent ( event : CustomEvent ) {
47
47
if ( ! this . isStarted ( ) ) {
48
48
return false
49
49
}
Original file line number Diff line number Diff line change 2
2
3
3
import { WebRTCStar } from '../src/index.js'
4
4
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
5
- import { mockUpgrader } from '@libp2p/interface-compliance-tests/transport/utils '
5
+ import { mockRegistrar , mockUpgrader } from '@libp2p/interface-compliance-tests/mocks '
6
6
import dialTests from './transport/dial.js'
7
7
import listenTests from './transport/listen.js'
8
8
import discoveryTests from './transport/discovery.js'
9
9
import filterTests from './transport/filter.js'
10
+ import { pipe } from 'it-pipe'
10
11
11
12
describe ( 'browser RTC' , ( ) => {
12
13
const create = async ( ) => {
14
+ const protocol = '/echo/1.0.0'
15
+ const registrar = mockRegistrar ( )
16
+ void registrar . handle ( protocol , ( evt ) => {
17
+ void pipe (
18
+ evt . detail . stream ,
19
+ evt . detail . stream
20
+ )
21
+ } )
22
+ const upgrader = mockUpgrader ( {
23
+ registrar
24
+ } )
25
+
13
26
return new WebRTCStar ( {
14
27
peerId : await createEd25519PeerId ( ) ,
15
- upgrader : mockUpgrader ( )
28
+ upgrader
16
29
} )
17
30
}
18
31
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { Multiaddr } from '@multiformats/multiaddr'
7
7
import testsTransport from '@libp2p/interface-compliance-tests/transport'
8
8
import testsDiscovery from '@libp2p/interface-compliance-tests/peer-discovery'
9
9
import { WebRTCStar } from '../src/index.js'
10
- import { mockUpgrader } from '@libp2p/interface-compliance-tests/transport/utils '
10
+ import { mockUpgrader } from '@libp2p/interface-compliance-tests/mocks '
11
11
import pWaitFor from 'p-wait-for'
12
12
import { peerIdFromString } from '@libp2p/peer-id'
13
13
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import wrtc from 'wrtc'
5
5
// @ts -expect-error no types
6
6
import electronWebRTC from 'electron-webrtc'
7
7
import { createEd25519PeerId } from '@libp2p/peer-id-factory'
8
- import { mockUpgrader } from '@libp2p/interface-compliance-tests/transport/utils '
8
+ import { mockUpgrader } from '@libp2p/interface-compliance-tests/mocks '
9
9
import { WebRTCStar } from '../src/index.js'
10
10
import dialTests from './transport/dial.js'
11
11
import listenTests from './transport/listen.js'
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ export default (create: () => Promise<WebRTCStar>) => {
47
47
handler : ( conn ) => {
48
48
expect ( conn . remoteAddr ) . to . exist ( )
49
49
50
- void conn . newStream ( [ 'echo' ] )
50
+ void conn . newStream ( [ '/ echo/1.0.0 ' ] )
51
51
. then ( ( { stream } ) => {
52
52
void pipe ( stream , stream )
53
53
} )
@@ -60,7 +60,7 @@ export default (create: () => Promise<WebRTCStar>) => {
60
60
handler : ( conn ) => {
61
61
expect ( conn . remoteAddr ) . to . exist ( )
62
62
63
- void conn . newStream ( [ 'echo' ] )
63
+ void conn . newStream ( [ '/ echo/1.0.0 ' ] )
64
64
. then ( ( { stream } ) => {
65
65
void pipe ( stream , stream )
66
66
} )
@@ -84,7 +84,7 @@ export default (create: () => Promise<WebRTCStar>) => {
84
84
const [ sigRefs ] = ws2 . sigServers . values ( )
85
85
86
86
const conn = await ws1 . dial ( sigRefs . signallingAddr )
87
- const { stream } = await conn . newStream ( [ 'echo' ] )
87
+ const { stream } = await conn . newStream ( [ '/ echo/1.0.0 ' ] )
88
88
const data = uint8ArrayFromString ( 'some data' )
89
89
const values = await pipe (
90
90
[ data ] ,
Original file line number Diff line number Diff line change 2
2
3
3
import { expect } from 'aegir/utils/chai.js'
4
4
import { WebRTCStar } from '../../src/index.js'
5
- import { mockUpgrader } from '@libp2p/interface-compliance-tests/transport/utils '
5
+ import { mockUpgrader } from '@libp2p/interface-compliance-tests/mocks '
6
6
import { peerIdFromString } from '@libp2p/peer-id'
7
7
8
8
describe ( 'instantiate the transport' , ( ) => {
You can’t perform that action at this time.
0 commit comments