test: proof of work utils

This commit is contained in:
Ricardo Arturo Cabral Mejia 2022-10-03 01:48:06 +00:00
parent ac5a9d6788
commit dca599da26
No known key found for this signature in database
GPG Key ID: 5931EBF43A650245

View File

@ -0,0 +1,10 @@
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)
})
})
})