nostream/test/unit/utils/proof-of-work.spec.ts
Ricardo Arturo Cabral Mejia dca599da26
test: proof of work utils
2022-10-18 23:11:36 -04:00

11 lines
435 B
TypeScript

import { expect } from 'chai'
import { getLeadingZeroBits } from '../../../src/utils/proof-of-work'
describe('getLeadingZeroBits()', () => {
['80', '40', '20', '10', '08', '04', '02', '01', '0080', '0040', '0020', '0010', '0008', '0004', '0002', '0001', '0000'].forEach((input, index) => {
it(`returns ${index} given ${input}`, () => {
expect(getLeadingZeroBits(Buffer.from(input, 'hex'))).to.equal(index)
})
})
})