This repository was archived by the owner on Jun 11, 2024. It is now read-only.
File tree 2 files changed +11
-4
lines changed
src/bootstrapping/commands/blockchain
test/bootstrapping/commands/blockchain
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,8 @@ export class HashCommand extends Command {
54
54
const dbHash = crypto . createHash ( 'sha256' ) ;
55
55
56
56
const hash : Buffer = await new Promise ( ( resolve , reject ) => {
57
- stream . on ( 'data' , ( chunk : Buffer ) => {
58
- dbHash . update ( chunk ) ;
57
+ stream . on ( 'data' , ( { value } : { key : Buffer ; value : Buffer } ) => {
58
+ dbHash . update ( value ) ;
59
59
} ) ;
60
60
61
61
stream . on ( 'error' , error => {
@@ -68,7 +68,7 @@ export class HashCommand extends Command {
68
68
} ) ;
69
69
70
70
this . debug ( 'Hash generation completed.' ) ;
71
-
72
71
this . log ( hash . toString ( 'hex' ) ) ;
72
+ db . close ( ) ;
73
73
}
74
74
}
Original file line number Diff line number Diff line change @@ -46,7 +46,14 @@ describe('blockchain:hash', () => {
46
46
} ;
47
47
jest . spyOn ( crypto , 'createHash' ) . mockReturnValue ( hashStub as never ) ;
48
48
jest . spyOn ( dbUtils , 'getBlockchainDB' ) . mockReturnValue ( {
49
- createReadStream : jest . fn ( ) . mockReturnValue ( Readable . from ( [ hashBuffer ] ) ) ,
49
+ createReadStream : jest . fn ( ) . mockReturnValue (
50
+ Readable . from ( [
51
+ {
52
+ value : hashBuffer ,
53
+ } ,
54
+ ] ) ,
55
+ ) ,
56
+ close : jest . fn ( ) ,
50
57
} as never ) ;
51
58
jest . spyOn ( appUtils , 'getPid' ) . mockReturnValue ( pid ) ;
52
59
} ) ;
You can’t perform that action at this time.
0 commit comments