You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
685 B
23 lines
685 B
const { describe, it } = require('mocha')
|
|
const assert = require('assert')
|
|
const bcrypto = require('../src/crypto')
|
|
|
|
const fixtures = require('./fixtures/crypto')
|
|
|
|
describe('crypto', function () {
|
|
['hash160', 'hash256', 'ripemd160', 'sha1', 'sha256'].forEach(function (algorithm) {
|
|
describe(algorithm, function () {
|
|
fixtures.forEach(function (f) {
|
|
const fn = bcrypto[algorithm]
|
|
const expected = f[algorithm]
|
|
|
|
it('returns ' + expected + ' for ' + f.hex, function () {
|
|
const data = Buffer.from(f.hex, 'hex')
|
|
const actual = fn(data).toString('hex')
|
|
|
|
assert.strictEqual(actual, expected)
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|
|
|