@@ -83,24 +83,21 @@ describe('name-pubsub', () => {
83
83
84
84
// Connect
85
85
before ( function ( ) {
86
- return ipfsA ( 'swarm' , 'connect' , bMultiaddr ) . then ( ( out ) => {
87
- expect ( out ) . to . eql ( `connect ${ bMultiaddr } success\n` )
88
- } )
86
+ return ipfsA ( 'swarm' , 'connect' , bMultiaddr )
87
+ . then ( ( out ) => {
88
+ expect ( out ) . to . eql ( `connect ${ bMultiaddr } success\n` )
89
+ } )
89
90
} )
90
91
91
92
after ( ( done ) => parallel ( nodes . map ( ( node ) => ( cb ) => node . stop ( cb ) ) , done ) )
92
93
93
94
describe ( 'pubsub commands' , ( ) => {
94
- before ( function ( done ) {
95
- this . timeout ( 50 * 1000 )
96
- done ( )
97
- } )
98
-
99
95
it ( 'should get enabled state of pubsub' , function ( ) {
100
- return ipfsA ( 'name pubsub state' ) . then ( ( res ) => {
101
- expect ( res ) . to . exist ( )
102
- expect ( res ) . to . have . string ( 'enabled' ) // enabled
103
- } )
96
+ return ipfsA ( 'name pubsub state' )
97
+ . then ( ( res ) => {
98
+ expect ( res ) . to . exist ( )
99
+ expect ( res ) . to . have . string ( 'enabled' ) // enabled
100
+ } )
104
101
} )
105
102
106
103
it ( 'should subscribe on name resolve' , function ( ) {
@@ -110,19 +107,17 @@ describe('name-pubsub', () => {
110
107
. catch ( ( err ) => {
111
108
expect ( err ) . to . exist ( ) // Not available (subscribed)
112
109
113
- return Promise . all ( [
114
- ipfsB ( 'pubsub ls' ) ,
115
- ipfsB ( 'name pubsub subs' )
116
- ] )
117
- . then ( ( res ) => {
118
- expect ( res ) . to . exist ( )
119
-
120
- expect ( res [ 0 ] ) . to . exist ( )
121
- expect ( res [ 0 ] ) . to . have . string ( '/ipns/' ) // have an ipns subscribtion
110
+ return ipfsB ( 'pubsub ls' )
111
+ } )
112
+ . then ( ( res ) => {
113
+ expect ( res ) . to . exist ( )
114
+ expect ( res ) . to . have . string ( '/ipns/' ) // have an ipns subscribtion
122
115
123
- expect ( res [ 1 ] ) . to . exist ( )
124
- expect ( res [ 1 ] ) . to . have . string ( `/ipns/${ nodeAId . id } ` ) // have subscription
125
- } )
116
+ return ipfsB ( 'name pubsub subs' )
117
+ } )
118
+ . then ( ( res ) => {
119
+ expect ( res ) . to . exist ( )
120
+ expect ( res ) . to . have . string ( `/ipns/${ nodeAId . id } ` ) // have subscription
126
121
} )
127
122
} )
128
123
@@ -135,29 +130,27 @@ describe('name-pubsub', () => {
135
130
expect ( res ) . to . have . string ( 'no subscription' ) // tried to cancel a not yet subscribed id
136
131
137
132
return ipfsA ( `name resolve ${ nodeBId . id } ` )
138
- . catch ( ( err ) => {
139
- expect ( err ) . to . exist ( ) // Not available (subscribed now)
140
-
141
- return ipfsA ( `name pubsub cancel /ipns/${ nodeBId . id } ` )
142
- . then ( ( res ) => {
143
- expect ( res ) . to . exist ( )
144
- expect ( res ) . to . have . string ( 'canceled' ) // canceled now
145
-
146
- return Promise . all ( [
147
- ipfsA ( 'pubsub ls' ) ,
148
- ipfsA ( 'name pubsub subs' )
149
- ] )
150
- . then ( ( res ) => {
151
- expect ( res ) . to . exist ( )
152
-
153
- expect ( res [ 0 ] ) . to . exist ( )
154
- expect ( res [ 0 ] ) . to . not . have . string ( '/ipns/' ) // ipns subscribtion not available
155
-
156
- expect ( res [ 1 ] ) . to . exist ( )
157
- expect ( res [ 1 ] ) . to . not . have . string ( `/ipns/${ nodeBId . id } ` ) // ipns subscribtion not available
158
- } )
159
- } )
160
- } )
133
+ } )
134
+ . catch ( ( err ) => {
135
+ expect ( err ) . to . exist ( ) // Not available (subscribed now)
136
+
137
+ return ipfsA ( `name pubsub cancel /ipns/${ nodeBId . id } ` )
138
+ } )
139
+ . then ( ( res ) => {
140
+ expect ( res ) . to . exist ( )
141
+ expect ( res ) . to . have . string ( 'canceled' ) // canceled now
142
+
143
+ return ipfsA ( 'pubsub ls' )
144
+ } )
145
+ . then ( ( res ) => {
146
+ expect ( res ) . to . exist ( )
147
+ expect ( res ) . to . not . have . string ( '/ipns/' ) // ipns subscribtion not available
148
+
149
+ return ipfsA ( 'name pubsub subs' )
150
+ } )
151
+ . then ( ( res ) => {
152
+ expect ( res ) . to . exist ( )
153
+ expect ( res ) . to . not . have . string ( `/ipns/${ nodeBId . id } ` ) // ipns subscribtion not available
161
154
} )
162
155
} )
163
156
} )
@@ -167,10 +160,11 @@ describe('name-pubsub', () => {
167
160
168
161
before ( function ( done ) {
169
162
this . timeout ( 50 * 1000 )
170
- ipfsA ( 'add src/init-files/init-docs/readme' ) . then ( ( out ) => {
171
- cidAdded = out . split ( ' ' ) [ 1 ]
172
- done ( )
173
- } )
163
+ ipfsA ( 'add src/init-files/init-docs/readme' )
164
+ . then ( ( out ) => {
165
+ cidAdded = out . split ( ' ' ) [ 1 ]
166
+ done ( )
167
+ } )
174
168
} )
175
169
176
170
it ( 'should publish the received record to the subscriber' , function ( ) {
@@ -182,30 +176,28 @@ describe('name-pubsub', () => {
182
176
expect ( res ) . to . satisfy ( checkAll ( [ emptyDirCid ] ) ) // Empty dir received (subscribed)
183
177
184
178
return ipfsA ( `name resolve ${ nodeBId . id } ` )
185
- . catch ( ( err ) => {
186
- expect ( err ) . to . exist ( ) // Not available (subscribed now)
187
-
188
- return ipfsB ( `name publish ${ cidAdded } ` )
189
- . then ( ( res ) => {
190
- // published to IpfsB and published through pubsub to ipfsa
191
- expect ( res ) . to . exist ( )
192
- expect ( res ) . to . satisfy ( checkAll ( [ cidAdded , nodeBId . id ] ) )
193
-
194
- return Promise . all ( [
195
- ipfsB ( `name resolve ${ nodeBId . id } ` ) ,
196
- ipfsA ( `name resolve ${ nodeBId . id } ` )
197
- ] )
198
- . then ( ( res ) => {
199
- expect ( res ) . to . exist ( )
200
-
201
- expect ( res [ 0 ] ) . to . exist ( )
202
- expect ( res [ 0 ] ) . to . satisfy ( checkAll ( [ cidAdded ] ) )
203
-
204
- expect ( res [ 1 ] ) . to . exist ( )
205
- expect ( res [ 1 ] ) . to . satisfy ( checkAll ( [ cidAdded ] ) ) // value propagated to node B
206
- } )
207
- } )
208
- } )
179
+ } )
180
+ . catch ( ( err ) => {
181
+ expect ( err ) . to . exist ( ) // Not available (subscribed now)
182
+
183
+ return ipfsB ( `name publish ${ cidAdded } ` )
184
+ } )
185
+ . then ( ( res ) => {
186
+ // published to IpfsB and published through pubsub to ipfsa
187
+ expect ( res ) . to . exist ( )
188
+ expect ( res ) . to . satisfy ( checkAll ( [ cidAdded , nodeBId . id ] ) )
189
+
190
+ return ipfsB ( `name resolve ${ nodeBId . id } ` )
191
+ } )
192
+ . then ( ( res ) => {
193
+ expect ( res ) . to . exist ( )
194
+ expect ( res ) . to . satisfy ( checkAll ( [ cidAdded ] ) )
195
+
196
+ return ipfsA ( `name resolve ${ nodeBId . id } ` )
197
+ } )
198
+ . then ( ( res ) => {
199
+ expect ( res ) . to . exist ( )
200
+ expect ( res ) . to . satisfy ( checkAll ( [ cidAdded ] ) ) // value propagated to node B
209
201
} )
210
202
} )
211
203
} )
@@ -235,30 +227,28 @@ describe('name-pubsub', () => {
235
227
236
228
after ( ( done ) => parallel ( nodes . map ( ( node ) => ( cb ) => node . stop ( cb ) ) , done ) )
237
229
238
- it ( 'should get disabled state of pubsub' , function ( done ) {
239
- ipfsA ( 'name pubsub state' ) . then ( ( res ) => {
240
- expect ( res ) . to . exist ( )
241
- expect ( res ) . to . have . string ( 'disabled' )
242
-
243
- done ( )
244
- } )
230
+ it ( 'should get disabled state of pubsub' , function ( ) {
231
+ return ipfsA ( 'name pubsub state' )
232
+ . then ( ( res ) => {
233
+ expect ( res ) . to . exist ( )
234
+ expect ( res ) . to . have . string ( 'disabled' )
235
+ } )
245
236
} )
246
237
247
- it ( 'should get error getting the available subscriptions' , function ( done ) {
248
- ipfsA ( 'name pubsub subs' ) . catch ( ( err ) => {
249
- expect ( err ) . to . exist ( ) // error as it is disabled
250
- expect ( err . toString ( ) ) . to . have . string ( 'IPNS pubsub subsystem is not enabled' )
251
- done ( )
252
- } )
238
+ it ( 'should get error getting the available subscriptions' , function ( ) {
239
+ return ipfsA ( 'name pubsub subs' )
240
+ . catch ( ( err ) => {
241
+ expect ( err ) . to . exist ( ) // error as it is disabled
242
+ expect ( err . toString ( ) ) . to . have . string ( 'IPNS pubsub subsystem is not enabled' )
243
+ } )
253
244
} )
254
245
255
- it ( 'should get error canceling a subscription' , function ( done ) {
256
- ipfsA ( 'name pubsub cancel /ipns/QmSWxaPcGgf4TDnFEBDWz2JnbHywF14phmY9hNcAeBEK5v' ) . catch ( ( err ) => {
257
- expect ( err ) . to . exist ( ) // error as it is disabled
258
- expect ( err . toString ( ) ) . to . have . string ( 'IPNS pubsub subsystem is not enabled' )
259
-
260
- done ( )
261
- } )
246
+ it ( 'should get error canceling a subscription' , function ( ) {
247
+ return ipfsA ( 'name pubsub cancel /ipns/QmSWxaPcGgf4TDnFEBDWz2JnbHywF14phmY9hNcAeBEK5v' )
248
+ . catch ( ( err ) => {
249
+ expect ( err ) . to . exist ( ) // error as it is disabled
250
+ expect ( err . toString ( ) ) . to . have . string ( 'IPNS pubsub subsystem is not enabled' )
251
+ } )
262
252
} )
263
253
} )
264
254
} )
0 commit comments