@@ -33,6 +33,8 @@ const PRIVATE_TEST_KEY_PASSWORD = 'secret'
3333const SIGN_HASH_TEXT = '5bb1ce718241bfec110552b86bb7cccf0d95b8a5f462fbf6dff7c48543622ba5'
3434const SIGN_TEXT = '0x7eceffab47295be3891ea745838a99102bfaf525ec43632366c7ec3f54db4822b5d581573aecde94c420554f963baebbf412e4304ad8636886ddfa7b1049f70e'
3535
36+ const TEST_KEY_FILE = 'test/resources/test_keyfile.dat'
37+
3638describe ( 'KeyPair class tests' , ( ) => {
3739 describe ( 'Key pair from PEM to new format' , async ( ) => {
3840 it ( 'should import and export a new encrypted format' , async ( ) => {
@@ -74,7 +76,7 @@ describe('KeyPair class tests', () => {
7476 } )
7577 } )
7678
77- describe ( 'Export keys' , ( ) => {
79+ describe ( 'Import and Export keys' , ( ) => {
7880 it ( 'should export/import key pair key too text' , async ( ) => {
7981 const keyPair = await KeyPair . create ( )
8082 const text = keyPair . exportToString ( PRIVATE_TEST_KEY_PASSWORD )
@@ -94,6 +96,13 @@ describe('KeyPair class tests', () => {
9496 assert . equal ( keyPairSaved . publicKeyAPI , keyPair . publicKeyAPI )
9597 fs . unlinkSync ( filename )
9698 } )
99+ it ( 'should import key from test key file' , async ( ) => {
100+ const keyPair = await KeyPair . importFromString ( PRIVATE_ENCRYPTED_KEY , PRIVATE_TEST_KEY_PASSWORD )
101+ assert ( keyPair )
102+
103+ const keyPairSaved = await KeyPair . importFromFile ( TEST_KEY_FILE , PRIVATE_TEST_KEY_PASSWORD )
104+ assert . equal ( keyPairSaved . publicKeyAPI , keyPair . publicKeyAPI )
105+ } )
97106 } )
98107 describe ( 'Sign text' , ( ) => {
99108 it ( 'should sign a standard hash text to produce a confirmed signed result' , async ( ) => {
0 commit comments