@@ -9,7 +9,7 @@ test('sum from native', (t) => {
9
9
10
10
// empty hash a67c89456ea2fcd58cdf557c01357632d4f0d28c51dd0d8f79a4c739352f71a7
11
11
12
- function testEncode ( t , imagePath , expectedHash ) {
12
+ function testEncode ( t , imagePath , expectedHash , trim = false ) {
13
13
let buffer = fs . readFileSync ( imagePath ) ;
14
14
15
15
//let arr = new Uint8Array(buffer);
@@ -19,6 +19,9 @@ function testEncode(t, imagePath, expectedHash) {
19
19
console . log ( 'hash ' , hash ) ;
20
20
21
21
let mchash = Buffer . from ( encoded . minecraftHash ) . toString ( 'hex' ) ;
22
+ if ( trim ) {
23
+ mchash = mchash . replace ( / ^ 0 + / , '' ) ;
24
+ }
22
25
console . log ( 'mchash ' , mchash ) ;
23
26
24
27
console . log ( 'expected' , expectedHash ) ;
@@ -35,7 +38,8 @@ for (const params of [
35
38
[ 'images/randomImage2.png' , '57a6d6ddebafe045e9a0501c7c489f6de47e670fc4ef1b0c1b2c2a9a2c8c0cbc' ] ,
36
39
[ 'images/randomImage3.png' , '1b84a8081994cce186eeae4787f95bce663d6711272782ce659d9cc954fec435' ] ,
37
40
[ 'images/randomImage4.png' , 'e19abca2800650b449fff3f12ed3d1bd0f20861d7cdd00c66d62264b52837e2c' ] ,
38
- [ 'images/trimmed0.png' , '0aa97a60ff386b6075aea693893106358def0cd580e6360599811e08bde38b6f' ] // mojang strips the leading 0, this doesn't currently
41
+ [ 'images/trimmed0.png' , '0aa97a60ff386b6075aea693893106358def0cd580e6360599811e08bde38b6f' ] , // mojang strips the leading 0, this doesn't currently
42
+ [ 'images/trimmed0.png' , 'aa97a60ff386b6075aea693893106358def0cd580e6360599811e08bde38b6f' , true ]
39
43
] ) {
40
44
test ( testEncode , ...params ) ;
41
45
}
0 commit comments