mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
refactor: Throw any storage errors when adding a key.
This commit is contained in:
parent
7396a4ac64
commit
1fb02ea4cb
@ -111,12 +111,8 @@ const KeyStore = async ({ storage, path } = {}) => {
|
||||
}
|
||||
|
||||
const addKey = async (id, key) => {
|
||||
try {
|
||||
await storage.put('public_' + id, key.publicKey)
|
||||
await storage.put('private_' + id, key.privateKey)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
await storage.put('public_' + id, key.publicKey)
|
||||
await storage.put('private_' + id, key.privateKey)
|
||||
}
|
||||
|
||||
const createKey = async (id, { entropy } = {}) => {
|
||||
|
@ -124,6 +124,18 @@ describe('KeyStore', () => {
|
||||
|
||||
strictEqual(actual, expected)
|
||||
})
|
||||
|
||||
it('creates a key when storage is closed', async () => {
|
||||
let err
|
||||
await keystore.close()
|
||||
try {
|
||||
await keystore.createKey(id)
|
||||
} catch (e) {
|
||||
err = e.toString()
|
||||
}
|
||||
|
||||
strictEqual(err, 'Error: Database is not open')
|
||||
})
|
||||
})
|
||||
|
||||
describe('Options', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user