Skip to content

Commit

Permalink
Failing test for persisted cores
Browse files Browse the repository at this point in the history
  • Loading branch information
gmaclennan committed Mar 2, 2023
1 parent b95bfbf commit 52269cd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/core-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,31 @@ test('multiplexing waits for cores to be added', async function (t) {
t.alike(await b2.get(0), Buffer.from('ho'))
})

test('Added cores are persisted', async t => {
const db = new Sqlite(':memory:')
const keyManager = new KeyManager(randomBytes(16))
const projectKey = randomBytes(32)
const cm1 = new CoreManager({
db,
keyManager,
storage: RAM,
projectKey
})
const key = randomBytes(32)
cm1.addCore(key, 'auth')

// No close method yet, need to add one.

const cm2 = new CoreManager({
db,
keyManager,
storage: RAM,
projectKey
})

t.ok(cm2.getCoreByKey(key), 'Added core is persisted')
})

async function waitForCores (coreManager, keys) {
const allKeys = getAllKeys(coreManager)
if (hasKeys(keys, allKeys)) return
Expand Down

0 comments on commit 52269cd

Please sign in to comment.