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/LockRewardCondition.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 { LockRewardCondition } 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: LockRewardCondition
2019-06-20 00:20:09 +02:00
describe('LockRewardCondition', () => {
const agreementId = `0x${'a'.repeat(64)}`
const address = `0x${'a'.repeat(40)}`
2019-03-06 15:58:15 +01:00
const amount = 15
before(async () => {
await TestContractHandler.prepareContracts()
2019-09-09 12:18:54 +02:00
condition = (await Ocean.getInstance(config)).keeper.conditions.lockRewardCondition
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(address, amount)
assert.match(hash, /^0x[a-f0-9]{64}$/i)
2019-06-20 00:20:09 +02:00
assert.equal(
hash,
'0x2543c2ea4b9403bb3e5df1145c70731454748e72a37acc80d025f85e03267973',
'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(address, amount)
const id = await condition.generateId(agreementId, hash)
assert.match(id, /^0x[a-f0-9]{64}$/i)
})
})
})