Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
test: make exchange file tests more interesting
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Jul 15, 2018
1 parent c53635b commit e4b2c57
Showing 1 changed file with 40 additions and 23 deletions.
63 changes: 40 additions & 23 deletions test/exchange-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,46 @@ function tmpDir () {
return join(os.tmpdir(), `ipfs_${hat()}`)
}

const KB = 1024
const MB = KB * 1024
const GB = KB * 1024

const sizes = [
1024,
1024 * 62,
1 * KB,
62 * KB,
// starts failing with spdy
1024 * 64,
1024 * 512,
1024 * 768,
1024 * 1023,
1024 * 1024,
1024 * 1024 * 4,
1024 * 1024 * 8
64 * KB,
512 * KB,
768 * KB,
1023 * KB,
1 * MB,
4 * MB,
8 * MB,
64 * MB,
128 * MB,
512 * MB,
1 * GB
]

const dirs = [
5,
10,
50,
100
100,
1000
]

describe('exchange files', () => {
const timeout = 120 * 1000

describe.only('exchange files', () => {
let goDaemon
let jsDaemon
let js2Daemon

let nodes

before(function (done) {
this.timeout(50 * 1000)
this.timeout(timeout)

parallel([
(cb) => goDf.spawn({ initOptions: { bits: 1024 } }, cb),
Expand All @@ -77,7 +88,7 @@ describe('exchange files', () => {
after((done) => parallel(nodes.map((node) => (cb) => node.stop(cb)), done))

it('connect go <-> js', function (done) {
this.timeout(50 * 1000)
this.timeout(timeout)

let jsId
let goId
Expand Down Expand Up @@ -107,7 +118,7 @@ describe('exchange files', () => {
})

it('connect js <-> js', function (done) {
this.timeout(50 * 1000)
this.timeout(timeout)

let jsId
let js2Id
Expand Down Expand Up @@ -138,8 +149,10 @@ describe('exchange files', () => {

describe('cat file', () => sizes.forEach((size) => {
it(`go -> js: ${pretty(size)}`, function (done) {
this.timeout(50 * 1000)
this.timeout(timeout)

const data = crypto.randomBytes(size)

waterfall([
(cb) => goDaemon.api.add(data, cb),
(res, cb) => jsDaemon.api.cat(res[0].hash, cb)
Expand All @@ -151,8 +164,10 @@ describe('exchange files', () => {
})

it(`js -> go: ${pretty(size)}`, function (done) {
this.timeout(50 * 1000)
this.timeout(timeout)

const data = crypto.randomBytes(size)

waterfall([
(cb) => jsDaemon.api.add(data, cb),
(res, cb) => goDaemon.api.cat(res[0].hash, cb)
Expand All @@ -164,8 +179,10 @@ describe('exchange files', () => {
})

it(`js -> js: ${pretty(size)}`, function (done) {
this.timeout(20 * 1000)
this.timeout(timeout)

const data = crypto.randomBytes(size)

waterfall([
(cb) => js2Daemon.api.add(data, cb),
(res, cb) => jsDaemon.api.cat(res[0].hash, cb)
Expand All @@ -180,13 +197,13 @@ describe('exchange files', () => {
// TODO these tests are not fetching the full dir??
describe('get directory', () => dirs.forEach((num) => {
// skipping until https://github.com/ipfs/interop/issues/9 is addressed
if (isWindows) {
return
}
if (isWindows) { return }

it(`go -> js: depth: 5, num: ${num}`, function () {
this.timeout(50 * 1000)
this.timeout(timeout)

const dir = tmpDir()

return randomFs({
path: dir,
depth: 5,
Expand All @@ -203,7 +220,7 @@ describe('exchange files', () => {
})

it(`js -> go: depth: 5, num: ${num}`, function () {
this.timeout(50 * 1000)
this.timeout(timeout)

const dir = tmpDir()
return randomFs({
Expand All @@ -222,7 +239,7 @@ describe('exchange files', () => {
})

it(`js -> js: depth: 5, num: ${num}`, function () {
this.timeout(80 * 1000)
this.timeout(timeout)

const dir = tmpDir()
return randomFs({
Expand Down

0 comments on commit e4b2c57

Please sign in to comment.