@@ -12,11 +12,14 @@ const isNode = !global.window
12
12
13
13
const testfilePath = __dirname + '/testfile.txt'
14
14
let testfile
15
+ let testfileBig
15
16
16
17
if ( isNode ) {
17
18
testfile = require ( 'fs' ) . readFileSync ( __dirname + '/testfile.txt' )
19
+ testfileBig = require ( 'fs' ) . readFileSync ( __dirname + '/100mb.random' )
18
20
} else {
19
21
testfile = require ( 'raw!./testfile.txt' )
22
+ testfileBig = require ( 'raw!./100mb.random' )
20
23
}
21
24
22
25
describe ( 'IPFS Node.js API wrapper tests' , ( ) => {
@@ -116,12 +119,26 @@ describe('IPFS Node.js API wrapper tests', () => {
116
119
if ( err ) throw err
117
120
118
121
// assert.equal(res.length, 1)
119
- const added = res [ 0 ] != null ? res [ 0 ] : res
122
+ const added = res [ 0 ] !== null ? res [ 0 ] : res
120
123
assert . equal ( added . Hash , 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' )
121
124
done ( )
122
125
} )
123
126
} )
124
127
128
+ it ( 'add BIG buffer' , function ( done ) {
129
+ this . timeout ( 10000 )
130
+
131
+ let buf = new Buffer ( testfileBig )
132
+ apiClients [ 'a' ] . add ( buf , ( err , res ) => {
133
+ if ( err ) throw err
134
+
135
+ // assert.equal(res.length, 1)
136
+ const added = res [ 0 ] !== null ? res [ 0 ] : res
137
+ assert . equal ( added . Hash , 'Qmaw8jKK2vdd1gxiYqfyXJgVwfibiXiH3H81eVViJRXMJj' )
138
+ done ( )
139
+ } )
140
+ } )
141
+
125
142
it ( 'add path' , function ( done ) {
126
143
if ( ! isNode ) {
127
144
return done ( )
@@ -203,6 +220,25 @@ describe('IPFS Node.js API wrapper tests', () => {
203
220
} )
204
221
} )
205
222
} )
223
+
224
+ it ( 'cat BIG file' , function ( done ) {
225
+ this . timeout ( 10000 )
226
+
227
+ apiClients [ 'a' ] . cat ( 'Qmaw8jKK2vdd1gxiYqfyXJgVwfibiXiH3H81eVViJRXMJj' , ( err , res ) => {
228
+ if ( err ) {
229
+ throw err
230
+ }
231
+
232
+ let buf = ''
233
+ res
234
+ . on ( 'error' , err => { throw err } )
235
+ . on ( 'data' , data => buf += data )
236
+ . on ( 'end' , ( ) => {
237
+ assert . equal ( buf , testfileBig )
238
+ done ( )
239
+ } )
240
+ } )
241
+ } )
206
242
} )
207
243
208
244
describe ( '.ls' , function ( ) {
0 commit comments