This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 4 files changed +43
-3
lines changed 4 files changed +43
-3
lines changed Original file line number Diff line number Diff line change 3
3
const IPFSFactory = require ( 'ipfsd-ctl' )
4
4
const MockPreloadNode = require ( './test/utils/mock-preload-node' )
5
5
const EchoServer = require ( 'interface-ipfs-core/src/utils/echo-http-server' )
6
+ const webRTCStarSigServer = require ( 'libp2p-webrtc-star/src/sig-server' )
6
7
7
8
const ipfsdServer = IPFSFactory . createServer ( )
8
9
const preloadNode = MockPreloadNode . createNode ( )
9
10
const echoServer = EchoServer . createServer ( )
11
+ let sigServer
10
12
11
13
module . exports = {
12
14
bundlesize : { maxSize : '652kB' } ,
@@ -42,11 +44,16 @@ module.exports = {
42
44
await ipfsdServer . start ( )
43
45
await preloadNode . start ( )
44
46
await echoServer . start ( )
47
+ sigServer = await webRTCStarSigServer . start ( {
48
+ host : '127.0.0.1' ,
49
+ port : 14579
50
+ } )
45
51
} ,
46
52
post : async ( ) => {
47
53
await ipfsdServer . stop ( )
48
54
await preloadNode . stop ( )
49
55
await echoServer . stop ( )
56
+ await sigServer . stop ( )
50
57
}
51
58
}
52
59
}
Original file line number Diff line number Diff line change @@ -12,7 +12,17 @@ module.exports = ({ peerInfo }) => {
12
12
publicKey : peerInfo . id . pubKey . bytes . toString ( 'base64' ) ,
13
13
addresses : peerInfo . multiaddrs
14
14
. toArray ( )
15
- . map ( ma => `${ ma } /p2p/${ id } ` )
15
+ . map ( ma => {
16
+ const str = ma . toString ( )
17
+
18
+ // some relay-style transports add our peer id to the ma for us
19
+ // so don't double-add
20
+ if ( str . endsWith ( `/p2p/${ id } ` ) ) {
21
+ return str
22
+ }
23
+
24
+ return `${ str } /p2p/${ id } `
25
+ } )
16
26
. sort ( )
17
27
. map ( ma => multiaddr ( ma ) ) ,
18
28
agentVersion : `js-ipfs/${ pkgversion } ` ,
Original file line number Diff line number Diff line change 4
4
const tests = require ( 'interface-ipfs-core' )
5
5
const merge = require ( 'merge-options' )
6
6
const { createFactory } = require ( 'ipfsd-ctl' )
7
- const { isNode } = require ( 'ipfs-utils/src/env' )
7
+ const { isNode, isBrowser } = require ( 'ipfs-utils/src/env' )
8
8
const IPFS = require ( '../../src' )
9
9
10
10
/** @typedef { import("ipfsd-ctl").ControllerOptions } ControllerOptions */
@@ -23,7 +23,16 @@ describe('interface-ipfs-core tests', function () {
23
23
ref : require ( 'ipfs-http-client' )
24
24
} ,
25
25
ipfsOptions : {
26
- pass : 'ipfs-is-awesome-software'
26
+ pass : 'ipfs-is-awesome-software' ,
27
+ ...( isBrowser ? {
28
+ config : {
29
+ Addresses : {
30
+ Swarm : [
31
+ '/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star'
32
+ ]
33
+ }
34
+ }
35
+ } : { } )
27
36
}
28
37
}
29
38
const overrides = {
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
const { createFactory } = require ( 'ipfsd-ctl' )
3
3
const merge = require ( 'merge-options' )
4
+ const { isBrowser } = require ( 'ipfs-utils/src/env' )
4
5
5
6
const factory = ( options , overrides ) => createFactory (
6
7
merge ( {
@@ -18,6 +19,19 @@ const factory = (options, overrides) => createFactory(
18
19
merge ( {
19
20
js : {
20
21
ipfsBin : './src/cli/bin.js'
22
+ } ,
23
+ proc : {
24
+ ...( isBrowser ? {
25
+ ipfsOptions : {
26
+ config : {
27
+ Addresses : {
28
+ Swarm : [
29
+ '/ip4/127.0.0.1/tcp/14579/wss/p2p-webrtc-star'
30
+ ]
31
+ }
32
+ }
33
+ }
34
+ } : { } )
21
35
}
22
36
} , overrides )
23
37
)
You can’t perform that action at this time.
0 commit comments