Fix fialing tests (unhappy commit)

This commit is contained in:
Jaco Greeff
2018-04-27 16:52:25 +02:00
parent 7fd0ee4eea
commit d4f6222a29
4 changed files with 7 additions and 11 deletions
+1 -5
View File
@@ -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);
};
+3 -3
View File
@@ -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/);
});
});
+1 -1
View File
@@ -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),
+2 -2
View File
@@ -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>