3
3
'use strict'
4
4
5
5
const series = require ( 'async/series' )
6
- const loadFixture = require ( 'aegir/fixtures' )
7
6
8
7
const { spawnNodeWithId } = require ( '../utils/spawn' )
9
8
const { getDescribe, getIt, expect } = require ( '../utils/mocha' )
10
9
11
- const fixture = Object . freeze ( {
12
- data : loadFixture ( 'js/test/fixtures/testfile.txt' , 'interface-ipfs-core' )
13
- } )
14
-
15
10
module . exports = ( createCommon , options ) => {
16
11
const describe = getDescribe ( options )
17
12
const it = getIt ( options )
@@ -20,7 +15,6 @@ module.exports = (createCommon, options) => {
20
15
describe ( '.name.pubsub.cancel' , function ( ) {
21
16
let ipfs
22
17
let nodeId
23
- let value
24
18
25
19
before ( function ( done ) {
26
20
// CI takes longer to instantiate the daemon, so we need to increase the
@@ -36,12 +30,7 @@ module.exports = (createCommon, options) => {
36
30
ipfs = node
37
31
nodeId = node . peerId . id
38
32
39
- ipfs . add ( fixture . data , { pin : false } , ( err , res ) => {
40
- expect ( err ) . to . not . exist ( )
41
-
42
- value = res [ 0 ] . path
43
- done ( )
44
- } )
33
+ done ( )
45
34
} )
46
35
} )
47
36
} )
@@ -63,24 +52,30 @@ module.exports = (createCommon, options) => {
63
52
64
53
it ( 'should cancel a subscription correctly returning true' , function ( done ) {
65
54
this . timeout ( 300 * 1000 )
66
- const ipnsPath = `/ipns/${ nodeId } `
67
-
68
- series ( [
69
- ( cb ) => ipfs . name . pubsub . subs ( cb ) ,
70
- ( cb ) => ipfs . name . publish ( value , { resolve : false } , cb ) ,
71
- ( cb ) => ipfs . name . resolve ( nodeId , cb ) ,
72
- ( cb ) => ipfs . name . pubsub . subs ( cb ) ,
73
- ( cb ) => ipfs . name . pubsub . cancel ( ipnsPath , cb ) ,
74
- ( cb ) => ipfs . name . pubsub . subs ( cb )
75
- ] , ( err , res ) => {
55
+ const id = 'QmNP1ASen5ZREtiJTtVD3jhMKhoPb1zppET1tgpjHx2NGA'
56
+ const ipnsPath = `/ipns/${ id } `
57
+
58
+ ipfs . name . pubsub . subs ( ( err , res ) => {
76
59
expect ( err ) . to . not . exist ( )
77
- expect ( res ) . to . exist ( )
78
- expect ( res [ 0 ] ) . to . eql ( [ ] ) // initally empty
79
- expect ( res [ 4 ] ) . to . have . property ( 'canceled' )
80
- expect ( res [ 4 ] . canceled ) . to . eql ( true )
81
- expect ( res [ 5 ] ) . to . be . an ( 'array' ) . that . does . not . include ( ipnsPath )
60
+ expect ( res ) . to . eql ( [ ] ) // initally empty
61
+
62
+ ipfs . name . resolve ( id , ( err ) => {
63
+ expect ( err ) . to . exist ( )
64
+ series ( [
65
+ ( cb ) => ipfs . name . pubsub . subs ( cb ) ,
66
+ ( cb ) => ipfs . name . pubsub . cancel ( ipnsPath , cb ) ,
67
+ ( cb ) => ipfs . name . pubsub . subs ( cb )
68
+ ] , ( err , res ) => {
69
+ expect ( err ) . to . not . exist ( )
70
+ expect ( res ) . to . exist ( )
71
+ expect ( res [ 0 ] ) . to . be . an ( 'array' ) . that . does . include ( ipnsPath )
72
+ expect ( res [ 1 ] ) . to . have . property ( 'canceled' )
73
+ expect ( res [ 1 ] . canceled ) . to . eql ( true )
74
+ expect ( res [ 2 ] ) . to . be . an ( 'array' ) . that . does . not . include ( ipnsPath )
82
75
83
- done ( )
76
+ done ( )
77
+ } )
78
+ } )
84
79
} )
85
80
} )
86
81
} )
0 commit comments