From dca599da26b0785d186e181b7f6df108a15fefaf Mon Sep 17 00:00:00 2001 From: Ricardo Arturo Cabral Mejia Date: Mon, 3 Oct 2022 01:48:06 +0000 Subject: [PATCH] test: proof of work utils --- test/unit/utils/proof-of-work.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 test/unit/utils/proof-of-work.spec.ts diff --git a/test/unit/utils/proof-of-work.spec.ts b/test/unit/utils/proof-of-work.spec.ts new file mode 100644 index 0000000..062e06c --- /dev/null +++ b/test/unit/utils/proof-of-work.spec.ts @@ -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) + }) + }) +})