Skip to content

Commit

Permalink
fix(core-database): allow legacy transaction in getBlocksForRound (#3…
Browse files Browse the repository at this point in the history
…372)

* fix: allow legacy transaction in getBlocksForRound
use deserializeTransactionsUnchecked option to disable checks
(as we get the block and txs from our own db)
  • Loading branch information
air1one authored and spkjp committed Jan 6, 2020
1 parent 4d5b365 commit 16446a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions __tests__/unit/crypto/blocks/factory.test.ts
Expand Up @@ -37,6 +37,16 @@ describe("BlockFactory", () => {
expectBlock(BlockFactory.fromData(dummyBlock));
});

it("should create a block instance when aip11 is true, block transactions are v1, and option deserializeTransactionsUnchecked is true", () => {
const milestone = configManager.getMilestone();
const spyGetMilestone = jest.spyOn(configManager, "getMilestone").mockReturnValue({
...milestone,
aip11: true
});
expectBlock(BlockFactory.fromData(dummyBlock, { deserializeTransactionsUnchecked: true }));
spyGetMilestone.mockRestore();
});

it("should create a block with exceptions", () => {
// @ts-ignore
expect(() => BlockFactory.fromData(blockWithExceptions)).not.toThrow();
Expand Down
2 changes: 1 addition & 1 deletion packages/core-database/src/database-service.ts
Expand Up @@ -350,7 +350,7 @@ export class DatabaseService implements Database.IDatabaseService {
.getGenesisBlock();
}

return Blocks.BlockFactory.fromData(block);
return Blocks.BlockFactory.fromData(block, { deserializeTransactionsUnchecked: true });
},
);
}
Expand Down

0 comments on commit 16446a1

Please sign in to comment.