@@ -9,7 +9,7 @@ describe('swarm', function () {
99
1010 describe ( 'api' , ( ) => {
1111 var api
12- var ipfs
12+ var ipfs // tmp node
1313 var ipfsAddr
1414
1515 before ( ( done ) => {
@@ -28,69 +28,80 @@ describe('swarm', function () {
2828 } )
2929 } )
3030
31- it ( 'api' , ( done ) => {
31+ after ( ( done ) => {
32+ // cause CI takes forever
33+ var closed = false
34+ setTimeout ( ( ) => {
35+ if ( ! closed ) {
36+ closed = true
37+ done ( )
38+ }
39+ } , 10000 )
40+ ipfs . libp2p . stop ( ( ) => {
41+ if ( ! closed ) {
42+ closed = true
43+ done ( )
44+ }
45+ } )
46+ } )
47+
48+ it ( 'gets the api obj' , ( done ) => {
3249 api = require ( '../../src/http-api' ) . server . select ( 'API' )
3350 done ( )
3451 } )
3552
36- describe ( '/swarm/connect' , ( ) => {
37- it ( 'returns 400 for request without argument' , ( done ) => {
38- api . inject ( {
39- method : 'GET' ,
40- url : '/api/v0/swarm/connect'
41- } , ( res ) => {
42- expect ( res . statusCode ) . to . equal ( 400 )
43- expect ( res . result ) . to . be . a ( 'string' )
44- done ( )
45- } )
53+ it ( '/swarm/connect returns 400 for request without argument' , ( done ) => {
54+ api . inject ( {
55+ method : 'GET' ,
56+ url : '/api/v0/swarm/connect'
57+ } , ( res ) => {
58+ expect ( res . statusCode ) . to . equal ( 400 )
59+ expect ( res . result ) . to . be . a ( 'string' )
60+ done ( )
4661 } )
62+ } )
4763
48- it ( 'returns 500 for request with invalid argument' , ( done ) => {
49- api . inject ( {
50- method : 'GET' ,
51- url : '/api/v0/swarm/connect?arg=invalid'
52- } , ( res ) => {
53- expect ( res . statusCode ) . to . equal ( 500 )
54- expect ( res . result . Code ) . to . equal ( 0 )
55- expect ( res . result . Message ) . to . be . a ( 'string' )
56- done ( )
57- } )
64+ it ( '/swarm/connect returns 500 for request with invalid argument' , ( done ) => {
65+ api . inject ( {
66+ method : 'GET' ,
67+ url : '/api/v0/swarm/connect?arg=invalid'
68+ } , ( res ) => {
69+ expect ( res . statusCode ) . to . equal ( 500 )
70+ expect ( res . result . Code ) . to . equal ( 0 )
71+ expect ( res . result . Message ) . to . be . a ( 'string' )
72+ done ( )
5873 } )
74+ } )
5975
60- it ( 'returns value' , ( done ) => {
61- api . inject ( {
62- method : 'GET' ,
63- url : `/api/v0/swarm/connect?arg=${ ipfsAddr } `
64- } , ( res ) => {
65- expect ( res . statusCode ) . to . equal ( 200 )
66- done ( )
67- } )
76+ it ( '/swarm/connect returns value' , ( done ) => {
77+ api . inject ( {
78+ method : 'GET' ,
79+ url : `/api/v0/swarm/connect?arg=${ ipfsAddr } `
80+ } , ( res ) => {
81+ expect ( res . statusCode ) . to . equal ( 200 )
82+ done ( )
6883 } )
6984 } )
7085
71- describe ( '/swarm/peers' , ( ) => {
72- it ( 'returns value' , ( done ) => {
73- api . inject ( {
74- method : 'GET' ,
75- url : '/api/v0/swarm/peers'
76- } , ( res ) => {
77- expect ( res . statusCode ) . to . equal ( 200 )
78- expect ( res . result . Strings ) . to . have . length . above ( 0 )
79- done ( )
80- } )
86+ it ( '/swarm/peers returns value' , ( done ) => {
87+ api . inject ( {
88+ method : 'GET' ,
89+ url : '/api/v0/swarm/peers'
90+ } , ( res ) => {
91+ expect ( res . statusCode ) . to . equal ( 200 )
92+ expect ( res . result . Strings ) . to . have . length . above ( 0 )
93+ done ( )
8194 } )
8295 } )
8396
84- describe ( '/swarm/addrs/local' , ( ) => {
85- it ( 'returns value' , ( done ) => {
86- api . inject ( {
87- method : 'GET' ,
88- url : '/api/v0/swarm/addrs/local'
89- } , ( res ) => {
90- expect ( res . statusCode ) . to . equal ( 200 )
91- expect ( res . result . Strings ) . to . have . length . above ( 0 )
92- done ( )
93- } )
97+ it ( '/swarm/addrs/local returns value' , ( done ) => {
98+ api . inject ( {
99+ method : 'GET' ,
100+ url : '/api/v0/swarm/addrs/local'
101+ } , ( res ) => {
102+ expect ( res . statusCode ) . to . equal ( 200 )
103+ expect ( res . result . Strings ) . to . have . length . above ( 0 )
104+ done ( )
94105 } )
95106 } )
96107 } )
@@ -116,51 +127,62 @@ describe('swarm', function () {
116127 } )
117128 } )
118129
130+ after ( ( done ) => {
131+ // cause CI takes forever
132+ var closed = false
133+ setTimeout ( ( ) => {
134+ if ( ! closed ) {
135+ closed = true
136+ done ( )
137+ }
138+ } , 10000 )
139+ ipfs . libp2p . stop ( ( ) => {
140+ if ( ! closed ) {
141+ closed = true
142+ done ( )
143+ }
144+ } )
145+ } )
146+
119147 it ( 'start IPFS API ctl' , ( done ) => {
120148 ctl = APIctl ( '/ip4/127.0.0.1/tcp/6001' )
121149 done ( )
122150 } )
123151
124- describe ( 'ipfs.swarm.connect' , ( ) => {
125- it ( 'returns error for request without argument' , ( done ) => {
126- ctl . swarm . connect ( null , ( err , result ) => {
127- expect ( err ) . to . exist
128- done ( )
129- } )
152+ it ( 'ipfs.swarm.connect returns error for request without argument' , ( done ) => {
153+ ctl . swarm . connect ( null , ( err , result ) => {
154+ expect ( err ) . to . exist
155+ done ( )
130156 } )
157+ } )
131158
132- it ( 'returns error for request with invalid argument' , ( done ) => {
133- ctl . swarm . connect ( 'invalid' , ( err , result ) => {
134- expect ( err ) . to . exist
135- done ( )
136- } )
159+ it ( 'ipfs.swarm.connect returns error for request with invalid argument' , ( done ) => {
160+ ctl . swarm . connect ( 'invalid' , ( err , result ) => {
161+ expect ( err ) . to . exist
162+ done ( )
137163 } )
164+ } )
138165
139- it ( 'returns value' , ( done ) => {
140- ctl . swarm . connect ( ipfsAddr , ( err , result ) => {
141- expect ( err ) . to . not . exist
142- done ( )
143- } )
166+ it ( 'ipfs.swarm.connect returns value' , ( done ) => {
167+ ctl . swarm . connect ( ipfsAddr , ( err , result ) => {
168+ expect ( err ) . to . not . exist
169+ done ( )
144170 } )
145171 } )
146172
147- describe ( 'ipfs.swarm.peers' , ( ) => {
148- it ( 'returns value' , ( done ) => {
149- ctl . swarm . peers ( ( err , result ) => {
150- expect ( err ) . to . not . exist
151- expect ( result . Strings ) . to . have . length . above ( 0 )
152- done ( )
153- } )
173+ it ( 'ipfs.swarm.peers returns value' , ( done ) => {
174+ ctl . swarm . peers ( ( err , result ) => {
175+ expect ( err ) . to . not . exist
176+ expect ( result . Strings ) . to . have . length . above ( 0 )
177+ done ( )
154178 } )
155179 } )
156180
157- describe ( 'ipfs.swarm.localAddrs' , ( ) => {
158- it ( 'returns value' , ( done ) => {
159- ctl . swarm . localAddrs ( ( err , result ) => {
160- expect ( err ) . to . not . exist
161- expect ( result . Strings ) . to . have . length . above ( 0 )
162- done ( )
163- } )
181+ it ( 'ipfs.swarm.localAddrsreturns value' , ( done ) => {
182+ ctl . swarm . localAddrs ( ( err , result ) => {
183+ expect ( err ) . to . not . exist
184+ expect ( result . Strings ) . to . have . length . above ( 0 )
185+ done ( )
164186 } )
165187 } )
166188 } )
0 commit comments