1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/test/unit/keeper/conditions/AccessSecretStoreCondition.test.ts

42 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-06-20 00:20:09 +02:00
import { assert } from 'chai'
2020-01-30 22:08:18 +01:00
import { AccessSecretStoreCondition } from '../../../../src/keeper/contracts/conditions'
import { Ocean } from '../../../../src/ocean/Ocean'
2019-06-20 00:20:09 +02:00
import config from '../../config'
import TestContractHandler from '../TestContractHandler'
2019-03-06 15:58:15 +01:00
let condition: AccessSecretStoreCondition
2019-06-20 00:20:09 +02:00
describe('AccessSecretStoreCondition', () => {
const agreementId = `0x${'a'.repeat(64)}`
const did = `did:op:${'a'.repeat(64)}`
const address = `0x${'a'.repeat(40)}`
2019-03-06 15:58:15 +01:00
before(async () => {
await TestContractHandler.prepareContracts()
2019-06-20 00:20:09 +02:00
condition = (await Ocean.getInstance(config)).keeper.conditions
.accessSecretStoreCondition
2019-03-06 15:58:15 +01:00
})
2019-06-20 00:20:09 +02:00
describe('#hashValues()', () => {
it('should hash the values', async () => {
2019-03-06 15:58:15 +01:00
const hash = await condition.hashValues(did, address)
assert.match(hash, /^0x[a-f0-9]{64}$/i)
2019-06-20 00:20:09 +02:00
assert.equal(
hash,
'0x1abbd7e58bc32bff739ee1e756a4108882322f2ec939d5e2f251e6b8424947fb',
'The hash is not the expected.'
)
2019-03-06 15:58:15 +01:00
})
})
2019-06-20 00:20:09 +02:00
describe('#generateId()', () => {
it('should generate an ID', async () => {
2019-03-06 15:58:15 +01:00
const hash = await condition.hashValues(did, address)
const id = await condition.generateId(agreementId, hash)
assert.match(id, /^0x[a-f0-9]{64}$/i)
})
})
})