-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from ssbc/cross_version_testing
Cross version testing
- Loading branch information
Showing
3 changed files
with
128 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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:[email protected]", | ||
"ssb-invite-2": "npm:[email protected]", | ||
"ssb-conn-1": "npm:[email protected]", | ||
"ssb-replicate": "^1.3.5", | ||
"ssb-replication-scheduler": "^3.1.0", | ||
"ssb-ws": "^6.2.3", | ||
"standard": "^17.1.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters