From 6150f92c6a34b19c6e6ab8ec2e3648a90ef83cba Mon Sep 17 00:00:00 2001 From: Andre Staltz Date: Mon, 11 Dec 2023 15:32:59 +0200 Subject: [PATCH] fix tests for new db --- lib/index.js | 2 +- test/util.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 346f479..084a899 100644 --- a/lib/index.js +++ b/lib/index.js @@ -430,7 +430,7 @@ function initSet(peer, config) { * @param {string=} id */ function values(subdomain, id) { - assert(!!accountID, 'Cannot call has() before loading') + assert(!!accountID, 'Cannot call values() before loading') const set = readSet(id ?? accountID, subdomain) return [...set] } diff --git a/test/util.js b/test/util.js index 43e6cda..9c4d2ef 100644 --- a/test/util.js +++ b/test/util.js @@ -6,14 +6,15 @@ const Keypair = require('ppppp-keypair') function createPeer(opts) { if (opts.name) { - opts.path ??= path.join(os.tmpdir(), 'ppppp-set-' + opts.name) + const tmp = os.tmpdir() + opts.db ??= {path: path.join(tmp, `ppppp-set-${opts.name}-${Date.now()}`)} opts.keypair ??= Keypair.generate('ed25519', opts.name) opts.name = undefined } - if (!opts.path) throw new Error('need opts.path 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.path) + rimraf.sync(opts.db.path) return require('secret-stack/bare')() .use(require('secret-stack/plugins/net')) .use(require('secret-handshake-ext/secret-stack'))