@@ -6,29 +6,27 @@ const chai = require('chai')
6
6
const dirtyChai = require ( 'dirty-chai' )
7
7
const expect = chai . expect
8
8
chai . use ( dirtyChai )
9
- const FactoryClient = require ( './ipfs-factory/client' )
9
+
10
+ const DaemonFactory = require ( 'ipfsd-ctl' )
11
+ const df = DaemonFactory . create ( )
10
12
11
13
const invalidArg = 'this/Is/So/Invalid/'
12
14
const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z'
13
15
14
16
describe ( '.bootstrap' , function ( ) {
15
17
this . timeout ( 100 * 1000 )
16
18
17
- let ipfs
18
- let fc
19
+ let ipfsd
19
20
20
21
before ( ( done ) => {
21
- fc = new FactoryClient ( )
22
- fc . spawnNode ( ( err , node ) => {
22
+ df . spawn ( ( err , node ) => {
23
23
expect ( err ) . to . not . exist ( )
24
- ipfs = node
24
+ ipfsd = node
25
25
done ( )
26
26
} )
27
27
} )
28
28
29
- after ( ( done ) => {
30
- fc . dismantle ( done )
31
- } )
29
+ after ( ( done ) => ipfsd . stop ( done ) )
32
30
33
31
let peers
34
32
@@ -37,14 +35,14 @@ describe('.bootstrap', function () {
37
35
38
36
describe ( '.add' , ( ) => {
39
37
it ( 'returns an error when called with an invalid arg' , ( done ) => {
40
- ipfs . bootstrap . add ( invalidArg , ( err ) => {
38
+ ipfsd . api . bootstrap . add ( invalidArg , ( err ) => {
41
39
expect ( err ) . to . be . an . instanceof ( Error )
42
40
done ( )
43
41
} )
44
42
} )
45
43
46
44
it ( 'returns a list of containing the bootstrap peer when called with a valid arg (ip4)' , ( done ) => {
47
- ipfs . bootstrap . add ( validIp4 , ( err , res ) => {
45
+ ipfsd . api . bootstrap . add ( validIp4 , ( err , res ) => {
48
46
expect ( err ) . to . not . exist ( )
49
47
expect ( res ) . to . be . eql ( { Peers : [ validIp4 ] } )
50
48
peers = res . Peers
@@ -55,7 +53,7 @@ describe('.bootstrap', function () {
55
53
} )
56
54
57
55
it ( 'returns a list of bootstrap peers when called with the default option' , ( done ) => {
58
- ipfs . bootstrap . add ( { default : true } , ( err , res ) => {
56
+ ipfsd . api . bootstrap . add ( { default : true } , ( err , res ) => {
59
57
expect ( err ) . to . not . exist ( )
60
58
peers = res . Peers
61
59
expect ( peers ) . to . exist ( )
@@ -67,7 +65,7 @@ describe('.bootstrap', function () {
67
65
68
66
describe ( '.list' , ( ) => {
69
67
it ( 'returns a list of peers' , ( done ) => {
70
- ipfs . bootstrap . list ( ( err , res ) => {
68
+ ipfsd . api . bootstrap . list ( ( err , res ) => {
71
69
expect ( err ) . to . not . exist ( )
72
70
peers = res . Peers
73
71
expect ( peers ) . to . exist ( )
@@ -78,14 +76,14 @@ describe('.bootstrap', function () {
78
76
79
77
describe ( '.rm' , ( ) => {
80
78
it ( 'returns an error when called with an invalid arg' , ( done ) => {
81
- ipfs . bootstrap . rm ( invalidArg , ( err ) => {
79
+ ipfsd . api . bootstrap . rm ( invalidArg , ( err ) => {
82
80
expect ( err ) . to . be . an . instanceof ( Error )
83
81
done ( )
84
82
} )
85
83
} )
86
84
87
85
it ( 'returns empty list because no peers removed when called without an arg or options' , ( done ) => {
88
- ipfs . bootstrap . rm ( null , ( err , res ) => {
86
+ ipfsd . api . bootstrap . rm ( null , ( err , res ) => {
89
87
expect ( err ) . to . not . exist ( )
90
88
peers = res . Peers
91
89
expect ( peers ) . to . exist ( )
@@ -95,7 +93,7 @@ describe('.bootstrap', function () {
95
93
} )
96
94
97
95
it ( 'returns list containing the peer removed when called with a valid arg (ip4)' , ( done ) => {
98
- ipfs . bootstrap . rm ( null , ( err , res ) => {
96
+ ipfsd . api . bootstrap . rm ( null , ( err , res ) => {
99
97
expect ( err ) . to . not . exist ( )
100
98
peers = res . Peers
101
99
expect ( peers ) . to . exist ( )
@@ -105,7 +103,7 @@ describe('.bootstrap', function () {
105
103
} )
106
104
107
105
it ( 'returns list of all peers removed when all option is passed' , ( done ) => {
108
- ipfs . bootstrap . rm ( null , { all : true } , ( err , res ) => {
106
+ ipfsd . api . bootstrap . rm ( null , { all : true } , ( err , res ) => {
109
107
expect ( err ) . to . not . exist ( )
110
108
peers = res . Peers
111
109
expect ( peers ) . to . exist ( )
@@ -120,21 +118,21 @@ describe('.bootstrap', function () {
120
118
121
119
describe ( '.add' , ( ) => {
122
120
it ( 'returns an error when called without args or options' , ( ) => {
123
- return ipfs . bootstrap . add ( null )
121
+ return ipfsd . api . bootstrap . add ( null )
124
122
. catch ( ( err ) => {
125
123
expect ( err ) . to . be . an . instanceof ( Error )
126
124
} )
127
125
} )
128
126
129
127
it ( 'returns an error when called with an invalid arg' , ( ) => {
130
- return ipfs . bootstrap . add ( invalidArg )
128
+ return ipfsd . api . bootstrap . add ( invalidArg )
131
129
. catch ( ( err ) => {
132
130
expect ( err ) . to . be . an . instanceof ( Error )
133
131
} )
134
132
} )
135
133
136
134
it ( 'returns a list of peers when called with a valid arg (ip4)' , ( ) => {
137
- return ipfs . bootstrap . add ( validIp4 )
135
+ return ipfsd . api . bootstrap . add ( validIp4 )
138
136
. then ( ( res ) => {
139
137
expect ( res ) . to . be . eql ( { Peers : [ validIp4 ] } )
140
138
peers = res . Peers
@@ -144,7 +142,7 @@ describe('.bootstrap', function () {
144
142
} )
145
143
146
144
it ( 'returns a list of default peers when called with the default option' , ( ) => {
147
- return ipfs . bootstrap . add ( null , { default : true } )
145
+ return ipfsd . api . bootstrap . add ( null , { default : true } )
148
146
. then ( ( res ) => {
149
147
peers = res . Peers
150
148
expect ( peers ) . to . exist ( )
@@ -155,7 +153,7 @@ describe('.bootstrap', function () {
155
153
156
154
describe ( '.list' , ( ) => {
157
155
it ( 'returns a list of peers' , ( ) => {
158
- return ipfs . bootstrap . list ( )
156
+ return ipfsd . api . bootstrap . list ( )
159
157
. then ( ( res ) => {
160
158
peers = res . Peers
161
159
expect ( peers ) . to . exist ( )
@@ -165,14 +163,14 @@ describe('.bootstrap', function () {
165
163
166
164
describe ( '.rm' , ( ) => {
167
165
it ( 'returns an error when called with an invalid arg' , ( ) => {
168
- return ipfs . bootstrap . rm ( invalidArg )
166
+ return ipfsd . api . bootstrap . rm ( invalidArg )
169
167
. catch ( ( err ) => {
170
168
expect ( err ) . to . be . an . instanceof ( Error )
171
169
} )
172
170
} )
173
171
174
172
it ( 'returns empty list when called without an arg or options' , ( ) => {
175
- return ipfs . bootstrap . rm ( null )
173
+ return ipfsd . api . bootstrap . rm ( null )
176
174
. then ( ( res ) => {
177
175
peers = res . Peers
178
176
expect ( peers ) . to . exist ( )
@@ -181,7 +179,7 @@ describe('.bootstrap', function () {
181
179
} )
182
180
183
181
it ( 'returns list containing the peer removed when called with a valid arg (ip4)' , ( ) => {
184
- return ipfs . bootstrap . rm ( null )
182
+ return ipfsd . api . bootstrap . rm ( null )
185
183
. then ( ( res ) => {
186
184
peers = res . Peers
187
185
expect ( peers ) . to . exist ( )
@@ -190,7 +188,7 @@ describe('.bootstrap', function () {
190
188
} )
191
189
192
190
it ( 'returns list of all peers removed when all option is passed' , ( ) => {
193
- return ipfs . bootstrap . rm ( null , { all : true } )
191
+ return ipfsd . api . bootstrap . rm ( null , { all : true } )
194
192
. then ( ( res ) => {
195
193
peers = res . Peers
196
194
expect ( peers ) . to . exist ( )
0 commit comments