-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core-blockchain): block processing (#4155)
- Loading branch information
1 parent
02c272e
commit 9e37040
Showing
29 changed files
with
1,148 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Utils } from "@packages/crypto"; | ||
|
||
export const block1 = { | ||
data: { | ||
id: "17184958558311101492", | ||
version: 0, | ||
timestamp: 0, | ||
height: 1, | ||
}, | ||
transactions: [], | ||
}; | ||
|
||
export const block2 = { | ||
data: { | ||
id: "17882607875259085966", | ||
version: 0, | ||
timestamp: 46583330, | ||
height: 2, | ||
reward: Utils.BigNumber.make("0"), | ||
previousBlock: "17184958558311101492", | ||
numberOfTransactions: 0, | ||
totalAmount: Utils.BigNumber.make("0"), | ||
totalFee: Utils.BigNumber.make("0"), | ||
payloadLength: 0, | ||
payloadHash: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", | ||
generatorPublicKey: "026c598170201caf0357f202ff14f365a3b09322071e347873869f58d776bfc565", | ||
blockSignature: | ||
"3045022100e7385c6ea42bd950f7f6ab8c8619cf2f66a41d8f8f185b0bc99af032cb25f30d02200b6210176a6cedfdcbe483167fd91c21d740e0e4011d24d679c601fdd46b0de9", | ||
// createdAt: "2018-09-11T16:48:50.550Z", | ||
}, | ||
transactions: [], | ||
}; | ||
export const block3 = { | ||
data: { | ||
id: "7242383292164246617", | ||
version: 0, | ||
timestamp: 46583338, | ||
height: 3, | ||
reward: Utils.BigNumber.make("0"), | ||
previousBlock: "17882607875259085966", | ||
numberOfTransactions: 0, | ||
totalAmount: Utils.BigNumber.make("0"), | ||
totalFee: Utils.BigNumber.make("0"), | ||
payloadLength: 0, | ||
payloadHash: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", | ||
generatorPublicKey: "038082dad560a22ea003022015e3136b21ef1ffd9f2fd50049026cbe8e2258ca17", | ||
blockSignature: | ||
"304402204087bb1d2c82b9178b02b9b3f285de260cdf0778643064fe6c7aef27321d49520220594c57009c1fca543350126d277c6adeb674c00685a464c3e4bf0d634dc37e39", | ||
createdAt: "2018-09-11T16:48:58.431Z", | ||
}, | ||
transactions: [], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * as Blocks from "./blocks"; |
19 changes: 19 additions & 0 deletions
19
__tests__/unit/core-blockchain/actions/process-block.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ProcessBlockAction } from "@packages/core-blockchain/src/actions/process-block"; | ||
|
||
const blockProcessor = { | ||
process: jest.fn(), | ||
}; | ||
|
||
const block = { | ||
id: "dummy_block_id", | ||
}; | ||
|
||
describe("ProcessBlockAction", () => { | ||
it("should execute", async () => { | ||
const action = new ProcessBlockAction(); | ||
|
||
await action.execute({ blockProcessor, block }); | ||
|
||
expect(blockProcessor.process).toHaveBeenCalledWith(block); | ||
}); | ||
}); |
Oops, something went wrong.