diff --git a/src/keycache.ts b/src/keycache.ts index 9574a46..820161a 100644 --- a/src/keycache.ts +++ b/src/keycache.ts @@ -1,11 +1,11 @@ -import { bytes, bytes32 } from './@types/basic' +import { bytes32 } from './@types/basic' import PeerId from 'peer-id' /** * Storage for static keys of previously connected peers. */ class Keycache { - private storage = new Map(); + private storage = new Map(); public store (peerId: PeerId, key: bytes32): void { this.storage.set(peerId.id, key) diff --git a/test/keycache.spec.ts b/test/keycache.spec.ts index 6c175eb..e1a3c32 100644 --- a/test/keycache.spec.ts +++ b/test/keycache.spec.ts @@ -1,6 +1,7 @@ import { assert } from 'chai' import { KeyCache } from '../src/keycache' import { createPeerIds, createPeerIdsFromFixtures } from './fixtures/peer' +import uint8ArrayEquals from 'uint8arrays/equals' describe('KeyCache', () => { let peerA @@ -14,7 +15,7 @@ describe('KeyCache', () => { const key = Buffer.from('this is id 007') await KeyCache.store(peerA, key) 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) { assert(false, `Test failed - ${e.message}`) }