diff --git a/.aegir.js b/.aegir.js
index 93a928004c..a8b6c78773 100644
--- a/.aegir.js
+++ b/.aegir.js
@@ -1,20 +1,33 @@
'use strict'
-const IPFSFactory = require('ipfsd-ctl')
+const { createServer } = require('ipfsd-ctl')
const MockPreloadNode = require('./test/utils/mock-preload-node')
const EchoServer = require('interface-ipfs-core/src/utils/echo-http-server')
+const webRTCStarSigServer = require('libp2p-webrtc-star/src/sig-server')
+const path = require('path')
+const webpack = require('webpack')
+const os = require('os')
-const ipfsdServer = IPFSFactory.createServer()
const preloadNode = MockPreloadNode.createNode()
const echoServer = EchoServer.createServer()
+// the second signalling server is needed for the inferface test 'should list peers only once even if they have multiple addresses'
+let sigServerA
+let sigServerB
+let ipfsdServer
+
module.exports = {
bundlesize: { maxSize: '652kB' },
webpack: {
resolve: {
mainFields: ['browser', 'main'],
aliasFields: ['browser', 'browser-all-ipld-formats'],
- }
+ },
+ ...(process.env.NODE_ENV === 'test' ? {
+ plugins: [
+ new webpack.EnvironmentPlugin(['DEBUG'])
+ ]
+ } : {})
},
karma: {
files: [{
@@ -39,14 +52,53 @@ module.exports = {
},
browser: {
pre: async () => {
- await ipfsdServer.start()
- await preloadNode.start()
- await echoServer.start()
+ await preloadNode.start()
+ await echoServer.start()
+ sigServerA = await webRTCStarSigServer.start({
+ host: '127.0.0.1',
+ port: 14579,
+ metrics: false
+ })
+ sigServerB = await webRTCStarSigServer.start({
+ host: '127.0.0.1',
+ port: 14578,
+ metrics: false
+ })
+ ipfsdServer = await createServer({
+ host: '127.0.0.1',
+ port: 43134
+ }, {
+ type: 'js',
+ ipfsModule: {
+ path: __dirname,
+ ref: require(__dirname)
+ },
+ ipfsHttpModule: {
+ path: require.resolve('ipfs-http-client'),
+ ref: require('ipfs-http-client')
+ },
+ ipfsBin: path.join(__dirname, 'src', 'cli', 'bin.js'),
+ ipfsOptions: {
+ config: {
+ libp2p: {
+ dialer: {
+ dialTimeout: 60e3 // increase timeout because travis is slow
+ }
+ }
+ }
+ }
+ }, {
+ go: {
+ ipfsBin: require.resolve(`go-ipfs-dep/go-ipfs/ipfs${os.platform() === 'win32' ? '.exe' : ''}`)
+ }
+ }).start()
},
post: async () => {
- await ipfsdServer.stop()
- await preloadNode.stop()
- await echoServer.stop()
+ await ipfsdServer.stop()
+ await preloadNode.stop()
+ await echoServer.stop()
+ await sigServerA.stop()
+ await sigServerB.stop()
}
}
}
diff --git a/.travis.yml b/.travis.yml
index 1672d57a02..e816ea620b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -52,14 +52,28 @@ jobs:
addons:
chrome: stable
script:
- - npx aegir test -t browser -t webworker
+ - npx aegir test -t browser --bail
+
+ - stage: test
+ name: chrome webworker
+ addons:
+ chrome: stable
+ script:
+ - npx aegir test -t webworker --bail
- stage: test
name: firefox
addons:
firefox: latest
script:
- - npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless
+ - npx aegir test -t browser --bail -- --browsers FirefoxHeadless
+
+ - stage: test
+ name: firefox webworker
+ addons:
+ firefox: latest
+ script:
+ - npx aegir test -t webworker --bail -- --browsers FirefoxHeadless
- stage: test
name: electron-main
@@ -76,44 +90,24 @@ jobs:
- stage: test
name: interop - node
script:
- - mkdir -p node_modules/ipfs-interop/node_modules
- - ln -s `pwd` node_modules/ipfs-interop/node_modules/ipfs
- - export IPFS_JS_EXEC=`pwd`/src/cli/bin.js
- - export IPFS_REUSEPORT=false
- - cd node_modules/ipfs-interop
- - npx aegir test -t node --bail
+ - npm run test:interop:node -- --bail
- stage: test
name: interop - browser
script:
- - mkdir -p node_modules/ipfs-interop/node_modules
- - ln -s `pwd` node_modules/ipfs-interop/node_modules/ipfs
- - export IPFS_JS_EXEC=`pwd`/src/cli/bin.js
- - export IPFS_REUSEPORT=false
- - cd node_modules/ipfs-interop
- - npx aegir test -t browser --bail
+ - npm run test:interop:browser -- --bail
- stage: test
name: interop - electron-main
os: osx
script:
- - mkdir -p node_modules/ipfs-interop/node_modules
- - ln -s `pwd` node_modules/ipfs-interop/node_modules/ipfs
- - export IPFS_JS_EXEC=`pwd`/src/cli/bin.js
- - export IPFS_REUSEPORT=false
- - cd node_modules/ipfs-interop
- - npx aegir test -t electron-main -f ./test/node.js --bail --timeout 10000
+ - npm run test:interop:electron-main -- --bail --timeout 10000
- stage: test
name: interop - electron-renderer
os: osx
script:
- - mkdir -p node_modules/ipfs-interop/node_modules
- - ln -s `pwd` node_modules/ipfs-interop/node_modules/ipfs
- - export IPFS_JS_EXEC=`pwd`/src/cli/bin.js
- - export IPFS_REUSEPORT=false
- - cd node_modules/ipfs-interop
- - npx aegir test -t electron-renderer -f ./test/browser.js --bail --timeout 10000
+ - npm run test:interop:electron-renderer -- --bail --timeout 10000
- stage: test
name: external - ipfs-companion
@@ -128,7 +122,7 @@ jobs:
- stage: test
name: external - ipfs-pubsub-room
script:
- - npm run test:external -- ipfs-pubsub-room https://github.com/ipfs-shipyard/ipfs-pubsub-room.git --branch upgrade-to-latest-js-ipfs-rc
+ - npm run test:external -- ipfs-pubsub-room https://github.com/ipfs-shipyard/ipfs-pubsub-room.git
- stage: test
name: external - peer-base
diff --git a/README.md b/README.md
index 93c08d2b2c..2e00436b55 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@
-### Project status - `Alpha`
+### Project status - `Alpha`
We've come a long way, but this project is still in Alpha, lots of development is happening, API might change, beware of the Dragons 🐉..
@@ -40,19 +40,16 @@ We've come a long way, but this project is still in Alpha, lots of development i
[**`Weekly Core Implementations Call`**](https://github.com/ipfs/team-mgmt/issues/992)
-## Tech Lead
+## Tech Lead
[David Dias](https://github.com/daviddias)
-## Lead Maintainer
+## Lead Maintainer
[Alan Shaw](https://github.com/alanshaw)
-## Table of Contents
+## Table of Contents
-- [Tech Lead](#tech-lead)
-- [Lead Maintainer](#lead-maintainer)
-- [Table of Contents](#table-of-contents)
- [Install](#install)
- [npm](#npm)
- [Use in Node.js](#use-in-nodejs)
@@ -66,6 +63,7 @@ We've come a long way, but this project is still in Alpha, lots of development i
- [API](#api)
- [IPFS Constructor](#ipfs-constructor)
- [`options.repo`](#optionsrepo)
+ - [`options.repoAutoMigrate`](#optionsrepoautomigrate)
- [`options.init`](#optionsinit)
- [`options.start`](#optionsstart)
- [`options.pass`](#optionspass)
@@ -1106,7 +1104,7 @@ Listing of the main packages used in the IPFS ecosystem. There are also three sp
| [`ipfs-mfs`](//github.com/ipfs/js-ipfs-mfs) | [![npm](https://img.shields.io/npm/v/ipfs-mfs.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-mfs/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-mfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-mfs) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-mfs.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-mfs) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-mfs/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-mfs) | [Alex Potsides](mailto:alex.potsides@protocol.ai) |
| [`ipfs-unixfs`](//github.com/ipfs/js-ipfs-unixfs) | [![npm](https://img.shields.io/npm/v/ipfs-unixfs.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-unixfs/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-unixfs.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-unixfs) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-unixfs.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-unixfs) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-unixfs/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-unixfs) | [Alex Potsides](mailto:alex.potsides@protocol.ai) |
| **Repo** |
-| [`ipfs-repo`](//github.com/ipfs/js-ipfs-repo) | [![npm](https://img.shields.io/npm/v/ipfs-repo.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-repo/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-repo.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-repo) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-repo.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-repo) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-repo/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-repo) | [Jacob Heun](mailto:jacobheun@gmail.com) |
+| [`ipfs-repo`](//github.com/ipfs/js-ipfs-repo) | [![npm](https://img.shields.io/npm/v/ipfs-repo.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-repo/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-repo.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-repo) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-repo.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-repo) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-repo/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-repo) | [Alex Potsides](mailto:alex.potsides@protocol.ai) |
| **Exchange** |
| [`ipfs-block-service`](//github.com/ipfs/js-ipfs-block-service) | [![npm](https://img.shields.io/npm/v/ipfs-block-service.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-block-service/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-block-service.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-block-service) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-block-service.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-block-service) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-block-service/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-block-service) | [Volker Mische](mailto:volker.mische@gmail.com) |
| [`ipfs-block`](//github.com/ipfs/js-ipfs-block) | [![npm](https://img.shields.io/npm/v/ipfs-block.svg?maxAge=86400&style=flat-square)](//github.com/ipfs/js-ipfs-block/releases) | [![Deps](https://david-dm.org/ipfs/js-ipfs-block.svg?style=flat-square)](https://david-dm.org/ipfs/js-ipfs-block) | [![Travis CI](https://flat.badgen.net/travis/ipfs/js-ipfs-block.svg?branch=master)](https://travis-ci.com/ipfs/js-ipfs-block) | [![codecov](https://codecov.io/gh/ipfs/js-ipfs-block/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-ipfs-block) | [Volker Mische](mailto:volker.mische@gmail.com) |
diff --git a/examples/browser-video-streaming/index.html b/examples/browser-video-streaming/index.html
index 2b33f7debf..29b2cac70e 100644
--- a/examples/browser-video-streaming/index.html
+++ b/examples/browser-video-streaming/index.html
@@ -2,7 +2,7 @@
-
+
diff --git a/examples/browser-video-streaming/streaming.js b/examples/browser-video-streaming/streaming.js
index d42631a73e..2781419613 100644
--- a/examples/browser-video-streaming/streaming.js
+++ b/examples/browser-video-streaming/streaming.js
@@ -2,7 +2,6 @@
/* global Hls Ipfs HlsjsIpfsLoader */
/* eslint-env browser */
-
document.addEventListener('DOMContentLoaded', async () => {
const testHash = 'QmdpAidwAsBGptFB3b6A9Pyi5coEbgjHrL3K2Qrsutmj9K'
const repoPath = 'ipfs-' + Math.random()
diff --git a/examples/circuit-relaying/package.json b/examples/circuit-relaying/package.json
index 7261bfa83f..e317e9d15c 100644
--- a/examples/circuit-relaying/package.json
+++ b/examples/circuit-relaying/package.json
@@ -15,7 +15,7 @@
"license": "MIT",
"dependencies": {
"ipfs": "file:../../",
- "ipfs-pubsub-room": "^1.4.0"
+ "ipfs-pubsub-room": "^2.0.1"
},
"devDependencies": {
"aegir": "^20.0.0",
diff --git a/examples/circuit-relaying/src/helpers.js b/examples/circuit-relaying/src/helpers.js
index 26a277ef2a..61330bf212 100644
--- a/examples/circuit-relaying/src/helpers.js
+++ b/examples/circuit-relaying/src/helpers.js
@@ -15,7 +15,7 @@ const mkRoomName = (name) => {
module.exports = (ipfs, peersSet) => {
const createRoom = (name) => {
- const room = Room(ipfs, mkRoomName(name))
+ const room = new Room(ipfs, mkRoomName(name))
room.on('peer joined', (peer) => {
console.log('peer ' + peer + ' joined')
diff --git a/examples/circuit-relaying/test.js b/examples/circuit-relaying/test.js
index 499abc69f4..955f6580fe 100644
--- a/examples/circuit-relaying/test.js
+++ b/examples/circuit-relaying/test.js
@@ -66,7 +66,9 @@ async function runTest () {
try {
const id = await ipfsd.api.id()
- const address = id.addresses.filter(addr => addr.includes('/ws/ipfs/Qm')).pop()
+ const address = id.addresses
+ .map(ma => ma.toString())
+ .find(addr => addr.includes('/ws/p2p/Qm'))
if (!address) {
throw new Error(`Could not find web socket address in ${id.addresses}`)
diff --git a/examples/custom-ipfs-repo/index.js b/examples/custom-ipfs-repo/index.js
index 8458bf7209..058bbd2ec3 100644
--- a/examples/custom-ipfs-repo/index.js
+++ b/examples/custom-ipfs-repo/index.js
@@ -3,6 +3,7 @@
const IPFS = require('ipfs')
const Repo = require('ipfs-repo')
const fsLock = require('ipfs-repo/src/lock')
+const all = require('it-all')
// Create our custom options
const customRepositoryOptions = {
@@ -79,19 +80,19 @@ async function main () {
console.log('Version:', version)
// Once we have the version, let's add a file to IPFS
- const filesAdded = await node.add({
+ for await (const file of node.add({
path: 'test-data.txt',
content: Buffer.from('We are using a customized repo!')
- })
-
- // Log out the added files metadata and cat the file from IPFS
- console.log('\nAdded file:', filesAdded[0].path, filesAdded[0].hash)
+ })) {
+ // Log out the added files metadata and cat the file from IPFS
+ console.log('\nAdded file:', file.path, file.cid)
- const data = await node.cat(filesAdded[0].hash)
+ const data = Buffer.concat(await all(node.cat(file.cid)))
- // Print out the files contents to console
- console.log('\nFetched file content:')
- process.stdout.write(data)
+ // Print out the files contents to console
+ console.log('\nFetched file content:')
+ process.stdout.write(data)
+ }
// After everything is done, shut the node down
console.log('\n\nStopping the node')
diff --git a/examples/custom-ipfs-repo/package.json b/examples/custom-ipfs-repo/package.json
index f7289d7bca..7e52503e29 100644
--- a/examples/custom-ipfs-repo/package.json
+++ b/examples/custom-ipfs-repo/package.json
@@ -11,7 +11,8 @@
"dependencies": {
"datastore-fs": "^0.9.1",
"ipfs": "file:../../",
- "ipfs-repo": "^0.28.0"
+ "ipfs-repo": "^0.28.0",
+ "it-all": "^1.0.1"
},
"devDependencies": {
"execa": "^3.2.0"
diff --git a/examples/custom-libp2p/index.js b/examples/custom-libp2p/index.js
index fa1a097b86..1b5d2387e8 100644
--- a/examples/custom-libp2p/index.js
+++ b/examples/custom-libp2p/index.js
@@ -1,14 +1,13 @@
'use strict'
const Libp2p = require('libp2p')
-const IPFS = require('ipfs')
+const IPFS = require('../../')
const TCP = require('libp2p-tcp')
const MulticastDNS = require('libp2p-mdns')
-const WebSocketStar = require('libp2p-websocket-star')
const Bootstrap = require('libp2p-bootstrap')
const SPDY = require('libp2p-spdy')
const KadDHT = require('libp2p-kad-dht')
-const MPLEX = require('pull-mplex')
+const MPLEX = require('libp2p-mplex')
const SECIO = require('libp2p-secio')
/**
@@ -32,11 +31,6 @@ const libp2pBundle = (opts) => {
const peerBook = opts.peerBook
const bootstrapList = opts.config.Bootstrap
- // Create our WebSocketStar transport and give it our PeerId, straight from the ipfs node
- const wsstar = new WebSocketStar({
- id: peerInfo.id
- })
-
// Build and return our libp2p node
return new Libp2p({
peerInfo,
@@ -49,8 +43,7 @@ const libp2pBundle = (opts) => {
},
modules: {
transport: [
- TCP,
- wsstar
+ TCP
],
streamMuxer: [
MPLEX,
@@ -61,8 +54,7 @@ const libp2pBundle = (opts) => {
],
peerDiscovery: [
MulticastDNS,
- Bootstrap,
- wsstar.discovery
+ Bootstrap
],
dht: KadDHT
},
diff --git a/examples/custom-libp2p/package.json b/examples/custom-libp2p/package.json
index 197b8d5c5f..62c1a398fc 100644
--- a/examples/custom-libp2p/package.json
+++ b/examples/custom-libp2p/package.json
@@ -9,18 +9,16 @@
},
"license": "MIT",
"dependencies": {
- "ipfs": "file:../../",
- "libp2p": "^0.26.2",
- "libp2p-bootstrap": "~0.9.7",
- "libp2p-kad-dht": "~0.16.0",
- "libp2p-mdns": "~0.12.2",
- "libp2p-secio": "~0.11.1",
- "libp2p-spdy": "~0.13.3",
- "libp2p-tcp": "~0.13.0",
- "libp2p-websocket-star": "~0.10.2",
- "pull-mplex": "~0.1.0"
+ "libp2p": "^0.27.0-rc.0",
+ "libp2p-bootstrap": "^0.10.3",
+ "libp2p-kad-dht": "^0.18.3",
+ "libp2p-mdns": "^0.13.1",
+ "libp2p-mplex": "^0.9.3",
+ "libp2p-secio": "^0.12.2",
+ "libp2p-spdy": "^0.13.3",
+ "libp2p-tcp": "^0.14.3"
},
"devDependencies": {
- "execa": "^3.2.0"
+ "execa": "^4.0.0"
}
}
diff --git a/examples/custom-libp2p/test.js b/examples/custom-libp2p/test.js
index b4666f67b9..3240104e38 100644
--- a/examples/custom-libp2p/test.js
+++ b/examples/custom-libp2p/test.js
@@ -5,13 +5,11 @@ const execa = require('execa')
const Libp2p = require('libp2p')
const TCP = require('libp2p-tcp')
const SPDY = require('libp2p-spdy')
-const MPLEX = require('pull-mplex')
+const MPLEX = require('libp2p-mplex')
const SECIO = require('libp2p-secio')
const PeerInfo = require('peer-info')
const PeerId = require('peer-id')
const multiaddr = require('multiaddr')
-const promisify = require('promisify-es6')
-const PeerBook = require('peer-book')
async function test () {
let output = ''
@@ -31,12 +29,11 @@ async function test () {
console.info('Dialling', address)
- const peerInfo = new PeerInfo(await promisify(PeerId.create)())
+ const peerInfo = new PeerInfo(await PeerId.create())
peerInfo.multiaddrs.add(multiaddr('/ip4/127.0.0.1/tcp/0'))
const libp2p = new Libp2p({
peerInfo,
- peerBook: new PeerBook(),
modules: {
transport: [
TCP
diff --git a/examples/exchange-files-in-browser/README.md b/examples/exchange-files-in-browser/README.md
index adb86df2fb..30a4f47edc 100644
--- a/examples/exchange-files-in-browser/README.md
+++ b/examples/exchange-files-in-browser/README.md
@@ -2,7 +2,7 @@
This tutorial will help you exchange files between browser nodes and go-ipfs or js-ipfs nodes!
-**Note:** As `js-ipfs@0.33.x` currently doesn't support DHT peer discovery, the peer from which you are fetching data should be within the reach (local or in public IP) of the browser node.
+**Note:** As `js-ipfs@0.41.x` currently doesn't support DHT peer discovery, the peer from which you are fetching data should be within the reach (local or in public IP) of the browser node.
That being said, we will explain how to circumvent these caveats and once they are fixed, we'll update the tutorial as well.
@@ -35,9 +35,10 @@ Here's what we are going to be doing:
1. Install a `go-ipfs` or `js-ipfs` node in your machine
2. Make your daemons listen on WebSockets
-3. Start the app
-4. Dial to a node using WebSockets (your desktop ones)
-5. Transfer files between all of your nodes!
+3. Start a `libp2p-webrtc-star` signaling server
+4. Start the app
+5. Dial to a node using WebSockets (your desktop ones)
+6. Transfer files between all of your nodes!
Just follow the instructions below and it will be up and running in no time!
@@ -121,7 +122,25 @@ Daemon is ready
Check the `/ws` in line 5, that means it is listening. Cool.
-### 3. Start the app
+### 3. Start a `libp2p-webrtc-star` signaling server
+
+This server allows the two browser nodes to talk to each other by doing the initial handshake and network introductions.
+
+First install the `libp2p-webrtc-star` module globally:
+
+```sh
+> npm install -g libp2p-webrtc-star
+```
+
+This will give you the `webrtc-star` command. Use this to start a signaling server:
+
+```sh
+> webrtc-star
+```
+
+By default it will listen to all incoming connections on port 13579. Override this with the `--host` and/or `--port` options.
+
+### 4. Start the app
Make sure you're in `js-ipfs/examples/exchange-files-in-browser`.
@@ -147,7 +166,7 @@ Hit CTRL-C to stop the server
Now go to http://127.0.0.1:12345 in a modern browser and you're on!
-### 4. Dial to a node using WebSockets (your desktop ones)
+### 5. Dial to a node using WebSockets (your desktop ones)
Make sure you have a daemon running. If you don't, run:
@@ -179,7 +198,7 @@ Check that you got connected:
[js-libp2p-crypto#105]: https://github.com/libp2p/js-libp2p-crypto/issues/105
-### 5. Transfer files between all of your nodes!
+### 6. Transfer files between all of your nodes!
Now you can add files through the CLI with:
diff --git a/examples/exchange-files-in-browser/public/app.js b/examples/exchange-files-in-browser/public/app.js
index f23ca84f14..29a3850a88 100644
--- a/examples/exchange-files-in-browser/public/app.js
+++ b/examples/exchange-files-in-browser/public/app.js
@@ -1,7 +1,7 @@
/* global location */
'use strict'
-const IPFS = require('ipfs')
+const IPFS = require('../../../dist')
const { Buffer } = IPFS
// Node
@@ -31,7 +31,7 @@ const $workspaceInput = document.querySelector('#workspace-input')
const $workspaceBtn = document.querySelector('#workspace-btn')
let FILES = []
-let workspace = location.hash
+let workspace = (location.hash || 'default-workspace').replace(/^#/, '')
let fileSize = 0
@@ -44,20 +44,30 @@ let info
async function start () {
if (!node) {
- const options = {
+ node = await IPFS.create({
repo: 'ipfs-' + Math.random(),
config: {
Addresses: {
- Swarm: ['/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star']
+ Swarm: [
+ // This is a public webrtc-star server
+ // '/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star'
+ '/ip4/127.0.0.1/tcp/13579/wss/p2p-webrtc-star'
+ ]
}
}
- }
-
- node = await IPFS.create(options)
+ })
try {
info = await node.id()
- updateView('ready', node)
+
+ const addressesHtml = info.addresses.map((address) => {
+ return `${address}
`
+ }).join('')
+ $nodeId.innerText = info.id
+ $nodeAddresses.innerHTML = addressesHtml
+ $allDisabledButtons.forEach(b => { b.disabled = false })
+ $allDisabledInputs.forEach(b => { b.disabled = false })
+ $allDisabledElements.forEach(el => { el.classList.remove('disabled') })
} catch (err) {
return onError(err)
}
@@ -114,7 +124,7 @@ async function start () {
=========================================================================== */
const messageHandler = (message) => {
- const myNode = info.id
+ const myNode = info.id.toString()
const hash = message.data.toString()
const messageSender = message.from
@@ -127,7 +137,7 @@ const messageHandler = (message) => {
const subscribeToWorkpsace = async () => {
await node.pubsub.subscribe(workspace, messageHandler)
- const msg = `Subscribed to workspace ${workspace}`
+ const msg = `Subscribed to workspace '${workspace}'`
$logs.innerHTML = msg
}
@@ -138,7 +148,7 @@ const workspaceUpdated = async () => {
FILES = []
$fileHistory.innerHTML = ''
- workspace = location.hash
+ workspace = location.hash.replace(/^#/, '')
await subscribeToWorkpsace()
}
@@ -207,15 +217,13 @@ async function getFile () {
FILES.push(hash)
- const files = await node.get(hash)
-
- return Promise.all(files.map(async (file) => {
+ for await (const file of node.get(hash)) {
if (file.content) {
await appendFile(file.name, hash, file.size, file.content)
onSuccess(`The ${file.name} file was added.`)
$emptyRow.style.display = 'none'
}
- }))
+ }
}
/* Drag & Drop
@@ -272,10 +280,11 @@ async function refreshPeerList () {
.map((peer) => {
if (peer.addr) {
const addr = peer.addr.toString()
- if (addr.indexOf('ipfs') >= 0) {
+
+ if (addr.indexOf('/p2p/') >= 0) {
return addr
} else {
- return addr + peer.peer.id.toB58String()
+ return addr + peer.peer
}
}
})
@@ -322,31 +331,6 @@ function onError (err) {
window.onerror = onError
-/* ===========================================================================
- App states
- =========================================================================== */
-
-const states = {
- ready: () => {
- const addressesHtml = info.addresses.map((address) => {
- return `${address}
`
- }).join('')
- $nodeId.innerText = info.id
- $nodeAddresses.innerHTML = addressesHtml
- $allDisabledButtons.forEach(b => { b.disabled = false })
- $allDisabledInputs.forEach(b => { b.disabled = false })
- $allDisabledElements.forEach(el => { el.classList.remove('disabled') })
- }
-}
-
-function updateView (state, ipfs) {
- if (states[state] !== undefined) {
- states[state]()
- } else {
- throw new Error('Could not find state "' + state + '"')
- }
-}
-
/* ===========================================================================
Boot the app
=========================================================================== */
diff --git a/examples/exchange-files-in-browser/test.js b/examples/exchange-files-in-browser/test.js
index 2e9f164395..723a00ba29 100644
--- a/examples/exchange-files-in-browser/test.js
+++ b/examples/exchange-files-in-browser/test.js
@@ -19,12 +19,12 @@ const df = createFactory({
js: {
ipfsBin: path.resolve(`${__dirname}/../../src/cli/bin.js`)
}
-}
-)
+})
const {
startServer
} = require('../utils')
const pkg = require('./package.json')
+const webRTCStarSigServer = require('libp2p-webrtc-star/src/sig-server')
async function testUI (env) {
const proc = execa('nightwatch', [path.join(__dirname, 'test.js')], {
@@ -44,7 +44,13 @@ async function testUI (env) {
}
async function runTest () {
- const ipfsd = await df.spawn({
+ const sigServer = await webRTCStarSigServer.start({
+ host: '127.0.0.1',
+ port: 13579
+ })
+
+ const relay = await df.spawn({
+ type: 'js',
ipfsOptions: {
config: {
Addresses: {
@@ -56,15 +62,20 @@ async function runTest () {
}
})
- const [{
- hash: cid
- }] = await ipfsd.api.add('A file with some content')
+ let cid
+
+ for await (const imported of relay.api.add('A file with some content')) {
+ cid = imported.cid
+ }
+
const server1 = await startServer(__dirname)
const server2 = await startServer(__dirname)
try {
- const id = await ipfsd.api.id()
- const address = id.addresses.filter(addr => addr.includes('/ws/ipfs/Qm')).pop()
+ const id = await relay.api.id()
+ const address = id.addresses
+ .map(ma => ma.toString())
+ .find(addr => addr.includes('/ws/p2p'))
if (!address) {
throw new Error(`Could not find web socket address in ${id.addresses}`)
@@ -74,10 +85,12 @@ async function runTest () {
const peerA = path.join(os.tmpdir(), `test-${Date.now()}-a.txt`)
const peerB = path.join(os.tmpdir(), `test-${Date.now()}-b.txt`)
+ console.info('Relay address', address)
+
await Promise.all([
testUI({
IPFS_EXAMPLE_TEST_URL: server1.url,
- IPFS_RELAY_ADDRESS: id.addresses[0],
+ IPFS_RELAY_ADDRESS: address,
IPFS_CID: cid,
IPFS_WORKSPACE_NAME: workspaceName,
IPFS_ADD_FILE: true,
@@ -86,7 +99,7 @@ async function runTest () {
}),
testUI({
IPFS_EXAMPLE_TEST_URL: server1.url,
- IPFS_RELAY_ADDRESS: id.addresses[0],
+ IPFS_RELAY_ADDRESS: address,
IPFS_CID: cid,
IPFS_WORKSPACE_NAME: workspaceName,
IPFS_LOCAL_PEER_ID_FILE: peerB,
@@ -94,9 +107,10 @@ async function runTest () {
})
])
} finally {
- await ipfsd.stop()
- await server1.stop()
await server2.stop()
+ await server1.stop()
+ await relay.stop()
+ await sigServer.stop()
}
}
@@ -108,7 +122,7 @@ module.exports[pkg.name] = function (browser) {
browser
.url(process.env.IPFS_EXAMPLE_TEST_URL)
- .waitForElementVisible('.node-addresses li pre')
+ .waitForElementVisible('#connected-peers tr td')
.pause(1000)
console.info('dialling relay', process.env.IPFS_RELAY_ADDRESS)
diff --git a/examples/ipfs-101/1.js b/examples/ipfs-101/1.js
index 3b832eb98d..314f2dabbe 100644
--- a/examples/ipfs-101/1.js
+++ b/examples/ipfs-101/1.js
@@ -1,6 +1,7 @@
'use strict'
const IPFS = require('ipfs')
+const all = require('it-all')
async function main () {
const node = await IPFS.create()
@@ -8,16 +9,16 @@ async function main () {
console.log('Version:', version.version)
- const filesAdded = await node.add({
+ for await (const file of await node.add({
path: 'hello.txt',
content: Buffer.from('Hello World 101')
- })
+ })) {
+ console.log('Added file:', file.path, file.cid.toString())
- console.log('Added file:', filesAdded[0].path, filesAdded[0].hash)
+ const data = Buffer.concat(await all(node.cat(file.cid)))
- const fileBuffer = await node.cat(filesAdded[0].hash)
-
- console.log('Added file contents:', fileBuffer.toString())
+ console.log('Added file contents:', data.toString())
+ }
}
main()
diff --git a/examples/ipfs-101/package.json b/examples/ipfs-101/package.json
index 7b77539945..663bd15e1a 100644
--- a/examples/ipfs-101/package.json
+++ b/examples/ipfs-101/package.json
@@ -9,6 +9,7 @@
"author": "David Dias ",
"license": "MIT",
"dependencies": {
- "ipfs": "file:../../"
+ "ipfs": "file:../../",
+ "it-all": "^1.0.1"
}
}
diff --git a/examples/package.json b/examples/package.json
index ed9608c395..42f4f055a2 100644
--- a/examples/package.json
+++ b/examples/package.json
@@ -9,7 +9,6 @@
"license": "MIT",
"dependencies": {
"chromedriver": "^79.0.0",
- "delay": "^4.1.0",
"execa": "^3.2.0",
"fs-extra": "^8.1.0",
"http-server": "~0.11.1",
diff --git a/examples/running-multiple-nodes/README.md b/examples/running-multiple-nodes/README.md
index 9683075b53..dcf836eb54 100644
--- a/examples/running-multiple-nodes/README.md
+++ b/examples/running-multiple-nodes/README.md
@@ -42,7 +42,7 @@ Firstly, you'll want to pass the [`repo`](https://github.com/ipfs/js-ipfs#option
```js
// The repo path by default is `os.homedir() + '/.jsipfs'`.
-new IPFS({ repo: os.homedir() + '/.jsipfs2' })
+await IPFS.create({ repo: os.homedir() + '/.jsipfs2' })
```
Secondly, you'll need them to bind to different ports because otherwise bad things happen.
@@ -50,7 +50,7 @@ Secondly, you'll need them to bind to different ports because otherwise bad thin
To do this, simply pass the different ports to the [`config`](https://github.com/ipfs/js-ipfs#optionsconfig) constructor option. All together:
```js
-new IPFS({
+await IPFS.create({
repo: os.homedir() + '/.jsipfs2',
config: {
Addresses: {
diff --git a/examples/running-multiple-nodes/test.js b/examples/running-multiple-nodes/test.js
index 76eefe9cf2..c62577d6a5 100644
--- a/examples/running-multiple-nodes/test.js
+++ b/examples/running-multiple-nodes/test.js
@@ -7,7 +7,6 @@ const os = require('os')
const path = require('path')
const hat = require('hat')
const {
- ephemeralPort,
waitForOutput
} = require('../utils')
@@ -29,9 +28,9 @@ async function startCliNode () {
const ipfs = path.resolve(__dirname, '../../src/cli/bin.js')
await execa(ipfs, ['init'], opts)
- await execa(ipfs, ['config', 'Addresses.Swarm', '--json', JSON.stringify([`/ip4/0.0.0.0/tcp/${ephemeralPort()}`, `/ip4/127.0.0.1/tcp/${ephemeralPort()}/ws`])], opts)
- await execa(ipfs, ['config', 'Addresses.API', `/ip4/127.0.0.1/tcp/${ephemeralPort()}`], opts)
- await execa(ipfs, ['config', 'Addresses.Gateway', `/ip4/127.0.0.1/tcp/${ephemeralPort()}`], opts)
+ await execa(ipfs, ['config', 'Addresses.Swarm', '--json', JSON.stringify([`/ip4/0.0.0.0/tcp/0`, `/ip4/127.0.0.1/tcp/0/ws`])], opts)
+ await execa(ipfs, ['config', 'Addresses.API', `/ip4/127.0.0.1/tcp/0`], opts)
+ await execa(ipfs, ['config', 'Addresses.Gateway', `/ip4/127.0.0.1/tcp/0`], opts)
return waitForOutput('Daemon is ready', ipfs, ['daemon'], opts)
}
@@ -45,25 +44,21 @@ async function testProgramatically () {
async function startProgramaticNode () {
const repoDir = path.join(os.tmpdir(), `repo-${hat()}`)
- const node = new IPFS({
+ const node = await IPFS.create({
repo: repoDir,
config: {
Addresses: {
Swarm: [
- `/ip4/0.0.0.0/tcp/${ephemeralPort()}`,
- `/ip4/127.0.0.1/tcp/${ephemeralPort()}/ws`
+ `/ip4/0.0.0.0/tcp/0`,
+ `/ip4/127.0.0.1/tcp/0/ws`
],
- API: `/ip4/127.0.0.1/tcp/${ephemeralPort()}`,
- Gateway: `/ip4/127.0.0.1/tcp/${ephemeralPort()}`
+ API: `/ip4/127.0.0.1/tcp/0`,
+ Gateway: `/ip4/127.0.0.1/tcp/0`
},
Bootstrap: []
}
})
- console.info('Initialising programmatic node')
- await node.init()
- console.info('Starting programmatic node')
- await node.start()
console.info('Stopping programmatic node')
await node.stop()
}
diff --git a/examples/test-all.js b/examples/test-all.js
index 50ae41a98d..a4eb7fa809 100644
--- a/examples/test-all.js
+++ b/examples/test-all.js
@@ -24,6 +24,8 @@ async function testAll () {
continue
}
+ console.info('Testing example', dir)
+
await waitForOutput('npm info ok', 'npm', ['test', '--verbose', '--', dir], {
cwd: __dirname
})
diff --git a/examples/traverse-ipld-graphs/test.js b/examples/traverse-ipld-graphs/test.js
index 45ae20aed9..e40d25349d 100644
--- a/examples/traverse-ipld-graphs/test.js
+++ b/examples/traverse-ipld-graphs/test.js
@@ -19,7 +19,7 @@ async function runTest () {
await waitForOutput('capoeira', path.resolve(__dirname, 'get-path-accross-formats.js'))
console.info('Testing tree.js')
- await waitForOutput("'hobbies/0/Links'", path.resolve(__dirname, 'tree.js'))
+ await waitForOutput("hobbies/0/Links", path.resolve(__dirname, 'tree.js'))
console.info('Testing eth.js')
await waitForOutput('302516', path.resolve(__dirname, 'eth.js'))
diff --git a/examples/traverse-ipld-graphs/tree.js b/examples/traverse-ipld-graphs/tree.js
index 7f52206d7c..1acba5e58d 100644
--- a/examples/traverse-ipld-graphs/tree.js
+++ b/examples/traverse-ipld-graphs/tree.js
@@ -29,9 +29,11 @@ async function main () {
hashAlg: 'sha3-512'
})
- const paths = await ipfs.dag.tree(cborNodeCid, { recursive: true })
+ for await (const path of ipfs.dag.tree(cborNodeCid, { recursive: true })) {
+ console.log(path)
+ }
- console.log(paths)
+ await ipfs.stop()
}
main()
diff --git a/examples/utils.js b/examples/utils.js
index 98cc5d2beb..7c1b0ee41c 100644
--- a/examples/utils.js
+++ b/examples/utils.js
@@ -125,28 +125,48 @@ async function waitForOutput (expectedOutput, command, args = [], opts = {}) {
let output = ''
const time = 120000
- const timeout = setTimeout(() => {
- throw new Error(`Did not see "${expectedOutput}" in output from "${[command].concat(args).join(' ')}" after ${time / 1000}s`)
- }, time)
+ let foundExpectedOutput = false
+ let cancelTimeout
+ const timeoutPromise = new Promise((resolve, reject) => {
+ const timeout = setTimeout(() => {
+ reject(new Error(`Did not see "${expectedOutput}" in output from "${[command].concat(args).join(' ')}" after ${time / 1000}s`))
+
+ setTimeout(() => {
+ proc.kill()
+ }, 100)
+ }, time)
+
+ cancelTimeout = () => {
+ clearTimeout(timeout)
+ resolve()
+ }
+ })
proc.all.on('data', (data) => {
process.stdout.write(data)
-
output += data.toString('utf8')
if (output.includes(expectedOutput)) {
- clearTimeout(timeout)
+ foundExpectedOutput = true
proc.kill()
+ cancelTimeout()
}
})
try {
- await proc
+ await Promise.race([
+ proc,
+ timeoutPromise
+ ])
} catch (err) {
if (!err.killed) {
throw err
}
}
+
+ if (!foundExpectedOutput) {
+ throw new Error(`Did not see "${expectedOutput}" in output from "${[command].concat(args).join(' ')}"`)
+ }
}
module.exports = {
diff --git a/package.json b/package.json
index a1d58bee32..a146a49819 100644
--- a/package.json
+++ b/package.json
@@ -41,13 +41,20 @@
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser",
"test:webworker": "aegir test -t webworker",
+ "test:electron": "aegir test -t electron-main -t electron-renderer",
+ "test:electron-main": "aegir test -t electron-main",
+ "test:electron-renderer": "aegir test -t electron-renderer",
"test:node:core": "aegir test -t node -f test/core/**/*.js",
"test:node:http": "aegir test -t node -f test/http-api/index.js",
"test:node:gateway": "aegir test -t node -f test/gateway/index.js",
"test:node:cli": "aegir test -t node -f test/cli/index.js",
"test:node:interface": "aegir test -t node -f test/core/interface.spec.js",
"test:bootstrapers": "IPFS_TEST=bootstrapers aegir test -t browser -f test/bootstrapers.js",
- "test:interop": "IPFS_JS_EXEC=$PWD/src/cli/bin.js ipfs-interop",
+ "test:interop": "IPFS_JS_EXEC=$PWD/src/cli/bin.js IPFS_JS_MODULE=$PWD IPFS_REUSEPORT=false ipfs-interop",
+ "test:interop:node": "IPFS_JS_EXEC=$PWD/src/cli/bin.js IPFS_JS_MODULE=$PWD IPFS_REUSEPORT=false ipfs-interop -- -t node",
+ "test:interop:browser": "IPFS_JS_EXEC=$PWD/src/cli/bin.js IPFS_JS_MODULE=$PWD IPFS_REUSEPORT=false ipfs-interop -- -t browser",
+ "test:interop:electron-main": "IPFS_JS_EXEC=$PWD/src/cli/bin.js IPFS_JS_MODULE=$PWD IPFS_REUSEPORT=false ipfs-interop -- -t electron-main -f ./test/node.js",
+ "test:interop:electron-renderer": "IPFS_JS_EXEC=$PWD/src/cli/bin.js IPFS_JS_MODULE=$PWD IPFS_REUSEPORT=false ipfs-interop -- -t electron-renderer -f ./test/browser.js",
"test:external": "aegir test-external",
"coverage": "nyc --reporter=text --reporter=lcov npm run test:node",
"benchmark": "echo \"Error: no benchmarks yet\" && exit 1",
@@ -88,10 +95,10 @@
"hapi-pino": "^6.1.0",
"hashlru": "^2.3.0",
"interface-datastore": "~0.8.0",
- "ipfs-bitswap": "github:ipfs/js-ipfs-bitswap#refactor/libp2p-async",
+ "ipfs-bitswap": "^0.27.0",
"ipfs-block": "~0.8.1",
"ipfs-block-service": "~0.16.0",
- "ipfs-http-client": "^42.0.0-pre.0",
+ "ipfs-http-client": "^42.0.0-pre.2",
"ipfs-http-response": "^0.5.0",
"ipfs-mfs": "^1.0.0",
"ipfs-multipart": "^0.3.0",
@@ -122,13 +129,13 @@
"just-safe-set": "^2.1.0",
"ky": "^0.15.0",
"ky-universal": "~0.3.0",
- "libp2p": "github:libp2p/js-libp2p#refactor/async-await",
+ "libp2p": "^0.27.1",
"libp2p-bootstrap": "^0.10.2",
"libp2p-crypto": "^0.17.1",
"libp2p-delegated-content-routing": "^0.4.1",
"libp2p-delegated-peer-routing": "^0.4.0",
"libp2p-floodsub": "^0.20.0",
- "libp2p-gossipsub": "github:ChainSafe/gossipsub-js#71cb905983b125b50c64a9b75d745dfd7fb8f094",
+ "libp2p-gossipsub": "^0.2.2",
"libp2p-kad-dht": "^0.18.3",
"libp2p-keychain": "^0.6.0",
"libp2p-mdns": "^0.13.0",
@@ -136,7 +143,7 @@
"libp2p-record": "~0.7.0",
"libp2p-secio": "^0.12.1",
"libp2p-tcp": "^0.14.2",
- "libp2p-webrtc-star": "^0.17.0",
+ "libp2p-webrtc-star": "^0.17.5",
"libp2p-websockets": "^0.13.0",
"mafmt": "^7.0.0",
"merge-options": "^2.0.0",
@@ -168,17 +175,18 @@
"yargs-promise": "^1.1.0"
},
"devDependencies": {
- "aegir": "^20.4.1",
+ "aegir": "^20.5.1",
"base64url": "^3.0.1",
"clear-module": "^4.0.0",
"delay": "^4.1.0",
"dir-compare": "^1.7.3",
"execa": "^3.0.0",
"form-data": "^3.0.0",
+ "go-ipfs-dep": "^0.4.23",
"hat": "0.0.3",
- "interface-ipfs-core": "^0.129.0",
+ "interface-ipfs-core": "^0.131.7",
"ipfs-interop": "github:ipfs/interop#refactor/async-await",
- "ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#feat/force-kill",
+ "ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#remove-option-normalisation",
"ncp": "^2.0.0",
"p-event": "^4.1.0",
"p-map": "^3.0.0",
diff --git a/src/core/components/dht.js b/src/core/components/dht.js
index 428627ccde..8eaed7cc76 100644
--- a/src/core/components/dht.js
+++ b/src/core/components/dht.js
@@ -77,7 +77,7 @@ module.exports = ({ libp2p, repo }) => {
for await (const peerInfo of libp2p._dht.findProviders(key, options)) {
yield {
- id: new CID(peerInfo.id.toB58String()),
+ id: peerInfo.id.toB58String(),
addrs: peerInfo.multiaddrs.toArray()
}
}
@@ -97,7 +97,7 @@ module.exports = ({ libp2p, repo }) => {
const peerInfo = await libp2p._dht.findPeer(peerId)
return {
- id: new CID(peerInfo.id.toB58String()),
+ id: peerInfo.id.toB58String(),
addrs: peerInfo.multiaddrs.toArray()
}
},
@@ -153,7 +153,7 @@ module.exports = ({ libp2p, repo }) => {
for await (const closerPeerId of libp2p._dht.getClosestPeers(peerId.toBytes())) {
yield {
- id: new CID(closerPeerId.toB58String()),
+ id: closerPeerId.toB58String(),
addrs: [] // TODO: get addrs?
}
}
diff --git a/src/core/components/id.js b/src/core/components/id.js
index 8e5fcab862..ecc6843b8c 100644
--- a/src/core/components/id.js
+++ b/src/core/components/id.js
@@ -1,16 +1,30 @@
'use strict'
const pkgversion = require('../../../package.json').version
+const multiaddr = require('multiaddr')
module.exports = ({ peerInfo }) => {
return async function id () { // eslint-disable-line require-await
+ const id = peerInfo.id.toB58String()
+
return {
- id: peerInfo.id.toB58String(),
+ id,
publicKey: peerInfo.id.pubKey.bytes.toString('base64'),
addresses: peerInfo.multiaddrs
.toArray()
- .map(ma => `${ma}/p2p/${peerInfo.id.toB58String()}`)
- .sort(),
+ .map(ma => {
+ const str = ma.toString()
+
+ // some relay-style transports add our peer id to the ma for us
+ // so don't double-add
+ if (str.endsWith(`/p2p/${id}`)) {
+ return str
+ }
+
+ return `${str}/p2p/${id}`
+ })
+ .sort()
+ .map(ma => multiaddr(ma)),
agentVersion: `js-ipfs/${pkgversion}`,
protocolVersion: '9000'
}
diff --git a/src/core/components/swarm/addrs.js b/src/core/components/swarm/addrs.js
index 16f6ca8efa..adf6857c72 100644
--- a/src/core/components/swarm/addrs.js
+++ b/src/core/components/swarm/addrs.js
@@ -1,12 +1,13 @@
'use strict'
-const CID = require('cids')
-
module.exports = ({ libp2p }) => {
return async function addrs () { // eslint-disable-line require-await
const peers = []
for (const [peerId, peerInfo] of libp2p.peerStore.peers.entries()) {
- peers.push({ id: new CID(peerId), addrs: peerInfo.multiaddrs.toArray() })
+ peers.push({
+ id: peerId,
+ addrs: peerInfo.multiaddrs.toArray()
+ })
}
return peers
}
diff --git a/src/core/components/swarm/peers.js b/src/core/components/swarm/peers.js
index 3fbc45c9c8..f9d7b16745 100644
--- a/src/core/components/swarm/peers.js
+++ b/src/core/components/swarm/peers.js
@@ -1,7 +1,5 @@
'use strict'
-const CID = require('cids')
-
module.exports = ({ libp2p }) => {
return async function peers (options) { // eslint-disable-line require-await
options = options || {}
@@ -13,7 +11,7 @@ module.exports = ({ libp2p }) => {
for (const connection of connections) {
const tupple = {
addr: connection.remoteAddr,
- peer: new CID(peerId)
+ peer: peerId
}
if (verbose || options.direction) {
diff --git a/test/cli/daemon.js b/test/cli/daemon.js
index 2b5a6f2d18..8a0692cde7 100644
--- a/test/cli/daemon.js
+++ b/test/cli/daemon.js
@@ -38,6 +38,11 @@ const daemonReady = async (daemon, options) => {
})
daemon.stderr.on('data', (data) => {
+ if (process && process.env && process.env.DEBUG) {
+ // causes data to be written out to stderr
+ return
+ }
+
if (!data.toString().includes('ExperimentalWarning')) {
reject(new Error('Daemon didn\'t start ' + data))
}
@@ -179,6 +184,8 @@ describe('daemon', () => {
})
it('should be silent', async function () {
+ if (process && process.env && process.env.DEBUG) return this.skip()
+
this.timeout(100 * 1000)
await ipfs('init')
diff --git a/test/core/create-node.spec.js b/test/core/create-node.spec.js
index c0f72c8fa4..8b63ee1ae0 100644
--- a/test/core/create-node.spec.js
+++ b/test/core/create-node.spec.js
@@ -113,6 +113,8 @@ describe('create node', function () {
})
it('should be silent', async function () {
+ if (process && process.env && process.env.DEBUG) return this.skip()
+
this.timeout(30 * 1000)
sinon.spy(console, 'log')
diff --git a/test/core/interface.spec.js b/test/core/interface.spec.js
index 19ce074cea..837e40a36c 100644
--- a/test/core/interface.spec.js
+++ b/test/core/interface.spec.js
@@ -2,36 +2,13 @@
'use strict'
const tests = require('interface-ipfs-core')
-const merge = require('merge-options')
-const { createFactory } = require('ipfsd-ctl')
const { isNode } = require('ipfs-utils/src/env')
-const IPFS = require('../../src')
+const factory = require('../utils/factory')
/** @typedef { import("ipfsd-ctl").ControllerOptions } ControllerOptions */
describe('interface-ipfs-core tests', function () {
- /** @type ControllerOptions */
- const commonOptions = {
- test: true,
- type: 'proc',
- ipfsModule: {
- path: require.resolve('../../src'),
- ref: IPFS
- },
- ipfsHttpModule: {
- path: require.resolve('ipfs-http-client'),
- ref: require('ipfs-http-client')
- },
- ipfsOptions: {
- pass: 'ipfs-is-awesome-software'
- }
- }
- const overrides = {
- js: {
- ipfsBin: './src/cli/bin.js'
- }
- }
- const commonFactory = createFactory(commonOptions, overrides)
+ const commonFactory = factory()
tests.root(commonFactory, {
skip: isNode ? null : [{
@@ -73,19 +50,19 @@ describe('interface-ipfs-core tests', function () {
tests.miscellaneous(commonFactory)
- tests.name(createFactory(merge(commonOptions, {
+ tests.name(factory({
ipfsOptions: {
offline: true
}
- }), overrides))
+ }))
- tests.namePubsub(createFactory(merge(commonOptions, {
+ tests.namePubsub(factory({
ipfsOptions: {
EXPERIMENTAL: {
ipnsPubsub: true
}
}
- }), overrides))
+ }))
tests.object(commonFactory)
@@ -93,11 +70,11 @@ describe('interface-ipfs-core tests', function () {
tests.ping(commonFactory)
- tests.pubsub(createFactory(commonOptions, merge(overrides, {
+ tests.pubsub(factory({}, {
go: {
args: ['--enable-pubsub-experiment']
}
- })), {
+ }), {
skip: isNode ? null : [
{
name: 'should receive messages from a different node',
diff --git a/test/http-api/inject/pin.js b/test/http-api/inject/pin.js
index e196ceb9dc..f4a77ab1d6 100644
--- a/test/http-api/inject/pin.js
+++ b/test/http-api/inject/pin.js
@@ -234,7 +234,7 @@ module.exports = (http) => {
})
expect(res.statusCode).to.equal(200)
- expect(res.result.Keys).to.include.all.keys(Object.values(pins))
+ expect(res.result.Keys).to.include.keys(Object.values(pins))
})
it('finds all pinned objects streaming', async () => {
diff --git a/test/utils/factory.js b/test/utils/factory.js
index e8152175e9..7aff724c77 100644
--- a/test/utils/factory.js
+++ b/test/utils/factory.js
@@ -1,25 +1,56 @@
'use strict'
const { createFactory } = require('ipfsd-ctl')
const merge = require('merge-options')
+const { isNode, isBrowser } = require('ipfs-utils/src/env')
-const factory = (options, overrides) => createFactory(
- merge({
- test: true,
- type: 'proc',
- ipfsModule: {
- path: require.resolve('../../src'),
- ref: require('../../src')
- },
- ipfsHttpModule: {
- path: require.resolve('ipfs-http-client'),
- ref: require('ipfs-http-client')
+const commonOptions = {
+ test: true,
+ type: 'proc',
+ ipfsHttpModule: {
+ path: require.resolve('ipfs-http-client'),
+ ref: require('ipfs-http-client')
+ },
+ ipfsModule: {
+ path: require.resolve('../../src'),
+ ref: require('../../src')
+ },
+ ipfsOptions: {
+ pass: 'ipfs-is-awesome-software',
+ libp2p: {
+ dialer: {
+ dialTimeout: 60e3 // increase timeout because travis is slow
+ }
}
- }, options),
- merge({
- js: {
+ }
+}
+
+const commonOverrides = {
+ js: {
+ ...(isNode ? {
ipfsBin: './src/cli/bin.js'
- }
- }, overrides)
+ } : {}),
+ ...(isBrowser ? {
+ remote: true
+ } : {})
+ },
+ proc: {
+ ...(isBrowser ? {
+ ipfsOptions: {
+ config: {
+ Addresses: {
+ Swarm: [
+ '/ip4/127.0.0.1/tcp/14579/ws/p2p-webrtc-star'
+ ]
+ }
+ }
+ }
+ } : {})
+ }
+}
+
+const factory = (options = {}, overrides = {}) => createFactory(
+ merge(commonOptions, options),
+ merge(commonOverrides, overrides)
)
module.exports = factory