From 3602dbdb9260096d4e3beb6980bffa5e7bc89cdd Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Tue, 14 Nov 2017 22:42:58 +1300 Subject: [PATCH 01/10] fix(pubsub): topicCIDs should be topicIDs --- src/http/api/resources/pubsub.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http/api/resources/pubsub.js b/src/http/api/resources/pubsub.js index 8d35abce97..43d986179d 100644 --- a/src/http/api/resources/pubsub.js +++ b/src/http/api/resources/pubsub.js @@ -23,7 +23,7 @@ exports.subscribe = { from: msg.from, data: msg.data.toString('base64'), seqno: msg.seqno.toString('base64'), - topicCIDs: msg.topicCIDs + topicIDs: msg.topicIDs }) + '\n', 'utf8') } From 1f68a16855802b05f612b65836152834062c723b Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Wed, 15 Nov 2017 11:36:14 +1300 Subject: [PATCH 02/10] fix(pubsub): msg.from field is base64 encoding of peer id --- package.json | 3 ++- src/http/api/resources/pubsub.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0865299afd..707f51d598 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "async": "^2.6.0", "bl": "^1.2.1", "boom": "^7.1.1", + "bs58": "^4.0.1", "byteman": "^1.3.5", "cids": "^0.5.2", "debug": "^3.1.0", @@ -105,7 +106,7 @@ "hapi": "^16.6.2", "hapi-set-header": "^1.0.2", "hoek": "^5.0.2", - "ipfs-api": "^15.0.1", + "ipfs-api": "^15.1.0", "ipfs-bitswap": "~0.17.4", "ipfs-block": "~0.6.1", "ipfs-block-service": "~0.13.0", diff --git a/src/http/api/resources/pubsub.js b/src/http/api/resources/pubsub.js index 43d986179d..d234dd8e9f 100644 --- a/src/http/api/resources/pubsub.js +++ b/src/http/api/resources/pubsub.js @@ -20,7 +20,7 @@ exports.subscribe = { const handler = (msg) => { res.write(JSON.stringify({ - from: msg.from, + from: bs58.decode(msg.from).toString('base64'), data: msg.data.toString('base64'), seqno: msg.seqno.toString('base64'), topicIDs: msg.topicIDs From bca9ff2af1dd84f6e84a3bb2e441e34fd3ac8b46 Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Wed, 15 Nov 2017 12:14:06 +1300 Subject: [PATCH 03/10] fix: oops --- src/http/api/resources/pubsub.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/http/api/resources/pubsub.js b/src/http/api/resources/pubsub.js index d234dd8e9f..6aa1ad6f82 100644 --- a/src/http/api/resources/pubsub.js +++ b/src/http/api/resources/pubsub.js @@ -1,6 +1,7 @@ 'use strict' const PassThrough = require('stream').PassThrough +const bs58 = require('bs58') exports = module.exports From f107763dde2806f888e7ec36e81e202deee365dd Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 16 Nov 2017 11:28:41 +0000 Subject: [PATCH 04/10] chore: update deps --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 707f51d598..3716f0aaf7 100644 --- a/package.json +++ b/package.json @@ -75,8 +75,8 @@ "form-data": "^2.3.1", "gulp": "^3.9.1", "hat": "0.0.3", - "interface-ipfs-core": "~0.33.2", - "ipfsd-ctl": "~0.24.0", + "interface-ipfs-core": "~0.35.0", + "ipfsd-ctl": "~0.24.1", "left-pad": "^1.1.3", "lodash": "^4.17.4", "mocha": "^4.0.1", @@ -106,21 +106,21 @@ "hapi": "^16.6.2", "hapi-set-header": "^1.0.2", "hoek": "^5.0.2", - "ipfs-api": "^15.1.0", + "ipfs-api": "^16.0.0", "ipfs-bitswap": "~0.17.4", "ipfs-block": "~0.6.1", "ipfs-block-service": "~0.13.0", "ipfs-multipart": "~0.1.0", "ipfs-repo": "~0.18.3", "ipfs-unixfs": "~0.1.14", - "ipfs-unixfs-engine": "~0.23.1", + "ipfs-unixfs-engine": "~0.24.1", "ipld-resolver": "~0.14.1", "is-ipfs": "^0.3.2", "is-stream": "^1.1.0", - "joi": "^13.0.1", + "joi": "^13.0.2", "libp2p": "~0.13.1", "libp2p-circuit": "~0.1.4", - "libp2p-floodsub": "~0.11.1", + "libp2p-floodsub": "~0.12.0", "libp2p-kad-dht": "~0.6.0", "libp2p-mdns": "~0.9.1", "libp2p-multiplex": "~0.5.0", @@ -158,7 +158,7 @@ "readable-stream": "2.3.3", "safe-buffer": "^5.1.1", "stream-to-pull-stream": "^1.7.2", - "tar-stream": "^1.5.4", + "tar-stream": "^1.5.5", "temp": "~0.8.3", "through2": "^2.0.3", "update-notifier": "^2.3.0", From 404d9e12ea57b61293461c71d34df7705e5e23a6 Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 16 Nov 2017 12:25:20 +0000 Subject: [PATCH 05/10] write interop test setup for richard --- test/interop/pubsub.js | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/interop/pubsub.js diff --git a/test/interop/pubsub.js b/test/interop/pubsub.js new file mode 100644 index 0000000000..870f181a85 --- /dev/null +++ b/test/interop/pubsub.js @@ -0,0 +1,55 @@ +/* eslint-env mocha */ +'use strict' + +const chai = require('chai') +const dirtyChai = require('dirty-chai') +const expect = chai.expect +chai.use(dirtyChai) +const series = require('async/series') +const parallel = require('async/parallel') + +const GODaemon = require('../utils/interop-daemon-spawner/go') +const JSDaemon = require('../utils/interop-daemon-spawner/js') + +describe('pubsub', () => { + let jsD + let goD + + before((done) => { + goD = new GODaemon() + jsD = new JSDaemon({ port: 73 }) + + parallel([ + (cb) => goD.start(cb), + (cb) => jsD.start(cb) + ], done) + }) + + after((done) => { + series([ + (cb) => goD.stop(cb), + (cb) => jsD.stop(cb) + ], done) + }) + + it('make connections', (done) => { + parallel([ + (cb) => jsD.api.id(cb), + (cb) => goD.api.id(cb) + ], (err, ids) => { + expect(err).to.not.exist() + parallel([ + (cb) => jsD.api.swarm.connect(ids[1].addresses[0], cb), + (cb) => goD.api.swarm.connect(ids[0].addresses[0], cb) + ], done) + }) + }) + + it.skip('publish from JS, subscribe on Go', (done) => { + // TODO write this test + }) + + it.skip('publish from Go, subscribe on JS', (done) => { + // TODO write this test + }) +}) From 202bc1deb356f7f3c094378ee31fe1cb0245d355 Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Fri, 17 Nov 2017 10:52:59 +1300 Subject: [PATCH 06/10] fix: allow go daemon flags to be specified --- test/utils/interop-daemon-spawner/go.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/utils/interop-daemon-spawner/go.js b/test/utils/interop-daemon-spawner/go.js index 286f559afc..8010724d81 100644 --- a/test/utils/interop-daemon-spawner/go.js +++ b/test/utils/interop-daemon-spawner/go.js @@ -16,6 +16,7 @@ class GoDaemon { this.node = null this.api = null this.config = opts.config || {} + this.flags = opts.flags || {} } start (callback) { @@ -39,7 +40,7 @@ class GoDaemon { this.node = node this.node.setConfig('Bootstrap', '[]', cb) }, - (res, cb) => this.node.startDaemon(cb), + (res, cb) => this.node.startDaemon(this.flags, cb), (api, cb) => { this.api = api From 3ed8cb2647d4abf3a682c2fdb5cf4b794ee53a92 Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Fri, 17 Nov 2017 12:03:24 +1300 Subject: [PATCH 07/10] test: pubsub interop with go (WIP) --- test/interop/node.js | 1 + test/interop/pubsub.js | 47 +++++++++++++++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/test/interop/node.js b/test/interop/node.js index b3108e28bf..7e4a513445 100644 --- a/test/interop/node.js +++ b/test/interop/node.js @@ -5,3 +5,4 @@ require('./repo') require('./exchange-files') require('./circuit-relay') require('./kad-dht') +require('./pubsub') diff --git a/test/interop/pubsub.js b/test/interop/pubsub.js index 870f181a85..d7cb015e0c 100644 --- a/test/interop/pubsub.js +++ b/test/interop/pubsub.js @@ -11,18 +11,39 @@ const parallel = require('async/parallel') const GODaemon = require('../utils/interop-daemon-spawner/go') const JSDaemon = require('../utils/interop-daemon-spawner/js') +// TODO: These tests are mainly NYI. +// JS Pubsub is broken, https://github.com/ipfs/js-ipfs/issues/1068#issuecomment-345086825 describe('pubsub', () => { let jsD let goD + let jsID + let goID - before((done) => { - goD = new GODaemon() - jsD = new JSDaemon({ port: 73 }) + before(function (done) { + this.timeout(50 * 1000) + + goD = new GODaemon({ + disposable: true, + init: true, + flags: ['--enable-pubsub-experiment'] + }) + jsD = new JSDaemon() parallel([ - (cb) => goD.start(cb), - (cb) => jsD.start(cb) - ], done) + (cb) => goD.start(() => { + goD.api.id((err, data) => { + if (err) return cb(err) + goID = data.id + cb(err) + }) + }), + (cb) => jsD.start(() => { + jsD.api.id((err, data) => { + jsID = data.id + cb(err) + }) + }), + ], (done)) }) after((done) => { @@ -32,7 +53,7 @@ describe('pubsub', () => { ], done) }) - it('make connections', (done) => { + it.skip('make connections', (done) => { parallel([ (cb) => jsD.api.id(cb), (cb) => goD.api.id(cb) @@ -50,6 +71,16 @@ describe('pubsub', () => { }) it.skip('publish from Go, subscribe on JS', (done) => { - // TODO write this test + const topic = 'pubsub-go-js' + const data = Buffer.from('hello world') + + function checkMessage () { + console.log('check message', arguments) + } + + series([ + cb => jsD.api.pubsub.subscribe(topic, checkMessage, cb), + cb => goD.api.pubsub.publish(topic, data, cb) + ], done) }) }) From 5eefd30fe4eab2dd8d6b6d3857f9652c8c70c148 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 17 Nov 2017 09:14:02 +0000 Subject: [PATCH 08/10] chore: fix linting --- src/cli/commands/ls.js | 2 -- src/http/api/resources/files.js | 1 - 2 files changed, 3 deletions(-) diff --git a/src/cli/commands/ls.js b/src/cli/commands/ls.js index 61a19e760c..e7beecbaee 100644 --- a/src/cli/commands/ls.js +++ b/src/cli/commands/ls.js @@ -1,8 +1,6 @@ 'use strict' const utils = require('../utils') -const Unixfs = require('ipfs-unixfs') -const pull = require('pull-stream') module.exports = { command: 'ls ', diff --git a/src/http/api/resources/files.js b/src/http/api/resources/files.js index ebb1353f35..4bf13f2ac6 100644 --- a/src/http/api/resources/files.js +++ b/src/http/api/resources/files.js @@ -317,4 +317,3 @@ function toTypeCode (type) { return 0 } } - From f2c8296c41adb76eeb3e1f9e660b6c57af537a32 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 17 Nov 2017 09:18:49 +0000 Subject: [PATCH 09/10] fix more linting --- test/interop/pubsub.js | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/test/interop/pubsub.js b/test/interop/pubsub.js index d7cb015e0c..b76f21967f 100644 --- a/test/interop/pubsub.js +++ b/test/interop/pubsub.js @@ -11,17 +11,15 @@ const parallel = require('async/parallel') const GODaemon = require('../utils/interop-daemon-spawner/go') const JSDaemon = require('../utils/interop-daemon-spawner/js') -// TODO: These tests are mainly NYI. -// JS Pubsub is broken, https://github.com/ipfs/js-ipfs/issues/1068#issuecomment-345086825 describe('pubsub', () => { let jsD let goD - let jsID - let goID + let jsId + let goId before(function (done) { this.timeout(50 * 1000) - + goD = new GODaemon({ disposable: true, init: true, @@ -30,19 +28,8 @@ describe('pubsub', () => { jsD = new JSDaemon() parallel([ - (cb) => goD.start(() => { - goD.api.id((err, data) => { - if (err) return cb(err) - goID = data.id - cb(err) - }) - }), - (cb) => jsD.start(() => { - jsD.api.id((err, data) => { - jsID = data.id - cb(err) - }) - }), + (cb) => goD.start(cb), + (cb) => jsD.start(cb) ], (done)) }) @@ -53,12 +40,19 @@ describe('pubsub', () => { ], done) }) - it.skip('make connections', (done) => { + it('make connections', (done) => { parallel([ (cb) => jsD.api.id(cb), (cb) => goD.api.id(cb) ], (err, ids) => { expect(err).to.not.exist() + + jsId = ids[0].ID + goId = ids[0].ID + + console.log('jsId:', jsId) + console.log('goId:', goId) + parallel([ (cb) => jsD.api.swarm.connect(ids[1].addresses[0], cb), (cb) => goD.api.swarm.connect(ids[0].addresses[0], cb) From 007b4ceff2dc8a4e0ba579953cebb10c6963ad71 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 17 Nov 2017 09:26:02 +0000 Subject: [PATCH 10/10] fix interop tests --- test/utils/interop-daemon-spawner/go.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/utils/interop-daemon-spawner/go.js b/test/utils/interop-daemon-spawner/go.js index 8010724d81..92a04ca99e 100644 --- a/test/utils/interop-daemon-spawner/go.js +++ b/test/utils/interop-daemon-spawner/go.js @@ -40,7 +40,8 @@ class GoDaemon { this.node = node this.node.setConfig('Bootstrap', '[]', cb) }, - (res, cb) => this.node.startDaemon(this.flags, cb), + (res, cb) => this.node.startDaemon(cb), + // (res, cb) => this.node.startDaemon(this.flags, cb), (api, cb) => { this.api = api