Fix fialing tests (unhappy commit)
This commit is contained in:
@@ -5,10 +5,6 @@
|
||||
|
||||
import type { KeyringPair } from './types';
|
||||
|
||||
module.exports = function encrypt (pair: ?KeyringPair, passphrase: Uint8Array | string): ?Uint8Array {
|
||||
if (!pair) {
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = function encrypt (pair: KeyringPair, passphrase: Uint8Array | string): Uint8Array {
|
||||
return pair.encodePkcs8(passphrase);
|
||||
};
|
||||
|
||||
@@ -30,9 +30,9 @@ describe('encrypt', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('returns null for non-existing', () => {
|
||||
it('returns throws for non-existing', () => {
|
||||
expect(
|
||||
keypair.encrypt(new Uint8Array([]), 'test')
|
||||
).toEqual(null);
|
||||
() => keypair.encrypt(new Uint8Array([]), 'test')
|
||||
).toThrow(/Unable to retrieve/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ module.exports = function keyring (): KeyringInstance {
|
||||
pairs.add(createPair(naclKeypairFromSeed(seed))),
|
||||
decrypt: (encrypted: Uint8Array, passphrase: Uint8Array | string): KeyringPair =>
|
||||
pairs.add(decrypt(encrypted, passphrase)),
|
||||
encrypt: (publicKey: Uint8Array, passphrase: Uint8Array | string): ?Uint8Array =>
|
||||
encrypt: (publicKey: Uint8Array, passphrase: Uint8Array | string): Uint8Array =>
|
||||
encrypt(pairs.get(publicKey), passphrase),
|
||||
getPair: (publicKey: Uint8Array): KeyringPair =>
|
||||
pairs.get(publicKey),
|
||||
|
||||
@@ -21,13 +21,13 @@ export type KeyringPair = {
|
||||
export type KeyringPairs = {
|
||||
add: (pair: KeyringPair) => KeyringPair,
|
||||
all: () => Array<KeyringPair>,
|
||||
get: (publicKey: Uint8Array) => ?KeyringPair
|
||||
get: (publicKey: Uint8Array) => KeyringPair
|
||||
};
|
||||
|
||||
export type KeyringInstance = {
|
||||
addFromSeed (seed: Uint8Array): KeyringPair,
|
||||
decrypt (encrypted: Uint8Array, secret: Uint8Array | string): KeyringPair,
|
||||
encrypt (publicKey: Uint8Array, secret: Uint8Array | string): ?Uint8Array,
|
||||
encrypt (publicKey: Uint8Array, secret: Uint8Array | string): Uint8Array,
|
||||
getPair (publicKey: Uint8Array): KeyringPair,
|
||||
getPairs (): Array<KeyringPair>,
|
||||
getPublicKeys (): Array<Uint8Array>
|
||||
|
||||
Reference in New Issue
Block a user