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

41 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-06-20 00:20:09 +02:00
import { assert } from 'chai'
import { AccessSecretStoreCondition } from '../../../src/keeper/contracts/conditions'
import { Ocean } from '../../../src/ocean/Ocean'
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-09-09 12:18:54 +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)
})
})
})