Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit c608f5f

Browse files
dignifiedquiredaviddias
authored andcommitted
test(interop): add more sizes (#715)
1 parent 838bfde commit c608f5f

File tree

2 files changed

+50
-35
lines changed

2 files changed

+50
-35
lines changed

test/interop/daemons/js.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class JsDaemon {
4141
this.init = opts.init
4242
this.port = opts.port
4343

44-
this.path = opts.path || os.tmpdir() + `/${Math.ceil(Math.random() * 1000)}`
44+
this.path = opts.path || os.tmpdir() + `/${Math.ceil(Math.random() * 10000)}`
4545
if (this.init) {
4646
this.ipfs = new IPFS(this.path)
4747
} else {

test/interop/index.js

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ const crypto = require('crypto')
1111
const GoDaemon = require('./daemons/go')
1212
const JsDaemon = require('./daemons/js')
1313

14+
const sizes = [
15+
1024,
16+
1024 * 62,
17+
// starts failing with spdy
18+
1024 * 64,
19+
1024 * 512,
20+
1024 * 768,
21+
1024 * 1023,
22+
// starts failing with multiplex
23+
1024 * 1024,
24+
1024 * 1024 * 4,
25+
1024 * 1024 * 8
26+
]
27+
1428
describe('basic', () => {
1529
let goDaemon
1630
let jsDaemon
@@ -92,43 +106,44 @@ describe('basic', () => {
92106
], done)
93107
})
94108

95-
it('cat file: go -> js', (done) => {
96-
const data = crypto.randomBytes(1024 * 1024)
97-
waterfall([
98-
(cb) => goDaemon.api.add(data, cb),
99-
(res, cb) => jsDaemon.api.cat(res[0].hash, cb),
100-
(stream, cb) => stream.pipe(bl(cb))
101-
], (err, file) => {
102-
expect(err).to.not.exist
103-
expect(file).to.be.eql(data)
104-
done()
109+
describe('cat file', () => sizes.forEach((size) => {
110+
it(`go -> js: ${size}bytes`, (done) => {
111+
const data = crypto.randomBytes(size)
112+
waterfall([
113+
(cb) => goDaemon.api.add(data, cb),
114+
(res, cb) => jsDaemon.api.cat(res[0].hash, cb),
115+
(stream, cb) => stream.pipe(bl(cb))
116+
], (err, file) => {
117+
expect(err).to.not.exist
118+
expect(file).to.be.eql(data)
119+
done()
120+
})
105121
})
106-
})
107122

108-
it('cat file: js -> go', (done) => {
109-
// This will fail once the size is increased to 64512 = 1024 * 63
110-
const data = crypto.randomBytes(1024 * 63 - 1)
111-
waterfall([
112-
(cb) => jsDaemon.api.add(data, cb),
113-
(res, cb) => goDaemon.api.cat(res[0].hash, cb),
114-
(stream, cb) => stream.pipe(bl(cb))
115-
], (err, file) => {
116-
expect(err).to.not.exist
117-
expect(file).to.be.eql(data)
118-
done()
123+
it(`js -> go: ${size}bytes`, (done) => {
124+
const data = crypto.randomBytes(size)
125+
waterfall([
126+
(cb) => jsDaemon.api.add(data, cb),
127+
(res, cb) => goDaemon.api.cat(res[0].hash, cb),
128+
(stream, cb) => stream.pipe(bl(cb))
129+
], (err, file) => {
130+
expect(err).to.not.exist
131+
expect(file).to.be.eql(data)
132+
done()
133+
})
119134
})
120-
})
121135

122-
it('cat file: js -> js', (done) => {
123-
const data = crypto.randomBytes(1024 * 1024)
124-
waterfall([
125-
(cb) => js2Daemon.api.add(data, cb),
126-
(res, cb) => jsDaemon.api.cat(res[0].hash, cb),
127-
(stream, cb) => stream.pipe(bl(cb))
128-
], (err, file) => {
129-
expect(err).to.not.exist
130-
expect(file).to.be.eql(data)
131-
done()
136+
it(`js -> js: ${size}bytes`, (done) => {
137+
const data = crypto.randomBytes(size)
138+
waterfall([
139+
(cb) => js2Daemon.api.add(data, cb),
140+
(res, cb) => jsDaemon.api.cat(res[0].hash, cb),
141+
(stream, cb) => stream.pipe(bl(cb))
142+
], (err, file) => {
143+
expect(err).to.not.exist
144+
expect(file).to.be.eql(data)
145+
done()
146+
})
132147
})
133-
})
148+
}))
134149
})

0 commit comments

Comments
 (0)