diff --git a/package.json b/package.json index 0a0dd6e..1e0c290 100644 --- a/package.json +++ b/package.json @@ -39,8 +39,8 @@ "prettier": "^2.6.2", "pretty-quick": "^3.1.3", "rimraf": "^4.4.0", - "secret-handshake-ext": "^0.0.8", - "secret-stack": "~7.1.0", + "secret-handshake-ext": "0.0.11", + "secret-stack": "~8.0.0", "ssb-box": "^1.0.1", "typescript": "^5.1.3" }, diff --git a/test/feed-decay.test.js b/test/feed-decay.test.js index d07dca7..2f04c3d 100644 --- a/test/feed-decay.test.js +++ b/test/feed-decay.test.js @@ -8,9 +8,7 @@ function getTexts(msgs) { } test('Feed decay', async (t) => { - const alice = createPeer({ - name: 'alice', - }) + const alice = createPeer({ name: 'alice' }) await alice.db.loaded() diff --git a/test/feed-holes.test.js b/test/feed-holes.test.js index 7fef74c..863c512 100644 --- a/test/feed-holes.test.js +++ b/test/feed-holes.test.js @@ -8,9 +8,7 @@ function getTexts(msgs) { } test('Feed holes', async (t) => { - const alice = createPeer({ - name: 'alice', - }) + const alice = createPeer({ name: 'alice' }) await alice.db.loaded() diff --git a/test/orphan-weave.test.js b/test/orphan-weave.test.js index 52ea5b2..38452ff 100644 --- a/test/orphan-weave.test.js +++ b/test/orphan-weave.test.js @@ -12,9 +12,7 @@ function getTexts(msgs) { } test('Orphan weave msgs', async (t) => { - const alice = createPeer({ - name: 'alice', - }) + const alice = createPeer({ name: 'alice' }) await alice.db.loaded() diff --git a/test/util.js b/test/util.js index 3fc1b85..9c821a0 100644 --- a/test/util.js +++ b/test/util.js @@ -4,17 +4,26 @@ const rimraf = require('rimraf') const caps = require('ppppp-caps') const Keypair = require('ppppp-keypair') -function createPeer(opts) { - if (opts.name) { +function createPeer(config) { + if (config.name) { + const name = config.name const tmp = OS.tmpdir() - opts.db ??= {path: Path.join(tmp, `ppppp-gc-${opts.name}-${Date.now()}`)} - opts.keypair ??= Keypair.generate('ed25519', opts.name) - opts.name = undefined + config.global ??= {} + config.global.path ??= Path.join(tmp, `ppppp-gc-${name}-${Date.now()}`) + config.global.keypair ??= Keypair.generate('ed25519', name) + delete config.name + } + if (!config.global) { + throw new Error('need config.global in createPeer()') + } + if (!config.global.path) { + throw new Error('need config.global.path in createPeer()') + } + if (!config.global.keypair) { + throw new Error('need config.global.keypair in createPeer()') } - if (!opts.db.path) throw new Error('need opts.db.path in createPeer()') - if (!opts.keypair) throw new Error('need opts.keypair in createPeer()') - rimraf.sync(opts.db.path) + rimraf.sync(config.global.path) return require('secret-stack/bare')() .use(require('secret-stack/plugins/net')) .use(require('secret-handshake-ext/secret-stack')) @@ -24,16 +33,19 @@ function createPeer(opts) { .use(require('ssb-box')) .use(require('../lib')) .call(null, { - caps, - connections: { - incoming: { - net: [{ scope: 'device', transform: 'shse', port: null }], - }, - outgoing: { - net: [{ transform: 'shse' }], + shse: { caps }, + ...config, + global: { + connections: { + incoming: { + net: [{ scope: 'device', transform: 'shse', port: null }], + }, + outgoing: { + net: [{ transform: 'shse' }], + }, }, + ...config.global, }, - ...opts, }) }