feat: add typescript types + linting/tests (#161)

* feat: adds typescript types + linting/tests

Signed-off-by: Carson Farmer <carson.farmer@gmail.com>

* feat: much better types testing

Signed-off-by: Carson Farmer <carson.farmer@gmail.com>

* chore: revert eslintignore

Signed-off-by: Carson Farmer <carson.farmer@gmail.com>

* feat: update types entry

Signed-off-by: Carson Farmer <carson.farmer@gmail.com>

* chore: exclude has no effect here

Signed-off-by: Carson Farmer <carson.farmer@gmail.com>

* feat: more nuanced return types on keypair

Signed-off-by: Carson Farmer <carson.farmer@gmail.com>
This commit is contained in:
Carson Farmer
2020-01-17 03:04:52 -08:00
committed by Jacob Heun
parent b5d94ecae7
commit e01977c5a3
13 changed files with 449 additions and 12 deletions

View File

@ -10,8 +10,14 @@ const crypto = require('../src')
const fixtures = require('./fixtures/go-key-rsa')
const { expectErrCode } = require('./util')
/** @typedef {import("libp2p-crypto").PrivateKey} PrivateKey */
describe('libp2p-crypto', function () {
this.timeout(20 * 1000)
// @ts-check
/**
* @type {PrivateKey}
*/
let key
before(async () => {
key = await crypto.keys.generateKeyPair('RSA', 512)
@ -109,9 +115,9 @@ describe('libp2p-crypto', function () {
})
describe('randomBytes', () => {
it('throws with no number passed', () => {
it('throws with invalid number passed', () => {
expect(() => {
crypto.randomBytes()
crypto.randomBytes(-1)
}).to.throw()
})