3
3
'use strict'
4
4
5
5
const { expect } = require ( 'interface-ipfs-core/src/utils/mocha' )
6
+ const factory = require ( '../utils/factory' )
6
7
const path = require ( 'path' )
7
8
const ipfsExec = require ( '../utils/ipfs-exec' )
8
9
9
- const DaemonFactory = require ( 'ipfsd-ctl' )
10
- const df = DaemonFactory . create ( {
11
- type : 'js' ,
12
- IpfsClient : require ( 'ipfs-http-client' )
13
- } )
14
-
15
- const spawnDaemon = ( ) => df . spawn ( {
16
- exec : path . resolve ( `${ __dirname } /../../src/cli/bin.js` ) ,
17
- args : [ '--enable-namesys-pubsub' ] ,
18
- initOptions : { bits : 512 } ,
19
- config : {
20
- Bootstrap : [ ] ,
21
- Discovery : {
22
- MDNS : {
23
- Enabled : false
24
- } ,
25
- webRTCStar : {
26
- Enabled : false
27
- }
28
- }
29
- }
30
- } )
31
-
32
10
describe ( 'name-pubsub' , ( ) => {
33
11
describe ( 'enabled' , ( ) => {
12
+ const df = factory ( { type : 'js' , args : [ '--enable-namesys-pubsub' ] } )
34
13
let ipfsA
35
14
let ipfsB
36
15
let nodeAId
@@ -44,12 +23,12 @@ describe('name-pubsub', () => {
44
23
// timeout for the before step
45
24
this . timeout ( 80 * 1000 )
46
25
47
- const nodeA = await spawnDaemon ( )
48
- ipfsA = ipfsExec ( nodeA . repoPath )
26
+ const nodeA = await df . spawn ( )
27
+ ipfsA = ipfsExec ( nodeA . path )
49
28
nodes . push ( nodeA )
50
29
51
- const nodeB = await spawnDaemon ( )
52
- ipfsB = ipfsExec ( nodeB . repoPath )
30
+ const nodeB = await df . spawn ( )
31
+ ipfsB = ipfsExec ( nodeB . path )
53
32
nodes . push ( nodeB )
54
33
} )
55
34
@@ -71,7 +50,7 @@ describe('name-pubsub', () => {
71
50
expect ( out ) . to . eql ( `connect ${ bMultiaddr } success\n` )
72
51
} )
73
52
74
- after ( ( ) => Promise . all ( nodes . map ( ( node ) => node . stop ( ) ) ) )
53
+ after ( ( ) => df . clean ( ) )
75
54
76
55
describe ( 'pubsub commands' , ( ) => {
77
56
it ( 'should get enabled state of pubsub' , async function ( ) {
@@ -114,6 +93,7 @@ describe('name-pubsub', () => {
114
93
} )
115
94
116
95
describe ( 'disabled' , ( ) => {
96
+ const df = factory ( { type : 'js' } )
117
97
let ipfsA
118
98
let node
119
99
@@ -123,19 +103,11 @@ describe('name-pubsub', () => {
123
103
// timeout for the before step
124
104
this . timeout ( 80 * 1000 )
125
105
126
- node = await df . spawn ( {
127
- exec : path . resolve ( `${ __dirname } /../../src/cli/bin.js` ) ,
128
- config : { } ,
129
- initOptions : { bits : 512 }
130
- } )
106
+ node = await df . spawn ( )
131
107
ipfsA = ipfsExec ( node . repoPath )
132
108
} )
133
109
134
- after ( ( ) => {
135
- if ( node ) {
136
- return node . stop ( )
137
- }
138
- } )
110
+ after ( ( ) => df . clean ( ) )
139
111
140
112
it ( 'should get disabled state of pubsub' , async function ( ) {
141
113
const res = await ipfsA ( 'name pubsub state' )
0 commit comments