Skip to content

Commit 9e37040

Browse files
refactor(core-blockchain): block processing (#4155)
1 parent 02c272e commit 9e37040

29 files changed

+1148
-509
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { Utils } from "@packages/crypto";
2+
3+
export const block1 = {
4+
data: {
5+
id: "17184958558311101492",
6+
version: 0,
7+
timestamp: 0,
8+
height: 1,
9+
},
10+
transactions: [],
11+
};
12+
13+
export const block2 = {
14+
data: {
15+
id: "17882607875259085966",
16+
version: 0,
17+
timestamp: 46583330,
18+
height: 2,
19+
reward: Utils.BigNumber.make("0"),
20+
previousBlock: "17184958558311101492",
21+
numberOfTransactions: 0,
22+
totalAmount: Utils.BigNumber.make("0"),
23+
totalFee: Utils.BigNumber.make("0"),
24+
payloadLength: 0,
25+
payloadHash: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
26+
generatorPublicKey: "026c598170201caf0357f202ff14f365a3b09322071e347873869f58d776bfc565",
27+
blockSignature:
28+
"3045022100e7385c6ea42bd950f7f6ab8c8619cf2f66a41d8f8f185b0bc99af032cb25f30d02200b6210176a6cedfdcbe483167fd91c21d740e0e4011d24d679c601fdd46b0de9",
29+
// createdAt: "2018-09-11T16:48:50.550Z",
30+
},
31+
transactions: [],
32+
};
33+
export const block3 = {
34+
data: {
35+
id: "7242383292164246617",
36+
version: 0,
37+
timestamp: 46583338,
38+
height: 3,
39+
reward: Utils.BigNumber.make("0"),
40+
previousBlock: "17882607875259085966",
41+
numberOfTransactions: 0,
42+
totalAmount: Utils.BigNumber.make("0"),
43+
totalFee: Utils.BigNumber.make("0"),
44+
payloadLength: 0,
45+
payloadHash: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
46+
generatorPublicKey: "038082dad560a22ea003022015e3136b21ef1ffd9f2fd50049026cbe8e2258ca17",
47+
blockSignature:
48+
"304402204087bb1d2c82b9178b02b9b3f285de260cdf0778643064fe6c7aef27321d49520220594c57009c1fca543350126d277c6adeb674c00685a464c3e4bf0d634dc37e39",
49+
createdAt: "2018-09-11T16:48:58.431Z",
50+
},
51+
transactions: [],
52+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * as Blocks from "./blocks";
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { ProcessBlockAction } from "@packages/core-blockchain/src/actions/process-block";
2+
3+
const blockProcessor = {
4+
process: jest.fn(),
5+
};
6+
7+
const block = {
8+
id: "dummy_block_id",
9+
};
10+
11+
describe("ProcessBlockAction", () => {
12+
it("should execute", async () => {
13+
const action = new ProcessBlockAction();
14+
15+
await action.execute({ blockProcessor, block });
16+
17+
expect(blockProcessor.process).toHaveBeenCalledWith(block);
18+
});
19+
});

0 commit comments

Comments
 (0)