diff --git a/test/schedule.test.js b/test/schedule.test.js index 88852be..a1da495 100644 --- a/test/schedule.test.js +++ b/test/schedule.test.js @@ -36,8 +36,8 @@ test('Cleanup is scheduled automatically', async (t) => { alice.goals.set(postFeedID, 'newest-3') assert('alice set a goal for newest-3 of post feed') - alice.gc.start(4 * 1024), // 4kB, approximately 8 messages - await p(setTimeout)(3000) + alice.gc.start(4 * 1024) // 4kB, approximately 8 messages + await p(setTimeout)(3000) assert.deepEqual( getTexts([...alice.db.msgs()]), @@ -93,7 +93,6 @@ test('Compaction is scheduled automatically', async (t) => { alice.goals.set(alice.db.feed.getID(aliceID, 'post4'), 'all') alice.gc.start(6 * 1024) // 6kB, approximately 12 messages - await p(setTimeout)(3000) assert.deepEqual( diff --git a/test/util.js b/test/util.js index 9917b6a..3fc1b85 100644 --- a/test/util.js +++ b/test/util.js @@ -1,19 +1,20 @@ -const os = require('node:os') -const path = require('node:path') +const OS = require('node:os') +const Path = require('node:path') const rimraf = require('rimraf') const caps = require('ppppp-caps') const Keypair = require('ppppp-keypair') function createPeer(opts) { if (opts.name) { - opts.path ??= path.join(os.tmpdir(), 'ppppp-gc-' + opts.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 } - 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'))