This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 5 files changed +48
-49
lines changed 5 files changed +48
-49
lines changed Original file line number Diff line number Diff line change @@ -290,7 +290,7 @@ describe('files', () => runOnAndOff((thing) => {
290
290
. then ( out => {
291
291
const hash = out . split ( ' ' ) [ 1 ]
292
292
293
- // 'jsipfs object get <hash>' should time out with the daemon on
293
+ // 'jsipfs object get <hash>' should timeout with the daemon on
294
294
// and should fail fast with the daemon off
295
295
return Promise . race ( [
296
296
ipfs . fail ( `object get ${ hash } ` ) ,
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ /* eslint-env mocha */
2
+ /* eslint max-nested-callbacks: ["error", 8] */
3
+ 'use strict'
4
+
5
+ const chai = require ( 'chai' )
6
+ const dirtyChai = require ( 'dirty-chai' )
7
+ chai . use ( dirtyChai )
8
+
9
+ describe ( '.files' , ( ) => {
10
+ let ipfs = null
11
+ let ipfsd = null
12
+ before ( function ( done ) {
13
+ this . timeout ( 20 * 1000 )
14
+ df . spawn ( { initOptions : { bits : 512 } } , ( err , _ipfsd ) => {
15
+ expect ( err ) . to . not . exist ( )
16
+ ipfsd = _ipfsd
17
+ ipfs = ipfsd . api
18
+ done ( )
19
+ } )
20
+ } )
21
+
22
+ after ( ( done ) => ipfsd . stop ( done ) )
23
+
24
+ describe ( '.add' , function ( ) {
25
+ it ( 'performs a speculative add, --only-hash' , ( ) => {
26
+ const content = String ( Math . random ( ) )
27
+
28
+ return ipfs . add ( Buffer . from ( content ) , { onlyHash : true } )
29
+ . then ( files => {
30
+ const getAttempt = ipfs . object . get ( files [ 0 ] . hash )
31
+ . then ( ( ) => {
32
+ throw new Error ( 'Should not find an object for content added with --only-hash' )
33
+ } )
34
+
35
+ return Promise . race ( [
36
+ getAttempt ,
37
+ new Promise ( ( resolve , reject ) => setTimeout ( resolve , 4000 ) )
38
+ ] )
39
+ } )
40
+ } )
41
+ } )
42
+ } )
Original file line number Diff line number Diff line change @@ -51,6 +51,11 @@ module.exports = (repoPath, opts) => {
51
51
return res
52
52
}
53
53
54
+ /**
55
+ * Expect the command passed as @param arguments to fail.
56
+ * @return {Promise } Resolves if the command passed as @param arguments fails,
57
+ * rejects if it was successful.
58
+ */
54
59
ipfs . fail = function ipfsFail ( ) {
55
60
let args = Array . from ( arguments )
56
61
let caught = false
You can’t perform that action at this time.
0 commit comments