diff --git a/commander/src/bootstrapping/commands/blockchain/hash.ts b/commander/src/bootstrapping/commands/blockchain/hash.ts index 3b792b848b9..f5c1578caec 100644 --- a/commander/src/bootstrapping/commands/blockchain/hash.ts +++ b/commander/src/bootstrapping/commands/blockchain/hash.ts @@ -54,8 +54,8 @@ export class HashCommand extends Command { const dbHash = crypto.createHash('sha256'); const hash: Buffer = await new Promise((resolve, reject) => { - stream.on('data', (chunk: Buffer) => { - dbHash.update(chunk); + stream.on('data', ({ value }: { key: Buffer; value: Buffer }) => { + dbHash.update(value); }); stream.on('error', error => { @@ -68,7 +68,7 @@ export class HashCommand extends Command { }); this.debug('Hash generation completed.'); - this.log(hash.toString('hex')); + db.close(); } } diff --git a/commander/test/bootstrapping/commands/blockchain/hash.spec.ts b/commander/test/bootstrapping/commands/blockchain/hash.spec.ts index ee3d6f9fb01..a63b506b82f 100644 --- a/commander/test/bootstrapping/commands/blockchain/hash.spec.ts +++ b/commander/test/bootstrapping/commands/blockchain/hash.spec.ts @@ -46,7 +46,14 @@ describe('blockchain:hash', () => { }; jest.spyOn(crypto, 'createHash').mockReturnValue(hashStub as never); jest.spyOn(dbUtils, 'getBlockchainDB').mockReturnValue({ - createReadStream: jest.fn().mockReturnValue(Readable.from([hashBuffer])), + createReadStream: jest.fn().mockReturnValue( + Readable.from([ + { + value: hashBuffer, + }, + ]), + ), + close: jest.fn(), } as never); jest.spyOn(appUtils, 'getPid').mockReturnValue(pid); });