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

test(interop): add more sizes, get that multiplexing thing done #715

Merged
merged 1 commit into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/interop/daemons/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class JsDaemon {
this.init = opts.init
this.port = opts.port

this.path = opts.path || os.tmpdir() + `/${Math.ceil(Math.random() * 1000)}`
this.path = opts.path || os.tmpdir() + `/${Math.ceil(Math.random() * 10000)}`
if (this.init) {
this.ipfs = new IPFS(this.path)
} else {
Expand Down
83 changes: 49 additions & 34 deletions test/interop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ const crypto = require('crypto')
const GoDaemon = require('./daemons/go')
const JsDaemon = require('./daemons/js')

const sizes = [
1024,
1024 * 62,
// starts failing with spdy
1024 * 64,
1024 * 512,
1024 * 768,
1024 * 1023,
// starts failing with multiplex
1024 * 1024,
1024 * 1024 * 4,
1024 * 1024 * 8
]

describe('basic', () => {
let goDaemon
let jsDaemon
Expand Down Expand Up @@ -92,43 +106,44 @@ describe('basic', () => {
], done)
})

it('cat file: go -> js', (done) => {
const data = crypto.randomBytes(1024 * 1024)
waterfall([
(cb) => goDaemon.api.add(data, cb),
(res, cb) => jsDaemon.api.cat(res[0].hash, cb),
(stream, cb) => stream.pipe(bl(cb))
], (err, file) => {
expect(err).to.not.exist
expect(file).to.be.eql(data)
done()
describe('cat file', () => sizes.forEach((size) => {
it(`go -> js: ${size}bytes`, (done) => {
const data = crypto.randomBytes(size)
waterfall([
(cb) => goDaemon.api.add(data, cb),
(res, cb) => jsDaemon.api.cat(res[0].hash, cb),
(stream, cb) => stream.pipe(bl(cb))
], (err, file) => {
expect(err).to.not.exist
expect(file).to.be.eql(data)
done()
})
})
})

it('cat file: js -> go', (done) => {
// This will fail once the size is increased to 64512 = 1024 * 63
const data = crypto.randomBytes(1024 * 63 - 1)
waterfall([
(cb) => jsDaemon.api.add(data, cb),
(res, cb) => goDaemon.api.cat(res[0].hash, cb),
(stream, cb) => stream.pipe(bl(cb))
], (err, file) => {
expect(err).to.not.exist
expect(file).to.be.eql(data)
done()
it(`js -> go: ${size}bytes`, (done) => {
const data = crypto.randomBytes(size)
waterfall([
(cb) => jsDaemon.api.add(data, cb),
(res, cb) => goDaemon.api.cat(res[0].hash, cb),
(stream, cb) => stream.pipe(bl(cb))
], (err, file) => {
expect(err).to.not.exist
expect(file).to.be.eql(data)
done()
})
})
})

it('cat file: js -> js', (done) => {
const data = crypto.randomBytes(1024 * 1024)
waterfall([
(cb) => js2Daemon.api.add(data, cb),
(res, cb) => jsDaemon.api.cat(res[0].hash, cb),
(stream, cb) => stream.pipe(bl(cb))
], (err, file) => {
expect(err).to.not.exist
expect(file).to.be.eql(data)
done()
it(`js -> js: ${size}bytes`, (done) => {
const data = crypto.randomBytes(size)
waterfall([
(cb) => js2Daemon.api.add(data, cb),
(res, cb) => jsDaemon.api.cat(res[0].hash, cb),
(stream, cb) => stream.pipe(bl(cb))
], (err, file) => {
expect(err).to.not.exist
expect(file).to.be.eql(data)
done()
})
})
})
}))
})