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

Commit

Permalink
fix: bring back reverted changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov committed Jan 23, 2018
1 parent 54d4055 commit ceafe3e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 65 deletions.
56 changes: 23 additions & 33 deletions test/cli/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ chai.use(dirtyChai)
const delay = require('delay')
const series = require('async/series')
const ipfsExec = require('../utils/ipfs-exec')
const createRepo = require('../utils/create-repo-nodejs')
const IPFS = require('../../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()
const df = DaemonFactory.create({ type: 'js' })

const config = {
Bootstrap: [],
Expand All @@ -29,59 +28,50 @@ describe('pubsub', function () {
this.timeout(80 * 1000)

let node
let ipfsd
let ipfsdA
let ipfsdB
let cli
let httpApi

const topicA = 'nonscentsA'
const topicB = 'nonscentsB'
const topicC = 'nonscentsC'

let repo = createRepo()
before(function (done) {
this.timeout(60 * 1000)

node = new IPFS({
repo: createRepo(),
init: { bits: 1024 },
EXPERIMENTAL: {
pubsub: true
},
config
})

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

node.once('error', (err) => {
done(err)
})
DaemonFactory
.create({ type: 'proc' })
.spawn({
exec: IPFS,
config,
args: ['--enable-pubsub-experiment']
}, (err, _ipfsd) => {
expect(err).to.not.exist()
ipfsdA = _ipfsd
node = _ipfsd.api
done()
})
})

after((done) => {
node.stop((err) => {
expect(err).to.not.exist()
repo.teardown(done)
})
})
after((done) => ipfsdB.stop(done))

before((done) => {
df.spawn({
type: 'js',
args: ['--enable-pubsub-experiment'],
exec: `${process.cwd()}/src/cli/bin.js`,
exec: `./src/cli/bin.js`,
config
}, (err, _node) => {
}, (err, _ipfsd) => {
expect(err).to.not.exist()
httpApi = _node.api
ipfsd = _node
httpApi.repoPath = ipfsd.repoPath
httpApi = _ipfsd.api
ipfsdB = _ipfsd
httpApi.repoPath = ipfsdB.repoPath
done()
})
})

after((done) => ipfsd.stop(done))
after((done) => ipfsdA.stop(done))
after((done) => ipfsdB.stop(done))

before((done) => {
cli = ipfsExec(httpApi.repoPath)
Expand Down
6 changes: 3 additions & 3 deletions test/cli/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ipfsExec = require('../utils/ipfs-exec')
const parallel = require('async/parallel')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()
const df = DaemonFactory.create({ type: 'js' })

const config = {
Bootstrap: [],
Expand All @@ -36,15 +36,15 @@ describe('swarm', () => {

series([
(cb) => {
df.spawn({ type: 'js', exec: `${process.cwd()}/src/cli/bin.js`, config }, (err, node) => {
df.spawn({ exec: `./src/cli/bin.js`, config }, (err, node) => {
expect(err).to.not.exist()
ipfsA = ipfsExec(node.repoPath)
nodes.push(node)
cb()
})
},
(cb) => {
df.spawn({ type: 'js', exec: `${process.cwd()}/src/cli/bin.js`, config }, (err, node) => {
df.spawn({ exec: `./src/cli/bin.js`, config }, (err, node) => {
expect(err).to.not.exist()
node.api.id((err, id) => {
expect(err).to.not.exist()
Expand Down
11 changes: 6 additions & 5 deletions test/core/bitswap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const isNode = require('detect-node')
const multihashing = require('multihashing-async')
const CID = require('cids')

const IPFS = require('../../src/core')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create({ type: 'js', exec: `./src/cli/bin.js` })
const df = DaemonFactory.create({ type: 'js' })

const dfProc = DaemonFactory.create({ type: 'proc', exec: IPFS })
const dfProc = DaemonFactory.create({ type: 'proc' })

// This gets replaced by '../utils/create-repo-browser.js' in the browser
const createTempRepo = require('../utils/create-repo-nodejs.js')

const IPFS = require('../../src/core')

function makeBlock (callback) {
const d = Buffer.from(`IPFS is awesome ${Math.random()}`)

Expand Down Expand Up @@ -70,6 +70,7 @@ let nodes = []

function addNode (inProcNode, callback) {
df.spawn({
exec: `./src/cli/bin.js`,
config: {
Addresses: {
Swarm: [`/ip4/127.0.0.1/tcp/0/ws`]
Expand Down Expand Up @@ -114,7 +115,7 @@ describe('bitswap', function () {
})
}

dfProc.spawn({ config }, (err, _ipfsd) => {
dfProc.spawn({ exec: IPFS, config }, (err, _ipfsd) => {
expect(err).to.not.exist()
nodes.push(_ipfsd)
inProcNode = _ipfsd.api
Expand Down
32 changes: 8 additions & 24 deletions test/core/kad-dht.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,26 @@ const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const parallel = require('async/parallel')
const IPFS = require('../../src')

const createRepo = require('../utils/create-repo-nodejs')
const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create({ type: 'js' })

const config = {
Addresses: {
Swarm: [`/ip4/127.0.0.1/tcp/0`],
Swarm: [`/ip4/127.0.0.1/tcp/0`, `/ip4/127.0.0.1/tcp/0/ws`],
API: `/ip4/127.0.0.1/tcp/0`,
Gateway: `/ip4/127.0.0.1/tcp/0`
},
Bootstrap: [],
Discovery: {
MDNS: {
Enabled:
false
Enabled: false
}
}
}

function createNode (callback) {
const node = new IPFS({
repo: createRepo(),
init: { bits: 1024 },
EXPERIMENTAL: {
pubsub: true
},
config
})

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

node.once('error', (err) => {
callback(err)
})
df.spawn({ exec: './src/cli/bin.js', config }, callback)
}

describe('verify that kad-dht is doing its thing', () => {
Expand All @@ -62,9 +46,9 @@ describe('verify that kad-dht is doing its thing', () => {
], (err, _nodes) => {
expect(err).to.not.exist()
nodes = _nodes
nodeA = _nodes[0]
nodeB = _nodes[1]
nodeC = _nodes[2]
nodeA = _nodes[0].api
nodeB = _nodes[1].api
nodeC = _nodes[2].api
parallel([
(cb) => nodeA.id(cb),
(cb) => nodeB.id(cb),
Expand Down

0 comments on commit ceafe3e

Please sign in to comment.