@@ -5,86 +5,58 @@ const chai = require('chai')
55const dirtyChai = require ( 'dirty-chai' )
66const expect = chai . expect
77chai . 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 ( )
913
1014describe ( '.bitswap' , function ( ) {
1115 this . timeout ( 20 * 1000 ) // slow CI
1216 let ipfs
13- let fc
17+ let ipfsd = null
1418
1519 before ( ( done ) => {
1620 this . timeout ( 20 * 1000 ) // slow CI
17- fc = new FactoryClient ( )
18- fc . spawnNode ( ( err , node ) => {
21+ df . spawn ( ( err , _ipfsd ) => {
1922 expect ( err ) . to . not . exist ( )
20- ipfs = node
23+ ipfsd = _ipfsd
24+ ipfs = IPFSApi ( _ipfsd . apiAddr )
2125 done ( )
2226 } )
2327 } )
2428
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 ) )
5330
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
5936 } )
37+ done ( )
6038 } )
6139 } )
6240
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' )
7250
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 ( )
8352 } )
53+ } )
8454
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 ( )
8860 } )
8961 } )
9062} )
0 commit comments