Create key cache

This commit is contained in:
Belma Gutlic
2020-01-13 15:38:14 +01:00
parent 86c909d399
commit ce7f4118c2
5 changed files with 76 additions and 1 deletions

23
test/keycache.test.ts Normal file
View File

@@ -0,0 +1,23 @@
import { expect, assert } from "chai";
import { KeyCache } from "../src/keycache";
import {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}`)
}
});
});