@@ -5,86 +5,58 @@ const chai = require('chai')
5
5
const dirtyChai = require ( 'dirty-chai' )
6
6
const expect = chai . expect
7
7
chai . use ( dirtyChai )
8
- const FactoryClient = require ( './ipfs-factory/client' )
8
+
9
+ const IPFSApi = require ( '../src' )
10
+
11
+ const DaemonFactory = require ( 'ipfsd-ctl' )
12
+ const df = DaemonFactory . create ( )
9
13
10
14
describe ( '.bitswap' , function ( ) {
11
15
this . timeout ( 20 * 1000 ) // slow CI
12
16
let ipfs
13
- let fc
17
+ let ipfsd = null
14
18
15
19
before ( ( done ) => {
16
20
this . timeout ( 20 * 1000 ) // slow CI
17
- fc = new FactoryClient ( )
18
- fc . spawnNode ( ( err , node ) => {
21
+ df . spawn ( ( err , _ipfsd ) => {
19
22
expect ( err ) . to . not . exist ( )
20
- ipfs = node
23
+ ipfsd = _ipfsd
24
+ ipfs = IPFSApi ( _ipfsd . apiAddr )
21
25
done ( )
22
26
} )
23
27
} )
24
28
25
- after ( ( done ) => {
26
- fc . dismantle ( done )
27
- } )
28
-
29
- describe ( 'Callback API' , ( ) => {
30
- it ( '.wantlist' , ( done ) => {
31
- ipfs . bitswap . wantlist ( ( err , res ) => {
32
- expect ( err ) . to . not . exist ( )
33
- expect ( res ) . to . have . to . be . eql ( {
34
- Keys : null
35
- } )
36
- done ( )
37
- } )
38
- } )
39
-
40
- it ( '.stat' , ( done ) => {
41
- ipfs . bitswap . stat ( ( err , res ) => {
42
- expect ( err ) . to . not . exist ( )
43
- expect ( res ) . to . have . property ( 'BlocksReceived' )
44
- expect ( res ) . to . have . property ( 'DupBlksReceived' )
45
- expect ( res ) . to . have . property ( 'DupDataReceived' )
46
- expect ( res ) . to . have . property ( 'Peers' )
47
- expect ( res ) . to . have . property ( 'ProvideBufLen' )
48
- expect ( res ) . to . have . property ( 'Wantlist' )
49
-
50
- done ( )
51
- } )
52
- } )
29
+ after ( ( done ) => ipfsd . stop ( done ) )
53
30
54
- it ( '.unwant ' , ( done ) => {
55
- const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
56
- ipfs . bitswap . unwant ( key , ( err ) => {
57
- expect ( err ) . to . not . exist ( )
58
- done ( )
31
+ it ( '.wantlist ' , ( done ) => {
32
+ ipfs . bitswap . wantlist ( ( err , res ) => {
33
+ expect ( err ) . to . not . exist ( )
34
+ expect ( res ) . to . have . to . eql ( {
35
+ Keys : null
59
36
} )
37
+ done ( )
60
38
} )
61
39
} )
62
40
63
- describe ( 'Promise API ', ( ) => {
64
- it ( '.wantlist' , ( ) => {
65
- return ipfs . bitswap . wantlist ( )
66
- . then ( ( res ) => {
67
- expect ( res ) . to . have . to . be . eql ( {
68
- Keys : null
69
- } )
70
- } )
71
- } )
41
+ it ( '.stat ', ( done ) => {
42
+ ipfs . bitswap . stat ( ( err , res ) => {
43
+ expect ( err ) . to . not . exist ( )
44
+ expect ( res ) . to . have . property ( 'BlocksReceived' )
45
+ expect ( res ) . to . have . property ( 'DupBlksReceived' )
46
+ expect ( res ) . to . have . property ( 'DupDataReceived' )
47
+ expect ( res ) . to . have . property ( 'Peers' )
48
+ expect ( res ) . to . have . property ( 'ProvideBufLen' )
49
+ expect ( res ) . to . have . property ( 'Wantlist' )
72
50
73
- it ( '.stat' , ( ) => {
74
- return ipfs . bitswap . stat ( )
75
- . then ( ( res ) => {
76
- expect ( res ) . to . have . property ( 'BlocksReceived' )
77
- expect ( res ) . to . have . property ( 'DupBlksReceived' )
78
- expect ( res ) . to . have . property ( 'DupDataReceived' )
79
- expect ( res ) . to . have . property ( 'Peers' )
80
- expect ( res ) . to . have . property ( 'ProvideBufLen' )
81
- expect ( res ) . to . have . property ( 'Wantlist' )
82
- } )
51
+ done ( )
83
52
} )
53
+ } )
84
54
85
- it ( '.unwant' , ( ) => {
86
- const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
87
- return ipfs . bitswap . unwant ( key )
55
+ it ( '.unwant' , ( done ) => {
56
+ const key = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
57
+ ipfs . bitswap . unwant ( key , ( err ) => {
58
+ expect ( err ) . to . not . exist ( )
59
+ done ( )
88
60
} )
89
61
} )
90
62
} )
0 commit comments