2
2
'use strict'
3
3
4
4
const { nanoid } = require ( 'nanoid' )
5
+ const keys = require ( 'libp2p-crypto/src/keys' )
5
6
const { getDescribe, getIt, expect } = require ( '../utils/mocha' )
6
7
const testTimeout = require ( '../utils/test-timeout' )
7
8
@@ -26,24 +27,24 @@ module.exports = (common, options) => {
26
27
it ( 'should respect timeout option when importing a key' , async ( ) => {
27
28
const password = nanoid ( )
28
29
29
- const pem = await ipfs . key . export ( 'self' , password )
30
- expect ( pem ) . to . exist ( )
30
+ const key = await keys . generateKeyPair ( 'ed25519' )
31
+ const exported = key . export ( password )
31
32
32
- await testTimeout ( ( ) => ipfs . key . import ( 'derp' , pem , password , {
33
+ await testTimeout ( ( ) => ipfs . key . import ( 'derp' , exported , password , {
33
34
timeout : 1
34
35
} ) )
35
36
} )
36
37
37
38
it ( 'should import an exported key' , async ( ) => {
38
39
const password = nanoid ( )
39
40
40
- const pem = await ipfs . key . export ( 'self' , password )
41
- expect ( pem ) . to . exist ( )
41
+ const key = await keys . generateKeyPair ( 'ed25519' )
42
+ const exported = await key . export ( password )
42
43
43
- const key = await ipfs . key . import ( 'clone' , pem , password )
44
- expect ( key ) . to . exist ( )
45
- expect ( key ) . to . have . property ( 'name' , 'clone' )
46
- expect ( key ) . to . have . property ( 'id' )
44
+ const importedKey = await ipfs . key . import ( 'clone' , exported , password )
45
+ expect ( importedKey ) . to . exist ( )
46
+ expect ( importedKey ) . to . have . property ( 'name' , 'clone' )
47
+ expect ( importedKey ) . to . have . property ( 'id' )
47
48
} )
48
49
} )
49
50
}
0 commit comments