import {assert} from "chai" import ConfigProvider from "../../../src/ConfigProvider" import { AccessSecretStoreCondition } from "../../../src/keeper/contracts/conditions" import Keeper from "../../../src/keeper/Keeper" import config from "../../config" import TestContractHandler from "../TestContractHandler" let condition: AccessSecretStoreCondition describe("AccessSecretStoreCondition", () => { const agreementId = `0x${"a".repeat(64)}` const did = `0x${"a".repeat(64)}` const address = `0x${"a".repeat(40)}` before(async () => { ConfigProvider.setConfig(config) await TestContractHandler.prepareContracts() condition = (await Keeper.getInstance()).conditions.accessSecretStoreCondition }) describe("#hashValues()", () => { it("should hash the values", async () => { const hash = await condition.hashValues(did, address) assert.match(hash, /^0x[a-f0-9]{64}$/i) assert.equal(hash, "0x1abbd7e58bc32bff739ee1e756a4108882322f2ec939d5e2f251e6b8424947fb", "The hash is not the expected.") }) }) describe("#generateId()", () => { it("should generate an ID", async () => { const hash = await condition.hashValues(did, address) const id = await condition.generateId(agreementId, hash) assert.match(id, /^0x[a-f0-9]{64}$/i) }) }) })