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

Awesome Endeavour: Circuit Relay #830

Merged
merged 19 commits into from
Nov 8, 2017
Merged
Show file tree
Hide file tree
Changes from 16 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
38 changes: 37 additions & 1 deletion .aegir.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@
'use strict'

const parallel = require('async/parallel')
const ads = require('./test/utils/another-daemon-spawner')
const js = ads.spawnJsNode
const go = ads.spawnGoNode
const stop = ads.stopNodes

/*
* spawns a daemon with ports numbers starting in 10 and ending in `num`
*/
function start (done) {
const base = '/ip4/127.0.0.1/tcp'

if (!process.env.IPFS_TEST) {
parallel([
(cb) => js([`${base}/10007`, `${base}/20007/ws`], true, 31007, 32007, cb),
(cb) => js([`${base}/10008`, `${base}/20008/ws`], true, 31008, 32008, cb),
(cb) => js([`${base}/10012`, `${base}/20012/ws`], true, 31012, 32012, cb),
(cb) => js([`${base}/10013`, `${base}/20013/ws`], true, 31013, 32013, cb),
(cb) => js([`${base}/10014`, `${base}/20014/ws`], true, 31014, 32014, cb),
(cb) => js([`${base}/10015`, `${base}/20015/ws`], true, 31015, 32015, cb)
], done)
} else {
parallel([
(cb) => go([`${base}/10027`, `${base}/20027/ws`], true, 33027, 44027, cb),
(cb) => go([`${base}/10028`, `${base}/20028/ws`], true, 33028, 44028, cb),
(cb) => go([`${base}/10031`, `${base}/20031/ws`], true, 33031, 44031, cb),
(cb) => go([`${base}/10032`, `${base}/20032/ws`], true, 33032, 44032, cb)
], done)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you make these spawn daemon tools part of test/utils? This file should have a very declarative feel and just inform the dev what is going to be spawned for testing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I'll move them over.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't the "Spawner" use IPFS Factory?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what are the magic numbers?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The numbers are the preexisting port numbers that this daemons were being started with - I kept them because I believe some other tests might rely on them.


module.exports = {
karma: {
files: [{
pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*',
watched: false,
served: true,
included: false
included: false,
singleRun: false
}]
},
hooks: {
pre: start,
post: stop
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dignifiedquire is there a way to select custom .aegir.js for different runs? Goal here is to have one for interop and another for unit

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, we can have browser.hooks, but not sure if we can have custom tags.

10 changes: 5 additions & 5 deletions examples/exchange-files-in-browser/public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function start () {
if (!node) {
updateView('starting', node)

node = new self.Ipfs({repo: 'ipfs-' + Math.random()})
node = new self.Ipfs({ repo: 'ipfs-' + Math.random() })

node.on('start', () => {
node.id().then((id) => {
Expand All @@ -55,7 +55,7 @@ function stop () {
*/

function createFileBlob (data, multihash) {
const file = new window.Blob(data, {type: 'application/octet-binary'})
const file = new window.Blob(data, { type: 'application/octet-binary' })
const fileUrl = window.URL.createObjectURL(file)

const listItem = document.createElement('div')
Expand Down Expand Up @@ -151,7 +151,7 @@ function onDrop (event) {

let myReadableStreamBuffer = new streamBuffers.ReadableStreamBuffer({
// frequency: 10, // in milliseconds.
chunkSize: 32048 // in bytes.
chunkSize: 32048 // in bytes.
})

node.files.createAddStream((err, stream) => {
Expand Down Expand Up @@ -200,8 +200,8 @@ function onDrop (event) {
if (files && files.length) {
$multihashInput.value = files[0].hash
$filesStatus.innerHTML = files
.map((e) => `Added ${e.path} as ${e.hash}`)
.join('<br>')
.map((e) => `Added ${e.path} as ${e.hash}`)
.join('<br>')
}
})
.catch(onError)
Expand Down
2 changes: 1 addition & 1 deletion examples/traverse-ipld-graphs/get-path-accross-formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ createNode((err, ipfs) => {

series([
(cb) => {
const someData = new Buffer('capoeira')
const someData = Buffer.from('capoeira')

dagPB.DAGNode.create(someData, (err, node) => {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion examples/traverse-ipld-graphs/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ createNode((err, ipfs) => {

series([
(cb) => {
const someData = new Buffer('capoeira')
const someData = Buffer.from('capoeira')

dagPB.DAGNode.create(someData, (err, node) => {
if (err) {
Expand Down
64 changes: 0 additions & 64 deletions gulpfile.js

This file was deleted.

73 changes: 37 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,29 @@
"npm": ">=3.0.0"
},
"scripts": {
"lint": "aegir-lint",
"coverage": "gulp coverage",
"test": "gulp test --dom",
"test:node": "npm run test:unit:node",
"test:browser": "npm run test:unit:browser",
"test:unit:node": "gulp test:node",
"test:unit:node:core": "TEST=core npm run test:unit:node",
"test:unit:node:http": "TEST=http npm run test:unit:node",
"test:unit:node:gateway": "TEST=gateway npm run test:unit:node",
"test:unit:node:cli": "TEST=cli npm run test:unit:node",
"test:unit:browser": "gulp test:browser",
"test:interop": "npm run test:interop:node",
"test:interop:node": "mocha -t 60000 test/interop/node.js",
"test:interop:browser": "mocha -t 60000 test/interop/browser.js",
"lint": "aegir lint",
"build": "aegir build",
"test": "aegir test -t node -t browser --no-cors",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser -t webworker --no-cors",
"release": "aegir release -t node -t browser",
"release-minor": "aegir release --type minor -t node -t browser",
"release-major": "aegir release --type major -t node -t browser",
"test:unit:node": "aegir test -t node",
"test:unit:node:core": "aegir test -t node -f test/core/*.js",
"test:unit:node:http": "aegir test -t node -f test/http-api/index.js",
"test:unit:node:gateway": "aegir test -t node -f test/gateway/index.js",
"test:unit:node:cli": "aegir test -t node -f test/cli/index.js",
"test:unit:browser": "aegir test -t browser --no-cors",
"test:interop": "IPFS_TEST=interop aegir test -t node -t browser -f test/interop",
"test:interop:node": "IPFS_TEST=interop aegir test -t node -f test/interop/node.js",
"test:interop:browser": "IPFS_TEST=interop aegir test -t browser -f test/interop/browser.js",
"test:benchmark": "echo \"Error: no benchmarks yet\" && exit 1",
"test:benchmark:node": "echo \"Error: no benchmarks yet\" && exit 1",
"test:benchmark:node:core": "echo \"Error: no benchmarks yet\" && exit 1",
"test:benchmark:node:http": "echo \"Error: no benchmarks yet\" && exit 1",
"test:benchmark:browser": "echo \"Error: no benchmarks yet\" && exit 1",
"build": "gulp build",
"release": "gulp release",
"release-minor": "gulp release --type minor",
"release-major": "gulp release --type major",
"coverage": "aegir coverage",
"coverage-publish": "aegir-coverage publish"
},
"pre-commit": [
Expand All @@ -62,7 +62,7 @@
},
"homepage": "https://github.com/ipfs/js-ipfs#readme",
"devDependencies": {
"aegir": "^11.0.2",
"aegir": "^12.1.3",
"buffer-loader": "0.0.1",
"chai": "^4.1.2",
"delay": "^2.0.0",
Expand All @@ -74,7 +74,7 @@
"expose-loader": "^0.7.3",
"form-data": "^2.3.1",
"gulp": "^3.9.1",
"interface-ipfs-core": "~0.32.1",
"interface-ipfs-core": "~0.33.1",
"ipfsd-ctl": "~0.24.0",
"left-pad": "^1.1.3",
"lodash": "^4.17.4",
Expand All @@ -90,9 +90,9 @@
"transform-loader": "^0.2.4"
},
"dependencies": {
"async": "^2.5.0",
"async": "^2.6.0",
"bl": "^1.2.1",
"boom": "^6.0.0",
"boom": "^7.1.1",
"byteman": "^1.3.5",
"cids": "^0.5.2",
"debug": "^3.1.0",
Expand All @@ -103,20 +103,21 @@
"glob": "^7.1.2",
"hapi": "^16.6.2",
"hapi-set-header": "^1.0.2",
"hoek": "^5.0.0",
"ipfs-api": "^14.3.7",
"hoek": "^5.0.2",
"ipfs-api": "^15.0.1",
"ipfs-bitswap": "~0.17.2",
"ipfs-block": "~0.6.0",
"ipfs-block-service": "~0.12.0",
"ipfs-block": "~0.6.1",
"ipfs-block-service": "~0.13.0",
"ipfs-multipart": "~0.1.0",
"ipfs-repo": "~0.17.0",
"ipfs-unixfs": "~0.1.13",
"ipfs-unixfs-engine": "~0.22.5",
"ipld-resolver": "~0.13.4",
"ipfs-repo": "~0.18.3",
"ipfs-unixfs": "~0.1.14",
"ipfs-unixfs-engine": "~0.23.0",
"ipld-resolver": "~0.14.1",
"is-ipfs": "^0.3.2",
"is-stream": "^1.1.0",
"joi": "^13.0.1",
"libp2p": "~0.12.4",
"libp2p": "~0.13.0",
"libp2p-circuit": "~0.1.4",
"libp2p-floodsub": "~0.11.1",
"libp2p-kad-dht": "~0.5.1",
"libp2p-mdns": "~0.9.1",
Expand All @@ -125,12 +126,12 @@
"libp2p-secio": "~0.8.1",
"libp2p-tcp": "~0.11.1",
"libp2p-webrtc-star": "~0.13.2",
"libp2p-websockets": "~0.10.2",
"libp2p-websockets": "~0.10.4",
"lodash.flatmap": "^4.5.0",
"lodash.get": "^4.4.2",
"lodash.sortby": "^4.7.0",
"lodash.values": "^4.3.0",
"mafmt": "^3.0.1",
"mafmt": "^3.0.2",
"mime-types": "^2.1.17",
"mkdirp": "~0.5.1",
"multiaddr": "^3.0.1",
Expand All @@ -151,18 +152,18 @@
"pull-stream": "^3.6.1",
"pull-stream-to-stream": "^1.3.4",
"pull-zip": "^2.0.1",
"read-pkg-up": "^2.0.0",
"read-pkg-up": "^3.0.0",
"readable-stream": "2.3.3",
"safe-buffer": "^5.1.1",
"stream-to-pull-stream": "^1.7.2",
"tar-stream": "^1.5.4",
"temp": "~0.8.3",
"through2": "^2.0.3",
"update-notifier": "^2.3.0",
"yargs": "9.0.1"
"yargs": "^10.0.3"
},
"optionalDependencies": {
"prom-client": "^10.2.0",
"prom-client": "^10.2.2",
"prometheus-gc-stats": "^0.5.0"
},
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/bitswap/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {

stats.Wantlist = stats.Wantlist || []
stats.Wantlist = stats.Wantlist.map((entry) => {
const buf = new Buffer(entry.cid.hash.data)
const buf = Buffer.from(entry.cid.hash.data)
const cid = new CID(entry.cid.version, entry.cid.codec, buf)
return cid.toBaseEncodedString()
})
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/config/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = {

function saveConfig (config, next) {
config = utils.isDaemonOn()
? new Buffer(JSON.stringify(config)) : config
? Buffer.from(JSON.stringify(config)) : config

argv.ipfs.config.replace(config, (err) => {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/pubsub/pub.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
builder: {},

handler (argv) {
const data = new Buffer(String(argv.data))
const data = Buffer.from(String(argv.data))

argv.ipfs.pubsub.publish(argv.topic, data, (err) => {
if (err) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ module.exports = (self) => {
// fail the whole process.
// TODO: improve datastore and ipfs-repo implemenations so this error is a bit more unified
if (err.message.match(/not found/) || // indexeddb
err.message.match(/ENOENT/) || // fs
err.message.match(/No value/) // memory
) {
err.message.match(/ENOENT/) || // fs
err.message.match(/No value/) // memory
) {
return cb(null, false)
}
return cb(err)
Expand Down
8 changes: 4 additions & 4 deletions src/core/components/id.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ module.exports = function id (self) {
id: self._peerInfo.id.toB58String(),
publicKey: self._peerInfo.id.pubKey.bytes.toString('base64'),
addresses: self._peerInfo.multiaddrs
.toArray()
.map((ma) => ma.toString())
.filter((ma) => ma.indexOf('ipfs') >= 0)
.sort(),
.toArray()
.map((ma) => ma.toString())
.filter((ma) => ma.indexOf('ipfs') >= 0)
.sort(),
agentVersion: 'js-ipfs',
protocolVersion: '9000'
}))
Expand Down
14 changes: 4 additions & 10 deletions src/core/components/init-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,14 @@ module.exports = function addDefaultAssets (self, log, callback) {

pull(
pull.values([initDocsPath]),
pull.asyncMap((val, cb) => {
glob(path.join(val, '/**/*'), cb)
}),
pull.asyncMap((val, cb) => glob(path.join(val, '/**/*'), cb)),
pull.flatten(),
pull.map((element) => {
const addPath = element.substring(index + 1)
if (fs.statSync(element).isDirectory()) {
return
}

return {
path: addPath,
content: file(element)
}
if (fs.statSync(element).isDirectory()) { return }

return { path: addPath, content: file(element) }
}),
// Filter out directories, which are undefined from above
pull.filter(Boolean),
Expand Down
Loading