Expand setMeta to actually set (with tests) (#318)

This commit is contained in:
Jaco Greeff
2019-02-16 15:32:22 +01:00
committed by GitHub
parent 6bc073e07a
commit 63daf66861
2 changed files with 12 additions and 2 deletions
+10
View File
@@ -42,4 +42,14 @@ describe('pair', () => {
)
).toEqual(false);
});
it('allows setting/getting of meta', () => {
keyring.bob.setMeta({ foo: 'bar', something: 'else' });
expect(keyring.bob.getMeta()).toMatchObject({ foo: 'bar', something: 'else' });
keyring.bob.setMeta({ something: 'thing' });
expect(keyring.bob.getMeta()).toMatchObject({ foo: 'bar', something: 'thing' });
});
});
+2 -2
View File
@@ -91,8 +91,8 @@ export default function createPair (type: KeyringPairType, { publicKey, seed }:
},
publicKey: (): Uint8Array =>
publicKey,
setMeta: (_meta: KeyringPair$Meta): void => {
meta = meta;
setMeta: (additional: KeyringPair$Meta): void => {
meta = { ...meta, ...additional };
},
sign: (message: Uint8Array): Uint8Array =>
sign(type, message, { publicKey, secretKey }),