mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-07-30 23:12:00 +00:00
chore: add error codes (#155)
* chore: add error codes * chore: create errors with new Error() * fix: better error testin * refactor: simplify random bytes error checks
This commit is contained in:
@@ -6,6 +6,7 @@ const chai = require('chai')
|
||||
const dirtyChai = require('dirty-chai')
|
||||
const expect = chai.expect
|
||||
chai.use(dirtyChai)
|
||||
const { expectErrCode } = require('../util')
|
||||
const crypto = require('../../src')
|
||||
const fixtures = require('../fixtures/go-stretch-key')
|
||||
|
||||
@@ -30,6 +31,14 @@ describe('keyStretcher', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('handles invalid cipher type', () => {
|
||||
return expectErrCode(crypto.keys.keyStretcher('invalid-cipher', 'SHA256', 'secret'), 'ERR_INVALID_CIPHER_TYPE')
|
||||
})
|
||||
|
||||
it('handles missing hash type', () => {
|
||||
return expectErrCode(crypto.keys.keyStretcher('AES-128', '', 'secret'), 'ERR_MISSING_HASH_TYPE')
|
||||
})
|
||||
})
|
||||
|
||||
describe('go interop', () => {
|
||||
|
Reference in New Issue
Block a user