@@ -22,10 +22,9 @@ module.exports = (common) => {
2222 let ipfs
2323
2424 before ( function ( done ) {
25- // CI takes longer to instantiate the daemon,
26- // so we need to increase the timeout for the
27- // before step
28- this . timeout ( 20 * 1000 )
25+ // CI takes longer to instantiate the daemon, so we need to increase the
26+ // timeout for the before step
27+ this . timeout ( 40 * 1000 )
2928
3029 common . setup ( ( err , factory ) => {
3130 expect ( err ) . to . not . exist ( )
@@ -39,106 +38,108 @@ module.exports = (common) => {
3938
4039 after ( ( done ) => common . teardown ( done ) )
4140
42- describe ( 'callback API' , ( ) => {
43- describe ( '.put' , ( ) => {
44- it ( 'a buffer, using defaults' , ( done ) => {
45- const expectedHash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
46- const blob = new Buffer ( 'blorb' )
47-
48- ipfs . block . put ( blob , ( err , block ) => {
49- expect ( err ) . to . not . exist ( )
50- expect ( block . data ) . to . be . eql ( blob )
51- expectKey ( block , multihash . fromB58String ( expectedHash ) , done )
52- } )
41+ describe ( '.put' , ( ) => {
42+ it ( 'a buffer, using defaults' , ( done ) => {
43+ const expectedHash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
44+ const blob = new Buffer ( 'blorb' )
45+
46+ ipfs . block . put ( blob , ( err , block ) => {
47+ expect ( err ) . to . not . exist ( )
48+ expect ( block . data ) . to . be . eql ( blob )
49+ expectKey ( block , multihash . fromB58String ( expectedHash ) , done )
5350 } )
51+ } )
5452
55- it ( 'a buffer, using CID' , ( done ) => {
56- const expectedHash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
57- const cid = new CID ( expectedHash )
58- const blob = new Buffer ( 'blorb' )
53+ it ( 'a buffer, using CID' , ( done ) => {
54+ const expectedHash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
55+ const cid = new CID ( expectedHash )
56+ const blob = new Buffer ( 'blorb' )
5957
60- ipfs . block . put ( blob , { cid : cid } , ( err , block ) => {
61- expect ( err ) . to . not . exist ( )
62- expect ( block . data ) . to . be . eql ( blob )
63- expectKey ( block , multihash . fromB58String ( expectedHash ) , done )
64- } )
58+ ipfs . block . put ( blob , { cid : cid } , ( err , block ) => {
59+ expect ( err ) . to . not . exist ( )
60+ expect ( block . data ) . to . be . eql ( blob )
61+ expectKey ( block , multihash . fromB58String ( expectedHash ) , done )
6562 } )
63+ } )
64+
65+ it ( 'a buffer, using options' , ( done ) => {
66+ const expectedHash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
67+ const blob = new Buffer ( 'blorb' )
6668
67- it ( 'a buffer, using options' , ( done ) => {
68- const expectedHash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
69- const blob = new Buffer ( 'blorb' )
70-
71- ipfs . block . put ( blob , {
72- format : 'dag-pb' ,
73- mhtype : 'sha2-256' ,
74- version : 0
75- } , ( err , block ) => {
76- expect ( err ) . to . not . exist ( )
77- expect ( block . data ) . to . be . eql ( blob )
78- expectKey ( block , multihash . fromB58String ( expectedHash ) , done )
79- } )
69+ ipfs . block . put ( blob , {
70+ format : 'dag-pb' ,
71+ mhtype : 'sha2-256' ,
72+ version : 0
73+ } , ( err , block ) => {
74+ expect ( err ) . to . not . exist ( )
75+ expect ( block . data ) . to . be . eql ( blob )
76+ expectKey ( block , multihash . fromB58String ( expectedHash ) , done )
8077 } )
78+ } )
8179
82- it ( 'a Block instance' , ( done ) => {
83- const expectedHash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
84- const cid = new CID ( expectedHash )
85- const b = new Block ( new Buffer ( 'blorb' ) , cid )
80+ it ( 'a Block instance' , ( done ) => {
81+ const expectedHash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
82+ const cid = new CID ( expectedHash )
83+ const b = new Block ( new Buffer ( 'blorb' ) , cid )
8684
87- ipfs . block . put ( b , ( err , block ) => {
88- expect ( err ) . to . not . exist ( )
89- expect ( block . data ) . to . eql ( new Buffer ( 'blorb' ) )
90- expectKey ( block , multihash . fromB58String ( expectedHash ) , done )
91- } )
85+ ipfs . block . put ( b , ( err , block ) => {
86+ expect ( err ) . to . not . exist ( )
87+ expect ( block . data ) . to . eql ( new Buffer ( 'blorb' ) )
88+ expectKey ( block , multihash . fromB58String ( expectedHash ) , done )
9289 } )
90+ } )
9391
94- it ( 'error with array of blocks' , ( done ) => {
95- const blob = Buffer ( 'blorb' )
92+ it ( 'error with array of blocks' , ( done ) => {
93+ const blob = Buffer ( 'blorb' )
9694
97- ipfs . block . put ( [ blob , blob ] , ( err ) => {
98- expect ( err ) . to . be . an . instanceof ( Error )
99- done ( )
100- } )
95+ ipfs . block . put ( [ blob , blob ] , ( err ) => {
96+ expect ( err ) . to . be . an . instanceof ( Error )
97+ done ( )
10198 } )
10299 } )
103100
104- describe ( '.get' , ( ) => {
105- it ( 'by CID object' , ( done ) => {
106- const hash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
107- const cid = new CID ( hash )
101+ // TODO it.skip('Promises support', (done) => {})
102+ } )
108103
109- ipfs . block . get ( cid , ( err , block ) => {
110- expect ( err ) . to . not . exist ( )
111- expect ( block . data ) . to . eql ( new Buffer ( 'blorb' ) )
112- expectKey ( block , cid . multihash , done )
113- } )
104+ describe ( '.get' , ( ) => {
105+ it ( 'by CID object' , ( done ) => {
106+ const hash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
107+ const cid = new CID ( hash )
108+
109+ ipfs . block . get ( cid , ( err , block ) => {
110+ expect ( err ) . to . not . exist ( )
111+ expect ( block . data ) . to . eql ( new Buffer ( 'blorb' ) )
112+ expectKey ( block , cid . multihash , done )
114113 } )
114+ } )
115115
116- it ( 'by CID in Str' , ( done ) => {
117- const hash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
116+ it ( 'by CID in Str' , ( done ) => {
117+ const hash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
118118
119- ipfs . block . get ( hash , ( err , block ) => {
120- expect ( err ) . to . not . exist ( )
121- expect ( block . data ) . to . eql ( new Buffer ( 'blorb' ) )
122- expectKey ( block , multihash . fromB58String ( hash ) , done )
123- } )
119+ ipfs . block . get ( hash , ( err , block ) => {
120+ expect ( err ) . to . not . exist ( )
121+ expect ( block . data ) . to . eql ( new Buffer ( 'blorb' ) )
122+ expectKey ( block , multihash . fromB58String ( hash ) , done )
124123 } )
125124 } )
126125
127- describe ( '.stat' , ( ) => {
128- it ( 'by CID' , ( done ) => {
129- const hash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
130- const cid = new CID ( hash )
131-
132- ipfs . block . stat ( cid , ( err , stats ) => {
133- expect ( err ) . to . not . exist ( )
134- expect ( stats ) . to . have . property ( 'key' )
135- expect ( stats ) . to . have . property ( 'size' )
136- done ( )
137- } )
126+ // TODO it.skip('Promises support', (done) => {})
127+ } )
128+
129+ describe ( '.stat' , ( ) => {
130+ it ( 'by CID' , ( done ) => {
131+ const hash = 'QmPv52ekjS75L4JmHpXVeuJ5uX2ecSfSZo88NSyxwA3rAQ'
132+ const cid = new CID ( hash )
133+
134+ ipfs . block . stat ( cid , ( err , stats ) => {
135+ expect ( err ) . to . not . exist ( )
136+ expect ( stats ) . to . have . property ( 'key' )
137+ expect ( stats ) . to . have . property ( 'size' )
138+ done ( )
138139 } )
139140 } )
140- } )
141141
142- describe ( 'promise API' , ( ) => { } )
142+ // TODO it.skip('Promises support', (done) => {})
143+ } )
143144 } )
144145}
0 commit comments