2019-03-06 15:58:15 +01:00
|
|
|
import {assert} from "chai"
|
|
|
|
import { AccessSecretStoreCondition } from "../../../src/keeper/contracts/conditions"
|
2019-03-21 02:56:58 +01:00
|
|
|
import { Ocean } from "../../../src/ocean/Ocean"
|
2019-03-06 15:58:15 +01:00
|
|
|
import config from "../../config"
|
|
|
|
import TestContractHandler from "../TestContractHandler"
|
|
|
|
|
|
|
|
let condition: AccessSecretStoreCondition
|
|
|
|
|
|
|
|
describe("AccessSecretStoreCondition", () => {
|
|
|
|
|
|
|
|
const agreementId = `0x${"a".repeat(64)}`
|
2019-03-21 02:56:58 +01:00
|
|
|
const did = `did:op:${"a".repeat(64)}`
|
2019-03-06 15:58:15 +01:00
|
|
|
const address = `0x${"a".repeat(40)}`
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
await TestContractHandler.prepareContracts()
|
2019-03-21 02:56:58 +01:00
|
|
|
condition = (await Ocean.getInstance(config)).keeper.conditions.accessSecretStoreCondition
|
2019-03-06 15:58:15 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
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)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|