Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Blockchain:hash returns incorrect hash #9150

Merged
merged 6 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions commander/src/bootstrapping/commands/blockchain/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ 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,
},
]),
),
} as never);
jest.spyOn(appUtils, 'getPid').mockReturnValue(pid);
});
Expand Down