fix tests for new db

This commit is contained in:
Andre Staltz 2023-12-11 15:32:59 +02:00
parent 744f53da0e
commit 6150f92c6a
No known key found for this signature in database
GPG Key ID: 9EDE23EA7E8A4890
2 changed files with 5 additions and 4 deletions

View File

@ -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]
}

View File

@ -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'))