Throw Error if no private key found when calling toWIF()

This commit is contained in:
Vlad Stan 2020-08-31 17:09:08 +03:00
parent 62bb17b045
commit bc9b5abb7c

View file

@ -146,6 +146,13 @@ describe('ECPair', () => {
assert.strictEqual(result, f.WIF); assert.strictEqual(result, f.WIF);
}); });
}); });
it('throws if no private key is found', () => {
assert.throws(() => {
const keyPair = ECPair.makeRandom();
delete (keyPair as any).__D;
keyPair.toWIF();
}, /Missing private key/);
});
}); });
describe('makeRandom', () => { describe('makeRandom', () => {