@@ -32,6 +32,8 @@ function assertAllMultiaddrsHaveSamePort (addrs: Multiaddr[]): void {
3232 }
3333}
3434
35+ const LISTEN_SUPPORTED = isNode || isElectronMain
36+
3537describe ( 'WebRTCDirect Transport' , ( ) => {
3638 let components : WebRTCDirectTransportComponents
3739 let listener : Listener
@@ -68,9 +70,11 @@ describe('WebRTCDirect Transport', () => {
6870
6971 await start ( transport )
7072
71- listener = transport . createListener ( {
72- upgrader
73- } )
73+ if ( LISTEN_SUPPORTED ) {
74+ listener = transport . createListener ( {
75+ upgrader
76+ } )
77+ }
7478 } )
7579
7680 afterEach ( async ( ) => {
@@ -102,14 +106,21 @@ describe('WebRTCDirect Transport', () => {
102106 multiaddr ( '/ip4/1.2.3.4/udp/1234/certhash/uEiAUqV7kzvM1wI5DYDc1RbcekYVmXli_Qprlw3IkiEg6tQ/p2p/12D3KooWGDMwwqrpcYKpKCgxuKT2NfqPqa94QnkoBBpqvCaiCzWd' )
103107 ]
104108
105- expect ( transport . listenFilter ( [
106- ...valid ,
107- ...invalid
108- ] ) ) . to . deep . equal ( valid )
109+ if ( LISTEN_SUPPORTED ) {
110+ expect ( transport . listenFilter ( [
111+ ...valid ,
112+ ...invalid
113+ ] ) ) . to . deep . equal ( valid )
114+ } else {
115+ expect ( transport . listenFilter ( [
116+ ...valid ,
117+ ...invalid
118+ ] ) ) . to . be . empty ( )
119+ }
109120 } )
110121
111122 it ( 'can listen on ipv4 and ipv6 on the same port in series' , async function ( ) {
112- if ( ( ! isNode && ! isElectronMain ) || ! supportsIpV6 ( ) ) {
123+ if ( ! LISTEN_SUPPORTED || ! supportsIpV6 ( ) ) {
113124 return this . skip ( )
114125 }
115126
@@ -125,7 +136,7 @@ describe('WebRTCDirect Transport', () => {
125136 } )
126137
127138 it ( 'can listen on ipv4 and ipv6 on the same port in parallel' , async function ( ) {
128- if ( ( ! isNode && ! isElectronMain ) || ! supportsIpV6 ( ) ) {
139+ if ( ! LISTEN_SUPPORTED || ! supportsIpV6 ( ) ) {
129140 return this . skip ( )
130141 }
131142
@@ -143,7 +154,7 @@ describe('WebRTCDirect Transport', () => {
143154 } )
144155
145156 it ( 'can listen on wildcard IPv4 hosts' , async function ( ) {
146- if ( ( ! isNode && ! isElectronMain ) || ! supportsIpV6 ( ) ) {
157+ if ( ! LISTEN_SUPPORTED || ! supportsIpV6 ( ) ) {
147158 return this . skip ( )
148159 }
149160
@@ -168,7 +179,7 @@ describe('WebRTCDirect Transport', () => {
168179 } )
169180
170181 it ( 'can listen on wildcard IPv6 hosts' , async function ( ) {
171- if ( ( ! isNode && ! isElectronMain ) || ! supportsIpV6 ( ) ) {
182+ if ( ! LISTEN_SUPPORTED || ! supportsIpV6 ( ) ) {
172183 return this . skip ( )
173184 }
174185
@@ -193,7 +204,7 @@ describe('WebRTCDirect Transport', () => {
193204 } )
194205
195206 it ( 'should add certificate to announce addresses' , async function ( ) {
196- if ( ( ! isNode && ! isElectronMain ) || ! supportsIpV6 ( ) ) {
207+ if ( ! LISTEN_SUPPORTED || ! supportsIpV6 ( ) ) {
197208 return this . skip ( )
198209 }
199210
@@ -225,7 +236,7 @@ describe('WebRTCDirect Transport', () => {
225236 } )
226237
227238 it ( 'can start listeners for two nodes on wildcard socket addresses' , async function ( ) {
228- if ( ( ! isNode && ! isElectronMain ) || ! supportsIpV6 ( ) ) {
239+ if ( ! LISTEN_SUPPORTED || ! supportsIpV6 ( ) ) {
229240 return this . skip ( )
230241 }
231242
@@ -268,7 +279,7 @@ describe('WebRTCDirect Transport', () => {
268279 } )
269280
270281 it ( 'can start multiple wildcard listeners' , async function ( ) {
271- if ( ( ! isNode && ! isElectronMain ) || ! supportsIpV6 ( ) ) {
282+ if ( ! LISTEN_SUPPORTED || ! supportsIpV6 ( ) ) {
272283 return this . skip ( )
273284 }
274285
0 commit comments