/
core-container.ts
79 lines (70 loc) · 2.48 KB
/
core-container.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { configManager } from "@arkecosystem/crypto";
import { blocks2to100 } from "../../../utils/fixtures";
import { delegates } from "../../../utils/fixtures/testnet/delegates";
import { genesisBlock } from "../../../utils/fixtures/unitnet/block-model";
configManager.setFromPreset("testnet");
jest.mock("@arkecosystem/core-container", () => {
return {
app: {
getConfig: () => {
return {
get: key => {
if (key === "network.nethash") {
return configManager.get("nethash");
}
return null;
},
config: { milestones: [{ activeDelegates: 51, height: 1 }] },
getMilestone: () => ({
activeDelegates: 51,
}),
};
},
getVersion: () => "2.3.0",
has: () => true,
resolvePlugin: name => {
if (name === "logger") {
return {
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
debug: jest.fn(),
};
}
if (name === "database") {
return {
getBlocksByHeight: heights => {
if (heights[0] === 1) {
return [genesisBlock.data];
}
return [];
},
getActiveDelegates: height => {
return delegates;
},
loadActiveDelegateList: (count, height) => {
if (height === 2) {
return [blocks2to100[1]];
}
return delegates;
},
};
}
if (name === "event-emitter") {
return {
emit: jest.fn(),
};
}
return {};
},
resolve: name => {
if (name === "state") {
return {
getLastBlock: () => genesisBlock,
};
}
return {};
},
},
};
});