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

Commit

Permalink
fix: removing factory
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov committed Dec 23, 2017
1 parent 21c355c commit 53e391b
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 162 deletions.
3 changes: 2 additions & 1 deletion .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ module.exports = {
served: true,
included: false
}],
singleRun: true
singleRun: true,
browserNoActivityTimeout: 100 * 1000
},
hooks: {
browser: {
Expand Down
4 changes: 3 additions & 1 deletion test/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
'use strict'

// require('./exchange-files')
require('./repo')
// require('./pubsub')
// require('./kad-dht')
require('./circuit-relay')
require('./repo')
69 changes: 28 additions & 41 deletions test/circuit-relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const series = require('async/series')
const waterfall = require('async/waterfall')
const multiaddr = require('multiaddr')
const crypto = require('crypto')
const IPFSFactory = require('./utils/ipfs-factory-instance')
const IPFS = require('ipfs')
const createRepo = require('./utils/create-repo-nodejs')

const isNode = require('detect-node')

Expand All @@ -37,19 +38,27 @@ function setupInProcNode (factory, addrs, hop, callback) {
hop = false
}

factory.spawnNode(null, Object.assign({}, baseConf, {
Addresses: {
Swarm: addrs
},
EXPERIMENTAL: {
relay: {
enabled: true,
hop: {
enabled: hop
const node = new IPFS({
repo: createRepo(),
init: { bits: 1024 },
config: Object.assign({}, baseConf, {
Addresses: {
Swarm: addrs
},
EXPERIMENTAL: {
relay: {
enabled: true,
hop: {
enabled: hop
}
}
}
}
}), callback)
})
})

node.once('ready', () => {
callback(null, node)
})
}

function setUpJsNode (addrs, hop, callback) {
Expand Down Expand Up @@ -264,9 +273,7 @@ function tests (relayType) {
return
}

this.timeout(50 * 1000)

let factory
this.timeout(90 * 1000)

let browserNode1
let browserNode2
Expand All @@ -275,11 +282,9 @@ function tests (relayType) {
let browserNode2Addrs

before(function (done) {
factory = new IPFSFactory()

parallel([
(cb) => setupInProcNode(factory, [], false, cb),
(cb) => setupInProcNode(factory, [], false, cb)
(cb) => setupInProcNode([], false, cb),
(cb) => setupInProcNode([], false, cb)
], (err, nodes) => {
expect(err).to.not.exist()
browserNode1 = nodes[0]
Expand All @@ -292,8 +297,6 @@ function tests (relayType) {
})
})

after((done) => factory.dismantle(done))

it('should connect and transfer', function (done) {
const data = crypto.randomBytes(128)
series([
Expand All @@ -316,17 +319,14 @@ function tests (relayType) {

this.timeout(50 * 1000)

let factory

let browserNode1
let jsTCP
let jsTCPAddrs

before(function (done) {
factory = new IPFSFactory()

parallel([
(cb) => setupInProcNode(factory, [], false, cb),
(cb) => setupInProcNode([], false, cb),
(cb) => setUpJsNode([`${base}/35003`], cb)
], (err, nodes) => {
expect(err).to.not.exist()
Expand All @@ -339,12 +339,7 @@ function tests (relayType) {
})
})

after((done) => {
parallel([
(cb) => factory.dismantle(cb),
(cb) => jsTCP.stop(cb)
], done)
})
after((done) => jsTCP.stop(done))

it('should connect and transfer', function (done) {
const data = crypto.randomBytes(128)
Expand All @@ -368,17 +363,14 @@ function tests (relayType) {

this.timeout(50 * 1000)

let factory

let browserNode1
let goTCP
let goTCPAddrs

before(function (done) {
factory = new IPFSFactory()

parallel([
(cb) => setupInProcNode(factory, [], false, cb),
(cb) => setupInProcNode([], false, cb),
(cb) => setUpGoNode([`${base}/35003`], cb)
], (err, nodes) => {
expect(err).to.not.exist()
Expand All @@ -392,12 +384,7 @@ function tests (relayType) {
})
})

after((done) => {
parallel([
(cb) => factory.dismantle(cb),
(cb) => goTCP.stop(cb)
], done)
})
after((done) => goTCP.stop(done))

it('should connect and transfer', function (done) {
const data = crypto.randomBytes(128)
Expand Down
11 changes: 6 additions & 5 deletions test/exchange-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ describe('exchange files', () => {

parallel([
(cb) => df.spawn(cb),
(cb) => df.spawn({ isJs: true }, cb),
(cb) => df.spawn({ isJs: true }, cb)
(cb) => df.spawn({ type: 'js' }, cb),
(cb) => df.spawn({ type: 'js' }, cb)
], (err, n) => {
expect(err).to.not.exist()
nodes = n
Expand Down Expand Up @@ -172,7 +172,8 @@ describe('exchange files', () => {

// TODO these tests are not fetching the full dir??
describe('get directory', () => dirs.forEach((num) => {
it(`go -> js: depth: 5, num: ${num}`, () => {
it(`go -> js: depth: 5, num: ${num}`, function () {
this.timeout(10 * 1000)
const dir = tmpDir()
return randomFs({
path: dir,
Expand All @@ -190,7 +191,7 @@ describe('exchange files', () => {
})

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

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

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

const dir = tmpDir()
return randomFs({
Expand Down
1 change: 1 addition & 0 deletions test/kad-dht.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe.skip('kad-dht', () => {
goD2 = nodes[1]
goD3 = nodes[2]
jsD = nodes[3]
done()
})
})

Expand Down
6 changes: 3 additions & 3 deletions test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

require('./repo')
require('./exchange-files')
require('./circuit-relay')
require('./kad-dht')
require('./pubsub')
// require('./circuit-relay')
// require('./kad-dht')
// require('./pubsub')
47 changes: 28 additions & 19 deletions test/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const waterfall = require('async/waterfall')

const series = require('async/series')
const crypto = require('crypto')
const os = require('os')
const path = require('path')
Expand All @@ -22,8 +23,8 @@ function catAndCheck (api, hash, data, callback) {
})
}

describe.skip('repo', () => {
it.skip('read repo: go -> js', function (done) {
describe('repo', () => {
it('read repo: go -> js', function (done) {
this.timeout(50 * 1000)

const dir = path.join(os.tmpdir(), hat())
Expand All @@ -33,29 +34,37 @@ describe.skip('repo', () => {
let jsDaemon

let hash
waterfall([
series([
(cb) => df.spawn({
repoPath: dir
}, cb),
(node, cb) => {
repoPath: dir,
disposable: false
}, (err, node) => {
expect(err).to.not.exist()
goDaemon = node
goDaemon.api.add(data, cb)
},
(res, cb) => {
goDaemon.init(cb)
}),
(cb) => goDaemon.start(cb),
(cb) => goDaemon.api.add(data, (err, res) => {
expect(err).to.not.exist()
hash = res[0].hash
catAndCheck(goDaemon.api, hash, data, cb)
},
cb()
}),
(cb) => catAndCheck(goDaemon.api, hash, data, cb),
(cb) => goDaemon.stop(cb),
(cb) => df.spawn({
type: 'js',
repoPath: dir
}, cb),
(node, cb) => {
console.dir('HERE')
repoPath: dir,
disposable: false
}, (err, node) => {
expect(err).to.not.exist()
jsDaemon = node
cb()
},
}),
(cb) => jsDaemon.start(cb),
(cb) => catAndCheck(jsDaemon.api, hash, data, cb),
(cb) => jsDaemon.stop(cb)
(cb) => jsDaemon.stop(cb),
(cb) => setTimeout(cb, 10500),
(cb) => jsDaemon.cleanup(cb)
], done)
})

Expand All @@ -70,7 +79,7 @@ describe.skip('repo', () => {
let goDaemon

let hash
waterfall([
series([
(cb) => df.spawn({ type: 'js', repoPath: dir }, cb),
(node, cb) => {
jsDaemon = node
Expand Down
29 changes: 0 additions & 29 deletions test/utils/ipfs-factory-instance/default-config.json

This file was deleted.

Loading

0 comments on commit 53e391b

Please sign in to comment.