Skip to content

Commit

Permalink
fix: support libp2p creation without keychain pass
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobheun committed Aug 5, 2020
1 parent 80f015e commit 386c3d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Libp2p extends EventEmitter {
}

// Create keychain
if (this._options.keychain && this._options.keychain.pass && this._options.keychain.datastore) {
if (this._options.keychain && this._options.keychain.datastore) {
log('creating keychain')

const keychainOpts = Keychain.generateOptions()
Expand Down
18 changes: 17 additions & 1 deletion test/keychain/keychain.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ describe('libp2p.keychain', () => {
throw new Error('should throw an error using the keychain if no passphrase provided')
})

it('can be used if a passphrase is provided', async () => {
it('can be used when a passphrase is provided', async () => {
const [libp2p] = await peerUtils.createPeer({
started: false,
config: {
Expand All @@ -526,6 +526,22 @@ describe('libp2p.keychain', () => {
expect(kInfo).to.exist()
})

it('does not require a keychain passphrase', async () => {
const [libp2p] = await peerUtils.createPeer({
started: false,
config: {
keychain: {
datastore: new MemoryDatastore()
}
}
})

await libp2p.loadKeychain()

const kInfo = await libp2p.keychain.createKey('keyName', 'ed25519')
expect(kInfo).to.exist()
})

it('can reload keys', async () => {
const datastore = new MemoryDatastore()
const [libp2p] = await peerUtils.createPeer({
Expand Down

0 comments on commit 386c3d3

Please sign in to comment.