From bc9b5abb7c1e089cca3265e38c31d46846d96f25 Mon Sep 17 00:00:00 2001
From: Vlad Stan <stan.v.vlad@gmail.com>
Date: Mon, 31 Aug 2020 17:09:08 +0300
Subject: [PATCH] Throw Error if no private key found when calling toWIF()

---
 test/ecpair.spec.ts | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/ecpair.spec.ts b/test/ecpair.spec.ts
index b9b8538..0b54ecc 100644
--- a/test/ecpair.spec.ts
+++ b/test/ecpair.spec.ts
@@ -146,6 +146,13 @@ describe('ECPair', () => {
         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', () => {