mirror of https://codeberg.org/pzp/pzp-set.git
fix tests for new db
This commit is contained in:
parent
744f53da0e
commit
6150f92c6a
|
@ -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]
|
||||
}
|
||||
|
|
|
@ -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'))
|
||||
|
|
Loading…
Reference in New Issue