test: use ed25519 keys in tests (#669)

* chore: use ed25519 keys in tests

* fix: persisted keybook recheck keybook content for delete

* chore: only store if key not inline

* chore: update peer id

* chore: identify wait for closed streams
This commit is contained in:
Vasco Santos
2020-10-07 14:50:01 +02:00
committed by GitHub
parent 60d437f595
commit 0d48fc4f5a
5 changed files with 52 additions and 28 deletions

View File

@ -67,7 +67,7 @@ class PersistentPeerStore extends PeerStore {
// Handlers for dirty peers
this.on('change:protocols', this._addDirtyPeer)
this.on('change:multiaddrs', this._addDirtyPeer)
this.on('change:pubkey', this._addDirtyPeer)
this.on('change:pubkey', this._addDirtyPeerKey)
this.on('change:metadata', this._addDirtyPeerMetadata)
// Load data
@ -111,6 +111,31 @@ class PersistentPeerStore extends PeerStore {
}
}
/**
* Add modified peer key to the dirty set
* @private
* @param {Object} params
* @param {PeerId} params.peerId
*/
_addDirtyPeerKey ({ peerId }) {
// Not add if inline key available
if (peerId.hasInlinePublicKey()) {
return
}
const peerIdstr = peerId.toB58String()
log('add dirty peer key', peerIdstr)
this._dirtyPeers.add(peerIdstr)
if (this._dirtyPeers.size >= this.threshold) {
// Commit current data
this._commitData().catch(err => {
log.error('error committing data', err)
})
}
}
/**
* Add modified metadata peer to the set.
*
@ -164,7 +189,7 @@ class PersistentPeerStore extends PeerStore {
this._batchAddressBook(peerId, batch)
// Key Book
this._batchKeyBook(peerId, batch)
!peerId.hasInlinePublicKey() && this._batchKeyBook(peerId, batch)
// Metadata Book
this._batchMetadataBook(peerId, batch)