bitcoinjs-lib/test/crypto.spec.ts

23 lines
680 B
TypeScript
Raw Permalink Normal View History

import * as assert from 'assert';
import { describe, it } from 'mocha';
import { crypto as bcrypto } from '..';
import * as fixtures from './fixtures/crypto.json';
2014-04-08 15:39:22 +02:00
describe('crypto', () => {
['hash160', 'hash256', 'ripemd160', 'sha1', 'sha256'].forEach(algorithm => {
describe(algorithm, () => {
fixtures.forEach(f => {
const fn = (bcrypto as any)[algorithm];
const expected = (f as any)[algorithm];
2014-09-20 03:20:55 +02:00
it('returns ' + expected + ' for ' + f.hex, () => {
const data = Buffer.from(f.hex, 'hex');
const actual = fn(data).toString('hex');
2014-09-20 03:20:55 +02:00
assert.strictEqual(actual, expected);
});
});
});
});
});