mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-04-25 04:42:28 +00:00
chore: fix ts error
This commit is contained in:
parent
e52fe108ad
commit
de1cdb5bd0
@ -1,11 +1,11 @@
|
|||||||
import { bytes, bytes32 } from './@types/basic'
|
import { bytes32 } from './@types/basic'
|
||||||
import PeerId from 'peer-id'
|
import PeerId from 'peer-id'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Storage for static keys of previously connected peers.
|
* Storage for static keys of previously connected peers.
|
||||||
*/
|
*/
|
||||||
class Keycache {
|
class Keycache {
|
||||||
private storage = new Map<bytes, bytes32>();
|
private storage = new Map<Uint8Array, bytes32>();
|
||||||
|
|
||||||
public store (peerId: PeerId, key: bytes32): void {
|
public store (peerId: PeerId, key: bytes32): void {
|
||||||
this.storage.set(peerId.id, key)
|
this.storage.set(peerId.id, key)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
import { KeyCache } from '../src/keycache'
|
import { KeyCache } from '../src/keycache'
|
||||||
import { createPeerIds, createPeerIdsFromFixtures } from './fixtures/peer'
|
import { createPeerIds, createPeerIdsFromFixtures } from './fixtures/peer'
|
||||||
|
import uint8ArrayEquals from 'uint8arrays/equals'
|
||||||
|
|
||||||
describe('KeyCache', () => {
|
describe('KeyCache', () => {
|
||||||
let peerA
|
let peerA
|
||||||
@ -14,7 +15,7 @@ describe('KeyCache', () => {
|
|||||||
const key = Buffer.from('this is id 007')
|
const key = Buffer.from('this is id 007')
|
||||||
await KeyCache.store(peerA, key)
|
await KeyCache.store(peerA, key)
|
||||||
const result = await KeyCache.load(peerA)
|
const result = await KeyCache.load(peerA)
|
||||||
assert(result?.equals(key), 'Stored and loaded key are not the same')
|
assert(uint8ArrayEquals(result, key), 'Stored and loaded key are not the same')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
assert(false, `Test failed - ${e.message}`)
|
assert(false, `Test failed - ${e.message}`)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user