From 88ced2ce84d05fd073c0d40c890f446438dd861a Mon Sep 17 00:00:00 2001 From: mixmix Date: Wed, 6 Dec 2023 13:59:01 +1300 Subject: [PATCH 1/3] add tests for ssb-replicate,conn1,friends4 --- package.json | 7 ++++++- test/test-bot.js | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9ae60d3..c93359c 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,9 @@ "url": "git://github.com/ssbc/ssb-invite.git" }, "scripts": { - "test": "npm run test:js && npm run lint", + "test": "npm run test:js && npm run test:js:old && npm run lint", "test:js": "tape 'test/*.test.js' | tap-arc", + "test:js:old": "OLD_DEPS=true npm run test:js", "lint": "standard --fix" }, "dependencies": { @@ -27,6 +28,10 @@ "scuttle-testbot": "^2.2.0", "ssb-ebt": "^9.1.2", "ssb-friends": "^5.1.7", + "ssb-friends-4": "npm:ssb-friends@^4.4.10", + "ssb-invite-2": "npm:ssb-invite@^2.1.7", + "ssb-conn-1": "npm:ssb-conn@^1.0.0", + "ssb-replicate": "^1.3.5", "ssb-replication-scheduler": "^3.1.0", "ssb-ws": "^6.2.3", "standard": "^17.1.0", diff --git a/test/test-bot.js b/test/test-bot.js index 3567c57..ef3cc4e 100644 --- a/test/test-bot.js +++ b/test/test-bot.js @@ -12,11 +12,20 @@ module.exports = function (opts = {}) { const stack = require('scuttle-testbot') .use(require('..')) - .use(require('ssb-friends')) - .use(require('ssb-ebt')) - .use(require('ssb-replication-scheduler')) .use(require('ssb-ws')) + if (process.env.OLD_DEPS) { + stack + .use(require('ssb-replicate')) + .use(require('ssb-friends-4')) + .use(require('ssb-conn-1')) + } else { + stack + .use(require('ssb-friends')) + .use(require('ssb-ebt')) + .use(require('ssb-replication-scheduler')) + } + return stack({ db1: true, ...opts From 241d9cb8bf6aa969471d27692725517685e3174b Mon Sep 17 00:00:00 2001 From: mixmix Date: Wed, 6 Dec 2023 13:59:26 +1300 Subject: [PATCH 2/3] add tests for invite replication between invite 2/3 --- test/cross-version.test.js | 110 +++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 test/cross-version.test.js diff --git a/test/cross-version.test.js b/test/cross-version.test.js new file mode 100644 index 0000000..f6ee9fe --- /dev/null +++ b/test/cross-version.test.js @@ -0,0 +1,110 @@ +/* eslint-disable no-useless-call */ +const test = require('tape') +const crypto = require('crypto') +const { promisify: p } = require('util') +const pull = require('pull-stream') + +const caps = { + shs: crypto.randomBytes(32).toString('base64') +} +const skip = process.env.OLD_DEPS // these tests don't use util/testbot.js + +test('old peer → new pub', { skip }, async t => { + const peer = require('scuttle-testbot') + .use(require('ssb-invite-2')) + .use(require('ssb-replicate')) + .use(require('ssb-friends-4')) + .use(require('ssb-conn-1')) + .call(null, { + name: 'old-peer', + db1: true, + caps + }) + + const pub = require('scuttle-testbot') + .use(require('../')) // ssb-invite-3 + .use(require('ssb-replicate')) + .use(require('ssb-friends-4')) + .use(require('ssb-conn-1')) + .call(null, { + name: 'new-pub', + db1: true, + caps, + allowPrivate: true + }) + + const invite = await p(pub.invite.create)({ uses: 1 }) + + await p(peer.invite.accept)(invite) + + const readyPromise = pull( + pub.createHistoryStream({ id: peer.id, live: true }), + pull.filter(m => m.value.content.type === 'hello!'), + pull.take(1), + pull.collectAsPromise() + ) + + await p(peer.publish)({ type: 'hello!' }) + .then(() => t.pass('peer publishes a new message')) + .catch(err => t.error(err, 'peer publishes a new message')) + + const [{ value }] = await readyPromise + t.equal(value.author, peer.id, 'pub replicated message from peer') + t.equal(value.content.type, 'hello!', 'its hello!') + + await Promise.all([ + p(peer.close)(true), + p(pub.close)(true) + ]) + t.end() +}) + +test('new peer → old pub', { skip }, async t => { + const peer = require('scuttle-testbot') + .use(require('../')) // ssb-invite-3 + .use(require('ssb-replicate')) + .use(require('ssb-friends-4')) + .use(require('ssb-conn-1')) + .call(null, { + name: 'old-peer', + db1: true, + caps + }) + + const pub = require('scuttle-testbot') + .use(require('ssb-invite-2')) + .use(require('ssb-replicate')) + .use(require('ssb-friends-4')) + .use(require('ssb-conn-1')) + .call(null, { + name: 'new-pub', + db1: true, + caps, + allowPrivate: true + }) + + const invite = await p(pub.invite.create)({ uses: 1 }) + + await p(peer.invite.accept)(invite) + + const readyPromise = pull( + pub.createHistoryStream({ id: peer.id, live: true }), + pull.filter(m => m.value.content.type === 'hello!'), + pull.take(1), + pull.collectAsPromise() + ) + + await p(peer.publish)({ type: 'hello!' }) + .then(() => t.pass('peer publishes a new message')) + .catch(err => t.error(err, 'peer publishes a new message')) + + const [{ value }] = await readyPromise + t.equal(value.author, peer.id, 'pub replicated message from peer') + t.equal(value.content.type, 'hello!', 'its hello!') + + await Promise.all([ + p(peer.close)(true), + p(pub.close)(true) + ]) + t.end() +}) From 0ac9dbb3ca0a815920c13e9ba9c948f812cdc869 Mon Sep 17 00:00:00 2001 From: mixmix Date: Thu, 7 Dec 2023 14:15:46 +1300 Subject: [PATCH 3/3] pin exact old versions --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c93359c..813f4ac 100644 --- a/package.json +++ b/package.json @@ -28,9 +28,9 @@ "scuttle-testbot": "^2.2.0", "ssb-ebt": "^9.1.2", "ssb-friends": "^5.1.7", - "ssb-friends-4": "npm:ssb-friends@^4.4.10", - "ssb-invite-2": "npm:ssb-invite@^2.1.7", - "ssb-conn-1": "npm:ssb-conn@^1.0.0", + "ssb-friends-4": "npm:ssb-friends@4.4.10", + "ssb-invite-2": "npm:ssb-invite@2.1.7", + "ssb-conn-1": "npm:ssb-conn@1.0.0", "ssb-replicate": "^1.3.5", "ssb-replication-scheduler": "^3.1.0", "ssb-ws": "^6.2.3",