-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* expose sha256 for testing * Expose sha256 for testing * Remove unused code * Add common test functions * Use npm assert * move test utils to TS * Remove test code * Remove test code * Remove test code
- Loading branch information
Showing
3 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
export function to_hex_string(byteArray: Array<number>) { | ||
return Array.from(byteArray, function(byte: number) { | ||
return ('0' + (byte & 0xFF).toString(16)).slice(-2); | ||
}).join('') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { init, sha256bytes } from '../../../../pkg/chia_gaming_wasm.js'; | ||
import { to_hex_string } from './common'; | ||
import * as assert from 'assert'; | ||
|
||
let utf8Encode = new TextEncoder(); | ||
let b = utf8Encode.encode("abc"); | ||
|
||
it('hashes', async () => { | ||
init(); | ||
let msg = 'hello.there.my.dear.friend'; | ||
let hash = sha256bytes(msg); | ||
console.log(msg, hash); | ||
assert.equal( to_hex_string(hash), "5272821c151fdd49f19cc58cf8833da5781c7478a36d500e8dc2364be39f8216" ); | ||
}); |