mirror of
https://github.com/fluencelabs/js-libp2p-noise
synced 2025-06-30 13:31:49 +00:00
feat: use aegir
This commit is contained in:
34
test/keycache.spec.ts
Normal file
34
test/keycache.spec.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { expect, assert } from "chai";
|
||||
import { KeyCache } from "../src/keycache";
|
||||
import {createPeerIds, createPeerIdsFromFixtures} from "./fixtures/peer";
|
||||
|
||||
describe("KeyCache", () => {
|
||||
let peerA, peerB;
|
||||
|
||||
before(async () => {
|
||||
[peerA, peerB] = await createPeerIdsFromFixtures(2);
|
||||
});
|
||||
|
||||
it("should store and load same key successfully", async() => {
|
||||
try {
|
||||
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");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
assert(false, `Test failed - ${e.message}`)
|
||||
}
|
||||
});
|
||||
|
||||
it("should return undefined if key not found", async() => {
|
||||
try {
|
||||
const [newPeer] = await createPeerIds(1);
|
||||
const result = await KeyCache.load(newPeer);
|
||||
assert(!result);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
assert(false, `Test failed - ${e.message}`)
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user