mirror of
https://github.com/tornadocash/fixed-merkle-tree.git
synced 2024-11-22 01:37:09 +01:00
add simpleHash function & tests, add coverage
This commit is contained in:
parent
e6a1ce979c
commit
744438ceba
14
.run/ts-mocha.run.xml
Normal file
14
.run/ts-mocha.run.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="ts-mocha" type="mocha-javascript-test-runner">
|
||||
<node-interpreter>project</node-interpreter>
|
||||
<node-options />
|
||||
<mocha-package>$PROJECT_DIR$/node_modules/ts-mocha</mocha-package>
|
||||
<working-directory>$PROJECT_DIR$</working-directory>
|
||||
<pass-parent-env>true</pass-parent-env>
|
||||
<ui>bdd</ui>
|
||||
<extra-mocha-options />
|
||||
<test-kind>PATTERN</test-kind>
|
||||
<test-pattern>$PROJECT_DIR$/test/*.spec.ts</test-pattern>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
@ -5,6 +5,10 @@
|
||||
"repository": "https://github.com/tornadocash/fixed-merkle-tree.git",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"engines": {
|
||||
"node": "14.17",
|
||||
"npm": "6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "ts-mocha 'test/*.spec.ts'",
|
||||
"build": "tsc",
|
||||
@ -22,7 +26,6 @@
|
||||
"files": [
|
||||
"src/*"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@types/expect": "^24.3.0",
|
||||
"@types/mocha": "^9.1.0",
|
||||
@ -31,6 +34,7 @@
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^8.9.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"nyc": "^15.1.0",
|
||||
"mocha": "^9.2.1",
|
||||
"ts-mocha": "^9.0.2",
|
||||
"typescript": "^4.5.5"
|
||||
|
18
test/simpleHash.spec.ts
Normal file
18
test/simpleHash.spec.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import simpleHash from '../src/simpleHash'
|
||||
import { it } from 'mocha'
|
||||
import { should } from 'chai'
|
||||
|
||||
describe('SimpleHash', () => {
|
||||
it('should return correct hash string with default params', () => {
|
||||
const hash = simpleHash([1, 2, 3])
|
||||
return should().equal(hash, '3530513397947785053296897142557895557120')
|
||||
})
|
||||
it('should return correct hash string with length param', () => {
|
||||
const hash = simpleHash([1, 2, 3], null, 77)
|
||||
return should().equal(hash, '1259729275322113643079999203492506359813191573070980317691663537897682854338069790720')
|
||||
})
|
||||
it('should return correct hash string with seed param', () => {
|
||||
const hash = simpleHash(['1', '2', '3'], 123)
|
||||
return should().equal(hash, '1371592418687375416654554138100746944512')
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user