@rosen-bridge/abstract-extractor 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/ergo/{AbstractErgoExtractor.d.ts → abstractErgoExtractor.d.ts} +3 -3
- package/dist/ergo/abstractErgoExtractor.d.ts.map +1 -0
- package/dist/ergo/{AbstractErgoExtractor.js → abstractErgoExtractor.js} +3 -3
- package/dist/ergo/{AbstractErgoExtractorAction.d.ts → abstractErgoExtractorAction.d.ts} +6 -4
- package/dist/ergo/abstractErgoExtractorAction.d.ts.map +1 -0
- package/dist/ergo/abstractErgoExtractorAction.js +219 -0
- package/dist/ergo/{AbstractErgoExtractorEntity.d.ts → abstractErgoExtractorEntity.d.ts} +1 -1
- package/dist/ergo/{AbstractErgoExtractorEntity.d.ts.map → abstractErgoExtractorEntity.d.ts.map} +1 -1
- package/dist/ergo/{AbstractErgoExtractorEntity.js → abstractErgoExtractorEntity.js} +1 -1
- package/dist/ergo/index.d.ts +6 -6
- package/dist/ergo/index.js +7 -7
- package/dist/ergo/initializable/{AbstractInitializable.d.ts → abstractInitializable.d.ts} +4 -4
- package/dist/ergo/initializable/{AbstractInitializable.d.ts.map → abstractInitializable.d.ts.map} +1 -1
- package/dist/ergo/initializable/abstractInitializable.js +162 -0
- package/dist/ergo/initializable/{AbstractInitializableAction.d.ts → abstractInitializableAction.d.ts} +4 -4
- package/dist/ergo/initializable/abstractInitializableAction.d.ts.map +1 -0
- package/dist/ergo/initializable/{AbstractInitializableAction.js → abstractInitializableAction.js} +2 -2
- package/dist/ergo/initializable/index.d.ts +2 -2
- package/dist/ergo/initializable/index.js +3 -3
- package/dist/{lib/ergo/network/AbstractNetwork.d.ts → ergo/network/abstractNetwork.d.ts} +1 -1
- package/dist/ergo/network/{AbstractNetwork.d.ts.map → abstractNetwork.d.ts.map} +1 -1
- package/dist/ergo/network/{AbstractNetwork.js → abstractNetwork.js} +1 -1
- package/dist/{lib/ergo/network/ExplorerNetwork.d.ts → ergo/network/explorerNetwork.d.ts} +2 -2
- package/dist/ergo/network/explorerNetwork.d.ts.map +1 -0
- package/dist/ergo/network/{ExplorerNetwork.js → explorerNetwork.js} +3 -3
- package/dist/ergo/network/{NodeNetwork.d.ts → nodeNetwork.d.ts} +2 -2
- package/dist/ergo/network/nodeNetwork.d.ts.map +1 -0
- package/dist/ergo/network/nodeNetwork.js +131 -0
- package/dist/ergo/utils.d.ts.map +1 -1
- package/dist/ergo/utils.js +1 -1
- package/package.json +24 -16
- package/.eslintignore +0 -1
- package/dist/ergo/AbstractErgoExtractor.d.ts.map +0 -1
- package/dist/ergo/AbstractErgoExtractorAction.d.ts.map +0 -1
- package/dist/ergo/AbstractErgoExtractorAction.js +0 -222
- package/dist/ergo/initializable/AbstractInitializable.js +0 -163
- package/dist/ergo/initializable/AbstractInitializableAction.d.ts.map +0 -1
- package/dist/ergo/network/AbstractNetwork.d.ts +0 -26
- package/dist/ergo/network/ExplorerNetwork.d.ts +0 -74
- package/dist/ergo/network/ExplorerNetwork.d.ts.map +0 -1
- package/dist/ergo/network/NodeNetwork.d.ts.map +0 -1
- package/dist/ergo/network/NodeNetwork.js +0 -131
- package/dist/lib/abstractExtractor.d.ts +0 -25
- package/dist/lib/abstractExtractor.d.ts.map +0 -1
- package/dist/lib/abstractExtractor.js +0 -3
- package/dist/lib/constants.d.ts +0 -4
- package/dist/lib/constants.d.ts.map +0 -1
- package/dist/lib/constants.js +0 -4
- package/dist/lib/ergo/AbstractErgoExtractor.d.ts +0 -80
- package/dist/lib/ergo/AbstractErgoExtractor.d.ts.map +0 -1
- package/dist/lib/ergo/AbstractErgoExtractor.js +0 -142
- package/dist/lib/ergo/AbstractErgoExtractorAction.d.ts +0 -92
- package/dist/lib/ergo/AbstractErgoExtractorAction.d.ts.map +0 -1
- package/dist/lib/ergo/AbstractErgoExtractorAction.js +0 -222
- package/dist/lib/ergo/AbstractErgoExtractorEntity.d.ts +0 -11
- package/dist/lib/ergo/AbstractErgoExtractorEntity.d.ts.map +0 -1
- package/dist/lib/ergo/AbstractErgoExtractorEntity.js +0 -57
- package/dist/lib/ergo/index.d.ts +0 -10
- package/dist/lib/ergo/index.d.ts.map +0 -1
- package/dist/lib/ergo/index.js +0 -10
- package/dist/lib/ergo/initializable/AbstractInitializable.d.ts +0 -48
- package/dist/lib/ergo/initializable/AbstractInitializable.d.ts.map +0 -1
- package/dist/lib/ergo/initializable/AbstractInitializable.js +0 -163
- package/dist/lib/ergo/initializable/AbstractInitializableAction.d.ts +0 -14
- package/dist/lib/ergo/initializable/AbstractInitializableAction.d.ts.map +0 -1
- package/dist/lib/ergo/initializable/AbstractInitializableAction.js +0 -16
- package/dist/lib/ergo/initializable/index.d.ts +0 -3
- package/dist/lib/ergo/initializable/index.d.ts.map +0 -1
- package/dist/lib/ergo/initializable/index.js +0 -3
- package/dist/lib/ergo/interfaces.d.ts +0 -47
- package/dist/lib/ergo/interfaces.d.ts.map +0 -1
- package/dist/lib/ergo/interfaces.js +0 -8
- package/dist/lib/ergo/network/AbstractNetwork.d.ts.map +0 -1
- package/dist/lib/ergo/network/AbstractNetwork.js +0 -3
- package/dist/lib/ergo/network/ExplorerNetwork.d.ts.map +0 -1
- package/dist/lib/ergo/network/ExplorerNetwork.js +0 -185
- package/dist/lib/ergo/network/NodeNetwork.d.ts +0 -60
- package/dist/lib/ergo/network/NodeNetwork.d.ts.map +0 -1
- package/dist/lib/ergo/network/NodeNetwork.js +0 -131
- package/dist/lib/ergo/utils.d.ts +0 -8
- package/dist/lib/ergo/utils.d.ts.map +0 -1
- package/dist/lib/ergo/utils.js +0 -16
- package/dist/lib/index.d.ts +0 -4
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/index.js +0 -4
- package/dist/tests/AbstractErgoExtractor.mock.d.ts +0 -11
- package/dist/tests/AbstractErgoExtractor.mock.d.ts.map +0 -1
- package/dist/tests/AbstractErgoExtractor.mock.js +0 -11
- package/dist/tests/AbstractErgoExtractor.spec.d.ts +0 -2
- package/dist/tests/AbstractErgoExtractor.spec.d.ts.map +0 -1
- package/dist/tests/AbstractErgoExtractor.spec.js +0 -240
- package/dist/tests/AbstractErgoExtractorAction.mock.d.ts +0 -15
- package/dist/tests/AbstractErgoExtractorAction.mock.d.ts.map +0 -1
- package/dist/tests/AbstractErgoExtractorAction.mock.js +0 -27
- package/dist/tests/AbstractErgoExtractorAction.spec.d.ts +0 -2
- package/dist/tests/AbstractErgoExtractorAction.spec.d.ts.map +0 -1
- package/dist/tests/AbstractErgoExtractorAction.spec.js +0 -221
- package/dist/tests/initializable/AbstractInitializable.mock.d.ts +0 -61
- package/dist/tests/initializable/AbstractInitializable.mock.d.ts.map +0 -1
- package/dist/tests/initializable/AbstractInitializable.mock.js +0 -18
- package/dist/tests/initializable/AbstractInitializable.spec.d.ts +0 -2
- package/dist/tests/initializable/AbstractInitializable.spec.d.ts.map +0 -1
- package/dist/tests/initializable/AbstractInitializable.spec.js +0 -299
- package/dist/tests/initializable/AbstractInitializableAction.mock.d.ts +0 -15
- package/dist/tests/initializable/AbstractInitializableAction.mock.d.ts.map +0 -1
- package/dist/tests/initializable/AbstractInitializableAction.mock.js +0 -27
- package/dist/tests/initializable/AbstractInitializableAction.spec.d.ts +0 -2
- package/dist/tests/initializable/AbstractInitializableAction.spec.d.ts.map +0 -1
- package/dist/tests/initializable/AbstractInitializableAction.spec.js +0 -54
- package/dist/tests/initializable/testData.d.ts +0 -94
- package/dist/tests/initializable/testData.d.ts.map +0 -1
- package/dist/tests/initializable/testData.js +0 -235
- package/dist/tests/network/ExplorerNetwork.spec.d.ts +0 -2
- package/dist/tests/network/ExplorerNetwork.spec.d.ts.map +0 -1
- package/dist/tests/network/ExplorerNetwork.spec.js +0 -61
- package/dist/tests/network/NodeNetwork.spec.d.ts +0 -2
- package/dist/tests/network/NodeNetwork.spec.d.ts.map +0 -1
- package/dist/tests/network/NodeNetwork.spec.js +0 -48
- package/dist/tests/network/testData.d.ts +0 -752
- package/dist/tests/network/testData.d.ts.map +0 -1
- package/dist/tests/network/testData.js +0 -1401
- package/dist/tests/testData.d.ts +0 -32
- package/dist/tests/testData.d.ts.map +0 -1
- package/dist/tests/testData.js +0 -121
- package/dist/tests/testUtils.d.ts +0 -9
- package/dist/tests/testUtils.d.ts.map +0 -1
- package/dist/tests/testUtils.js +0 -31
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -18
- package/lib/abstractExtractor.ts +0 -31
- package/lib/constants.ts +0 -3
- package/lib/ergo/AbstractErgoExtractor.ts +0 -227
- package/lib/ergo/AbstractErgoExtractorAction.ts +0 -319
- package/lib/ergo/AbstractErgoExtractorEntity.ts +0 -32
- package/lib/ergo/index.ts +0 -9
- package/lib/ergo/initializable/AbstractInitializable.ts +0 -228
- package/lib/ergo/initializable/AbstractInitializableAction.ts +0 -33
- package/lib/ergo/initializable/index.ts +0 -2
- package/lib/ergo/interfaces.ts +0 -51
- package/lib/ergo/network/AbstractNetwork.ts +0 -29
- package/lib/ergo/network/ExplorerNetwork.ts +0 -237
- package/lib/ergo/network/NodeNetwork.ts +0 -169
- package/lib/ergo/utils.ts +0 -15
- package/lib/index.ts +0 -3
- package/tests/AbstractErgoExtractor.mock.ts +0 -33
- package/tests/AbstractErgoExtractor.spec.ts +0 -284
- package/tests/AbstractErgoExtractorAction.mock.ts +0 -45
- package/tests/AbstractErgoExtractorAction.spec.ts +0 -268
- package/tests/initializable/AbstractInitializable.mock.ts +0 -44
- package/tests/initializable/AbstractInitializable.spec.ts +0 -386
- package/tests/initializable/AbstractInitializableAction.mock.ts +0 -45
- package/tests/initializable/AbstractInitializableAction.spec.ts +0 -64
- package/tests/initializable/testData.ts +0 -283
- package/tests/network/ExplorerNetwork.spec.ts +0 -73
- package/tests/network/NodeNetwork.spec.ts +0 -56
- package/tests/network/testData.ts +0 -1708
- package/tests/testData.ts +0 -140
- package/tests/testUtils.ts +0 -22
- package/tsconfig.build.json +0 -9
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.json +0 -9
- package/vitest.config.ts +0 -18
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { DataSource, Repository } from '@rosen-bridge/extended-typeorm';
|
|
2
|
-
import { pick } from 'lodash-es';
|
|
3
|
-
|
|
4
|
-
import { TestErgoExtractorAction } from './AbstractErgoExtractorAction.mock';
|
|
5
|
-
import { createDatabase, TestEntity } from './testUtils';
|
|
6
|
-
import { block, block2, sampleEntities } from './testData';
|
|
7
|
-
import { SpendInfo } from '../lib';
|
|
8
|
-
|
|
9
|
-
describe('AbstractErgoExtractorAction', () => {
|
|
10
|
-
let dataSource: DataSource;
|
|
11
|
-
let action: TestErgoExtractorAction;
|
|
12
|
-
let repository: Repository<TestEntity>;
|
|
13
|
-
beforeEach(async () => {
|
|
14
|
-
dataSource = await createDatabase();
|
|
15
|
-
action = new TestErgoExtractorAction(dataSource);
|
|
16
|
-
repository = dataSource.getRepository(TestEntity);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
describe('storeBoxes', () => {
|
|
20
|
-
/**
|
|
21
|
-
* @target storeBoxes should save the passed box entities to database
|
|
22
|
-
* @dependencies
|
|
23
|
-
* @scenario
|
|
24
|
-
* - run test (call `storeBoxes` with 2 new boxes)
|
|
25
|
-
* @expected
|
|
26
|
-
* - to save 2 new entities
|
|
27
|
-
* - to return 2 inserted entity data
|
|
28
|
-
*/
|
|
29
|
-
it(`should save the passed box entities to database`, async () => {
|
|
30
|
-
const result = await action.storeBoxes(
|
|
31
|
-
sampleEntities.slice(0, 2),
|
|
32
|
-
block,
|
|
33
|
-
'extractor1',
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const [rows, rowsCount] = await repository.findAndCount();
|
|
37
|
-
|
|
38
|
-
expect(rowsCount).toEqual(2);
|
|
39
|
-
expect(rows[0]).toMatchObject({
|
|
40
|
-
...sampleEntities[0],
|
|
41
|
-
extractor: 'extractor1',
|
|
42
|
-
block: block.hash,
|
|
43
|
-
height: block.height,
|
|
44
|
-
spendBlock: null,
|
|
45
|
-
spendHeight: null,
|
|
46
|
-
});
|
|
47
|
-
expect(rows[1]).toMatchObject({
|
|
48
|
-
...sampleEntities[1],
|
|
49
|
-
extractor: 'extractor1',
|
|
50
|
-
block: block.hash,
|
|
51
|
-
height: block.height,
|
|
52
|
-
spendBlock: null,
|
|
53
|
-
spendHeight: null,
|
|
54
|
-
});
|
|
55
|
-
expect(result).toEqual(true);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @target storeBoxes should correctly save boxes with different extractors
|
|
60
|
-
* @dependencies
|
|
61
|
-
* @scenario
|
|
62
|
-
* - insert 2 boxes belonging to first-extractor
|
|
63
|
-
* - run test (call `storeBoxes` with same boxes for the second-extractor)
|
|
64
|
-
* @expected
|
|
65
|
-
* - to save 2 new entities belonging to second-extractor
|
|
66
|
-
* - to return 2 new inserted entity data
|
|
67
|
-
*/
|
|
68
|
-
it(`should correctly save boxes with different extractors`, async () => {
|
|
69
|
-
await repository.insert([
|
|
70
|
-
{
|
|
71
|
-
...sampleEntities[0],
|
|
72
|
-
extractor: 'first-extractor',
|
|
73
|
-
block: '1',
|
|
74
|
-
height: 1,
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
...sampleEntities[1],
|
|
78
|
-
extractor: 'first-extractor',
|
|
79
|
-
block: '1',
|
|
80
|
-
height: 1,
|
|
81
|
-
},
|
|
82
|
-
]);
|
|
83
|
-
|
|
84
|
-
const result = await action.storeBoxes(
|
|
85
|
-
[sampleEntities[0], sampleEntities[1]],
|
|
86
|
-
block,
|
|
87
|
-
'second-extractor',
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const [insertedRows] = await repository.findAndCount();
|
|
91
|
-
expect(insertedRows[2]).toMatchObject({
|
|
92
|
-
...sampleEntities[0],
|
|
93
|
-
extractor: 'second-extractor',
|
|
94
|
-
block: 'hash',
|
|
95
|
-
height: block.height,
|
|
96
|
-
spendBlock: null,
|
|
97
|
-
spendHeight: null,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
expect(insertedRows[3]).toMatchObject({
|
|
101
|
-
...sampleEntities[1],
|
|
102
|
-
extractor: 'second-extractor',
|
|
103
|
-
block: 'hash',
|
|
104
|
-
height: block.height,
|
|
105
|
-
spendBlock: null,
|
|
106
|
-
spendHeight: null,
|
|
107
|
-
});
|
|
108
|
-
expect(result).toEqual(true);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* @target storeBoxes should update boxes correctly
|
|
113
|
-
* @dependencies
|
|
114
|
-
* @scenario
|
|
115
|
-
* - insert 2 boxes
|
|
116
|
-
* - run test (call `storeBoxes` with the same boxes and updated info)
|
|
117
|
-
* @expected
|
|
118
|
-
* - to update the existing box in database
|
|
119
|
-
* - to return updated box id
|
|
120
|
-
*/
|
|
121
|
-
it(`storeBoxes should update boxes correctly`, async () => {
|
|
122
|
-
await repository.insert([
|
|
123
|
-
{
|
|
124
|
-
...sampleEntities[0],
|
|
125
|
-
extractor: 'extractor',
|
|
126
|
-
block: '1',
|
|
127
|
-
height: 1,
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
...sampleEntities[1],
|
|
131
|
-
extractor: 'extractor',
|
|
132
|
-
block: '1',
|
|
133
|
-
height: 1,
|
|
134
|
-
},
|
|
135
|
-
]);
|
|
136
|
-
|
|
137
|
-
const result = await action.storeBoxes(
|
|
138
|
-
[
|
|
139
|
-
{
|
|
140
|
-
...sampleEntities[0],
|
|
141
|
-
serialized: 'updatedBoxSerialized',
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
block,
|
|
145
|
-
'extractor',
|
|
146
|
-
);
|
|
147
|
-
const [secondInsertRows, secondInsertRowsCount] =
|
|
148
|
-
await repository.findAndCount();
|
|
149
|
-
expect(secondInsertRowsCount).toEqual(2);
|
|
150
|
-
expect(secondInsertRows[0]).toMatchObject({
|
|
151
|
-
...sampleEntities[0],
|
|
152
|
-
extractor: 'extractor',
|
|
153
|
-
serialized: 'updatedBoxSerialized',
|
|
154
|
-
block: block.hash,
|
|
155
|
-
height: block.height,
|
|
156
|
-
spendBlock: null,
|
|
157
|
-
spendHeight: null,
|
|
158
|
-
});
|
|
159
|
-
expect(result).toEqual(true);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
describe('spendBoxes', () => {
|
|
164
|
-
/**
|
|
165
|
-
* @target spendBoxes should set spendBlock and spendHeight for a set of boxes
|
|
166
|
-
* @dependencies
|
|
167
|
-
* @scenario
|
|
168
|
-
* - insert two boxes
|
|
169
|
-
* - mock spending information for the first box
|
|
170
|
-
* - run test (call `spendBoxes`)
|
|
171
|
-
* @expected
|
|
172
|
-
* - spend the first box
|
|
173
|
-
* - return boxId and serialized of spent box
|
|
174
|
-
*/
|
|
175
|
-
it(`should set spendBlock and spendHeight for a set of boxes`, async () => {
|
|
176
|
-
await action.storeBoxes(sampleEntities.slice(0, 2), block, 'extractor1');
|
|
177
|
-
|
|
178
|
-
const spendBlock = { ...block, hash: 'spendHash', height: 10006016 };
|
|
179
|
-
const spendInfos: Array<SpendInfo> = [
|
|
180
|
-
{ txId: 'txId', boxId: sampleEntities[0].boxId, index: 0 },
|
|
181
|
-
];
|
|
182
|
-
|
|
183
|
-
const spentBoxIds = await action.spendBoxes(
|
|
184
|
-
spendInfos,
|
|
185
|
-
spendBlock,
|
|
186
|
-
'extractor1',
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
const spentBoxes = await repository.findOneBy({
|
|
190
|
-
boxId: sampleEntities[0].boxId,
|
|
191
|
-
extractor: 'extractor1',
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
expect(spentBoxes).toMatchObject({
|
|
195
|
-
...sampleEntities[0],
|
|
196
|
-
block: block.hash,
|
|
197
|
-
height: block.height,
|
|
198
|
-
extractor: 'extractor1',
|
|
199
|
-
spendBlock: spendBlock.hash,
|
|
200
|
-
spendHeight: spendBlock.height,
|
|
201
|
-
});
|
|
202
|
-
expect(spentBoxIds).toEqual([pick(sampleEntities[0], ['boxId'])]);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
describe('deleteBlockBoxes', () => {
|
|
207
|
-
/**
|
|
208
|
-
* @target deleteBlockBoxes should delete the boxes created in the specified block
|
|
209
|
-
* @dependencies
|
|
210
|
-
* @scenario
|
|
211
|
-
* - insert four boxes created in two different blocks
|
|
212
|
-
* - run test(call `deleteBlockBoxes` to delete block2)
|
|
213
|
-
* @expected
|
|
214
|
-
* - to delete the two boxes created in block2
|
|
215
|
-
* - to return the deleted entity data
|
|
216
|
-
*/
|
|
217
|
-
it(`should delete the boxes created in the specified block`, async () => {
|
|
218
|
-
await action.storeBoxes(sampleEntities.slice(0, 2), block, 'extractor1');
|
|
219
|
-
await action.storeBoxes(sampleEntities.slice(2), block2, 'extractor1');
|
|
220
|
-
|
|
221
|
-
const result = await action.deleteBlockBoxes(block2.hash, 'extractor1');
|
|
222
|
-
|
|
223
|
-
const [rows, rowsCount] = await repository.findAndCount();
|
|
224
|
-
|
|
225
|
-
expect(rowsCount).toEqual(2);
|
|
226
|
-
expect(rows.map((row) => row.boxId)).not.toContain(
|
|
227
|
-
sampleEntities.slice(2).map((box) => box.boxId),
|
|
228
|
-
);
|
|
229
|
-
expect(result).toEqual({
|
|
230
|
-
deletedData: action.convertEntityToData(
|
|
231
|
-
sampleEntities.slice(2) as TestEntity[],
|
|
232
|
-
),
|
|
233
|
-
updatedData: [],
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* @target deleteBlockBoxes should update the boxes spent in the specified block
|
|
239
|
-
* @dependencies
|
|
240
|
-
* @scenario
|
|
241
|
-
* - insert four boxes created in a block
|
|
242
|
-
* - spend one of the in the block2
|
|
243
|
-
* - run test(call `deleteBlockBoxes` to delete block2)
|
|
244
|
-
* @expected
|
|
245
|
-
* - to update the box spent in block2
|
|
246
|
-
* - to return the updated entity boxId and serialized
|
|
247
|
-
*/
|
|
248
|
-
it(`should update the boxes spent in the specified block`, async () => {
|
|
249
|
-
await action.storeBoxes(sampleEntities, block, 'extractor1');
|
|
250
|
-
const spendInfos: Array<SpendInfo> = [
|
|
251
|
-
{ txId: 'txId', boxId: sampleEntities[0].boxId, index: 0 },
|
|
252
|
-
];
|
|
253
|
-
await action.spendBoxes(spendInfos, block2, 'extractor1');
|
|
254
|
-
const result = await action.deleteBlockBoxes(block2.hash, 'extractor1');
|
|
255
|
-
|
|
256
|
-
const [rows, rowsCount] = await repository.findAndCount();
|
|
257
|
-
|
|
258
|
-
expect(rowsCount).toEqual(4);
|
|
259
|
-
expect(rows.map((row) => row.boxId)).not.toContain(
|
|
260
|
-
sampleEntities.slice(2).map((box) => box.boxId),
|
|
261
|
-
);
|
|
262
|
-
expect(result).toEqual({
|
|
263
|
-
deletedData: [],
|
|
264
|
-
updatedData: [pick(sampleEntities[0], ['boxId'])],
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { V1 } from '@rosen-clients/ergo-explorer';
|
|
2
|
-
import { BlockInfo, OutputBox } from '@rosen-bridge/scanner-interfaces';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
AbstractInitializableErgoExtractor,
|
|
6
|
-
AbstractInitializableErgoExtractorAction,
|
|
7
|
-
} from '../../lib/ergo/initializable';
|
|
8
|
-
import { AbstractBoxData, AbstractErgoExtractorEntity } from '../../lib';
|
|
9
|
-
import { ergoBoxes } from './testData';
|
|
10
|
-
|
|
11
|
-
export class MockedInitializableErgoExtractor extends AbstractInitializableErgoExtractor<
|
|
12
|
-
AbstractBoxData,
|
|
13
|
-
AbstractErgoExtractorEntity
|
|
14
|
-
> {
|
|
15
|
-
actions: AbstractInitializableErgoExtractorAction<
|
|
16
|
-
AbstractBoxData,
|
|
17
|
-
AbstractErgoExtractorEntity
|
|
18
|
-
>;
|
|
19
|
-
|
|
20
|
-
getId = () => 'Test';
|
|
21
|
-
|
|
22
|
-
hasData = (
|
|
23
|
-
box: V1.OutputInfo | OutputBox, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
24
|
-
) => false;
|
|
25
|
-
|
|
26
|
-
getTxBlock = async (
|
|
27
|
-
txId: string, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
28
|
-
): Promise<BlockInfo> => {
|
|
29
|
-
return { hash: 'hash', height: 100 };
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
getBoxesWithOffsetLimit = (
|
|
33
|
-
offset: number, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
34
|
-
limit: number, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
35
|
-
) => {
|
|
36
|
-
return Promise.resolve({ boxes: ergoBoxes, hasNextBatch: true });
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
extractBoxData = (
|
|
40
|
-
box: V1.OutputInfo | OutputBox, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
41
|
-
) => {
|
|
42
|
-
return undefined;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
import { ErgoNetworkType } from '@rosen-bridge/scanner-interfaces';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
NodeNetwork,
|
|
5
|
-
AbstractBoxData,
|
|
6
|
-
ExplorerNetwork,
|
|
7
|
-
AbstractErgoExtractorEntity,
|
|
8
|
-
} from '../../lib';
|
|
9
|
-
import { MockedInitializableErgoExtractor } from './AbstractInitializable.mock';
|
|
10
|
-
import { transactionBatch } from './testData';
|
|
11
|
-
import { RETRIAL_COUNT } from '../../lib/constants';
|
|
12
|
-
import { AbstractInitializableErgoExtractorAction } from '../../lib/ergo/initializable';
|
|
13
|
-
|
|
14
|
-
describe('AbstractInitializableErgoExtractor', () => {
|
|
15
|
-
describe('getTotalTxCount', () => {
|
|
16
|
-
/**
|
|
17
|
-
* @target getTotalTxCount should return the total tx count
|
|
18
|
-
* @dependencies
|
|
19
|
-
* - explorer network
|
|
20
|
-
* @scenario
|
|
21
|
-
* - mock extractor
|
|
22
|
-
* - mock `getAddressTransactionsWithOffsetLimit` in node network
|
|
23
|
-
* - run test (call `getTotalTxCount`)
|
|
24
|
-
* @expected
|
|
25
|
-
* - return one total tx count
|
|
26
|
-
*/
|
|
27
|
-
it('should return the total tx count', async () => {
|
|
28
|
-
const extractor = new MockedInitializableErgoExtractor(
|
|
29
|
-
ErgoNetworkType.Node,
|
|
30
|
-
'node_url',
|
|
31
|
-
'address',
|
|
32
|
-
);
|
|
33
|
-
(
|
|
34
|
-
extractor['network'] as NodeNetwork
|
|
35
|
-
).getAddressTransactionsWithOffsetLimit = vitest.fn().mockResolvedValue({
|
|
36
|
-
items: [],
|
|
37
|
-
total: 196704,
|
|
38
|
-
});
|
|
39
|
-
const totalTxCount = await extractor['getTotalTxCount']();
|
|
40
|
-
expect(totalTxCount).toEqual(196704);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
describe('processTransactionBatch', () => {
|
|
45
|
-
/**
|
|
46
|
-
* @target processTransactionBatch should group transactions and process them in correct order
|
|
47
|
-
* @dependencies
|
|
48
|
-
* @scenario
|
|
49
|
-
* - mock extractor
|
|
50
|
-
* - spy `processTransactions`
|
|
51
|
-
* - run test (call `processTransactionBatch`)
|
|
52
|
-
* @expected
|
|
53
|
-
* - to group txs in two blocks
|
|
54
|
-
* - to process each blocks transaction separately
|
|
55
|
-
*/
|
|
56
|
-
it('should group transactions and process them in correct order', async () => {
|
|
57
|
-
const extractor = new MockedInitializableErgoExtractor(
|
|
58
|
-
ErgoNetworkType.Node,
|
|
59
|
-
'node_url',
|
|
60
|
-
'address',
|
|
61
|
-
);
|
|
62
|
-
const processSpy = vitest.fn().mockResolvedValue(true);
|
|
63
|
-
extractor.processTransactions = processSpy;
|
|
64
|
-
await extractor['processTransactionBatch'](transactionBatch);
|
|
65
|
-
expect(processSpy).toBeCalledTimes(2);
|
|
66
|
-
expect(processSpy).toHaveBeenCalledWith([transactionBatch[2]], {
|
|
67
|
-
hash: '92eaff11a4a1c29b8654473258f9d837e9ce99fc0a8a4f27c484d5871afcde64',
|
|
68
|
-
height: 1320698,
|
|
69
|
-
});
|
|
70
|
-
expect(processSpy).toHaveBeenLastCalledWith(
|
|
71
|
-
transactionBatch.slice(0, 2),
|
|
72
|
-
{
|
|
73
|
-
hash: 'b861e2134821fcf1fcdad7e6edd56c4e4495b42b2fd72762a4c79ed1db78b44b',
|
|
74
|
-
height: 1320705,
|
|
75
|
-
},
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @target processTransactionBatch should throw error when processing transactions fails for a block
|
|
81
|
-
* @dependencies
|
|
82
|
-
* @scenario
|
|
83
|
-
* - mock extractor
|
|
84
|
-
* - spy `processTransactions` to return false (always fails)
|
|
85
|
-
* - run test (call `processTransactionBatch`)
|
|
86
|
-
* @expected
|
|
87
|
-
* - to throw error
|
|
88
|
-
*/
|
|
89
|
-
it('should throw error when processing transactions fails for a block', async () => {
|
|
90
|
-
const extractor = new MockedInitializableErgoExtractor(
|
|
91
|
-
ErgoNetworkType.Node,
|
|
92
|
-
'node_url',
|
|
93
|
-
'address',
|
|
94
|
-
);
|
|
95
|
-
extractor.processTransactions = vitest.fn().mockResolvedValue(false);
|
|
96
|
-
await expect(() =>
|
|
97
|
-
extractor['processTransactionBatch'](transactionBatch),
|
|
98
|
-
).rejects.toThrowError();
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
describe('initWithRetrial', () => {
|
|
103
|
-
/**
|
|
104
|
-
* @target initWithRetrial should not run the init job when its not set
|
|
105
|
-
* @dependencies
|
|
106
|
-
* - database
|
|
107
|
-
* @scenario
|
|
108
|
-
* - mock extractor with false initialization
|
|
109
|
-
* - mock `removeAllData` in database actions
|
|
110
|
-
* - mock init job
|
|
111
|
-
* - run test (call `initWithRetrial`)
|
|
112
|
-
* @expected
|
|
113
|
-
* - not to remove database old data
|
|
114
|
-
* - not to run the init job
|
|
115
|
-
*/
|
|
116
|
-
it('should not run the init job when its not set', async () => {
|
|
117
|
-
const extractor = new MockedInitializableErgoExtractor(
|
|
118
|
-
ErgoNetworkType.Node,
|
|
119
|
-
'node_url',
|
|
120
|
-
'address',
|
|
121
|
-
undefined,
|
|
122
|
-
false,
|
|
123
|
-
);
|
|
124
|
-
const removeSpy = vitest.fn();
|
|
125
|
-
extractor['actions'] = {
|
|
126
|
-
removeAllData: removeSpy,
|
|
127
|
-
} as unknown as AbstractInitializableErgoExtractorAction<
|
|
128
|
-
AbstractBoxData,
|
|
129
|
-
AbstractErgoExtractorEntity
|
|
130
|
-
>;
|
|
131
|
-
const initSpy = vitest.fn();
|
|
132
|
-
await extractor['initWithRetrial'](initSpy);
|
|
133
|
-
expect(removeSpy).not.toHaveBeenCalled();
|
|
134
|
-
expect(initSpy).not.toHaveBeenCalled();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* @target initWithRetrial should call init job once
|
|
139
|
-
* @dependencies
|
|
140
|
-
* - database
|
|
141
|
-
* @scenario
|
|
142
|
-
* - mock extractor
|
|
143
|
-
* - mock `removeAllData` in database actions
|
|
144
|
-
* - mock init job
|
|
145
|
-
* - run test (call `initWithRetrial`)
|
|
146
|
-
* @expected
|
|
147
|
-
* - to remove database old data once
|
|
148
|
-
* - call init job once
|
|
149
|
-
*/
|
|
150
|
-
it('should call init job once', async () => {
|
|
151
|
-
const extractor = new MockedInitializableErgoExtractor(
|
|
152
|
-
ErgoNetworkType.Node,
|
|
153
|
-
'node_url',
|
|
154
|
-
'address',
|
|
155
|
-
);
|
|
156
|
-
const removeSpy = vitest.fn();
|
|
157
|
-
extractor['actions'] = {
|
|
158
|
-
removeAllData: removeSpy,
|
|
159
|
-
} as unknown as AbstractInitializableErgoExtractorAction<
|
|
160
|
-
AbstractBoxData,
|
|
161
|
-
AbstractErgoExtractorEntity
|
|
162
|
-
>;
|
|
163
|
-
const initSpy = vitest.fn();
|
|
164
|
-
await extractor['initWithRetrial'](initSpy);
|
|
165
|
-
expect(removeSpy).toHaveBeenCalledOnce();
|
|
166
|
-
expect(initSpy).toHaveBeenCalledOnce();
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* @target initWithRetrial should call init job RETRIAL_COUNT number of times
|
|
171
|
-
* @dependencies
|
|
172
|
-
* - database
|
|
173
|
-
* @scenario
|
|
174
|
-
* - mock extractor
|
|
175
|
-
* - mock `removeAllData` in database actions
|
|
176
|
-
* - mock init job to throw error
|
|
177
|
-
* - run test (call `initWithRetrial`)
|
|
178
|
-
* @expected
|
|
179
|
-
* - to remove database old data once
|
|
180
|
-
* - call init job RETRIAL_COUNT number of times
|
|
181
|
-
* - to throw error after trials
|
|
182
|
-
*/
|
|
183
|
-
it('should call init job RETRIAL_COUNT number of times', async () => {
|
|
184
|
-
const extractor = new MockedInitializableErgoExtractor(
|
|
185
|
-
ErgoNetworkType.Node,
|
|
186
|
-
'node_url',
|
|
187
|
-
'address',
|
|
188
|
-
);
|
|
189
|
-
const removeSpy = vitest.fn();
|
|
190
|
-
extractor['actions'] = {
|
|
191
|
-
removeAllData: removeSpy,
|
|
192
|
-
} as unknown as AbstractInitializableErgoExtractorAction<
|
|
193
|
-
AbstractBoxData,
|
|
194
|
-
AbstractErgoExtractorEntity
|
|
195
|
-
>;
|
|
196
|
-
const initSpy = vitest.fn().mockRejectedValue(0);
|
|
197
|
-
await expect(
|
|
198
|
-
async () => await extractor['initWithRetrial'](initSpy),
|
|
199
|
-
).rejects.toThrowError();
|
|
200
|
-
expect(removeSpy).toHaveBeenCalledOnce();
|
|
201
|
-
expect(initSpy).toHaveBeenCalledTimes(RETRIAL_COUNT);
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
describe('initializeWithNode', () => {
|
|
206
|
-
/**
|
|
207
|
-
* @target initializeWithNode should process all transactions bellow the init height twice
|
|
208
|
-
* @dependencies
|
|
209
|
-
* - node network
|
|
210
|
-
* @scenario
|
|
211
|
-
* - mock extractor
|
|
212
|
-
* - mock `getAddressTransactionsWithOffsetLimit` in node network
|
|
213
|
-
* - mock `initWithRetrial` to run the job once
|
|
214
|
-
* - mock `getTotalTxCount` to return 3
|
|
215
|
-
* - run test (call `initializeWithNode`)
|
|
216
|
-
* @expected
|
|
217
|
-
* - to filter the transactions and process the txs bellow the init height
|
|
218
|
-
* - to process all filtered transactions twice
|
|
219
|
-
*/
|
|
220
|
-
it('should process all transactions bellow the init height twice', async () => {
|
|
221
|
-
const extractor = new MockedInitializableErgoExtractor(
|
|
222
|
-
ErgoNetworkType.Node,
|
|
223
|
-
'node_url',
|
|
224
|
-
'address',
|
|
225
|
-
);
|
|
226
|
-
(
|
|
227
|
-
extractor['network'] as NodeNetwork
|
|
228
|
-
).getAddressTransactionsWithOffsetLimit = vitest.fn().mockResolvedValue({
|
|
229
|
-
items: transactionBatch,
|
|
230
|
-
total: 3,
|
|
231
|
-
});
|
|
232
|
-
extractor['initWithRetrial'] = async (job: () => Promise<void>) => job();
|
|
233
|
-
extractor['getTotalTxCount'] = async () => 3;
|
|
234
|
-
const processSpy = vitest.fn();
|
|
235
|
-
extractor['processTransactionBatch'] = processSpy;
|
|
236
|
-
await extractor['initializeWithNode']({ hash: 'hash', height: 1320698 });
|
|
237
|
-
expect(processSpy).toBeCalledTimes(2);
|
|
238
|
-
expect(processSpy).toBeCalledWith([transactionBatch[2]]);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* @target initializeWithNode should throw error when total transaction count changes
|
|
243
|
-
* @dependencies
|
|
244
|
-
* - node network
|
|
245
|
-
* @scenario
|
|
246
|
-
* - mock extractor
|
|
247
|
-
* - mock `getAddressTransactionsWithOffsetLimit` in node network
|
|
248
|
-
* - mock `initWithRetrial` to run the job once
|
|
249
|
-
* - mock `getTotalTxCount` to return 3 then 4
|
|
250
|
-
* - run test (call `initializeWithNode`)
|
|
251
|
-
* @expected
|
|
252
|
-
* - to throw error when the number of transactions change during initialization
|
|
253
|
-
*/
|
|
254
|
-
it('should throw error when total transaction count changes', async () => {
|
|
255
|
-
const extractor = new MockedInitializableErgoExtractor(
|
|
256
|
-
ErgoNetworkType.Node,
|
|
257
|
-
'node_url',
|
|
258
|
-
'address',
|
|
259
|
-
);
|
|
260
|
-
(
|
|
261
|
-
extractor['network'] as NodeNetwork
|
|
262
|
-
).getAddressTransactionsWithOffsetLimit = vitest.fn().mockResolvedValue({
|
|
263
|
-
items: transactionBatch,
|
|
264
|
-
total: 3,
|
|
265
|
-
});
|
|
266
|
-
extractor['initWithRetrial'] = async (job: () => Promise<void>) => job();
|
|
267
|
-
extractor['getTotalTxCount'] = vitest
|
|
268
|
-
.fn()
|
|
269
|
-
.mockResolvedValueOnce(3)
|
|
270
|
-
.mockResolvedValue(4);
|
|
271
|
-
extractor['processTransactionBatch'] = vitest.fn();
|
|
272
|
-
expect(() =>
|
|
273
|
-
extractor['initializeWithNode']({ hash: 'hash', height: 1320698 }),
|
|
274
|
-
).rejects.toThrowError();
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
describe('initializeWithExplorer', () => {
|
|
279
|
-
/**
|
|
280
|
-
* @target initializeWithExplorer should limit the height and process
|
|
281
|
-
* transactions when they are less than the API_LIMIT
|
|
282
|
-
* @dependencies
|
|
283
|
-
* - explorer network
|
|
284
|
-
* @scenario
|
|
285
|
-
* - mock extractor
|
|
286
|
-
* - mock `initWithRetrial` to run the job once
|
|
287
|
-
* - mock `getAddressTransactionsWithHeight` in explorer network
|
|
288
|
-
* return API_LIMIT transactions in first call (to limit the height range)
|
|
289
|
-
* return 0 transactions in second call (to pass a range without process)
|
|
290
|
-
* return transactionBatch in last call (to process the transactions when they are less than API_LIMIT)
|
|
291
|
-
* - run test (call `initializeWithExplorer`)
|
|
292
|
-
* @expected
|
|
293
|
-
* - to limit the height when the transaction count is equal to API_LIMIT
|
|
294
|
-
* - to cover all height ranges
|
|
295
|
-
* - to process transactions when they are less than API_LIMIT
|
|
296
|
-
*/
|
|
297
|
-
it(`should limit the height and process transactions when they are less than
|
|
298
|
-
the API_LIMIT`, async () => {
|
|
299
|
-
const extractor = new MockedInitializableErgoExtractor(
|
|
300
|
-
ErgoNetworkType.Explorer,
|
|
301
|
-
'explorer_url',
|
|
302
|
-
'address',
|
|
303
|
-
);
|
|
304
|
-
extractor['initWithRetrial'] = async (job: () => Promise<void>) => job();
|
|
305
|
-
const addressTxSpy = vitest
|
|
306
|
-
.fn()
|
|
307
|
-
.mockResolvedValueOnce(new Array(100).fill(transactionBatch[0]))
|
|
308
|
-
.mockResolvedValueOnce([])
|
|
309
|
-
.mockResolvedValueOnce(transactionBatch);
|
|
310
|
-
(
|
|
311
|
-
extractor['network'] as ExplorerNetwork
|
|
312
|
-
).getAddressTransactionsWithHeight = addressTxSpy;
|
|
313
|
-
const processSpy = vitest.fn();
|
|
314
|
-
extractor['processTransactionBatch'] = processSpy;
|
|
315
|
-
await extractor['initializeWithExplorer']({
|
|
316
|
-
hash: 'hash',
|
|
317
|
-
height: 1320800,
|
|
318
|
-
});
|
|
319
|
-
expect(addressTxSpy).toHaveBeenCalledWith('address', 0, 1320800);
|
|
320
|
-
expect(addressTxSpy).toHaveBeenCalledWith('address', 0, 660400);
|
|
321
|
-
expect(addressTxSpy).toHaveBeenLastCalledWith('address', 660401, 1320800);
|
|
322
|
-
expect(processSpy).toHaveBeenCalledTimes(1);
|
|
323
|
-
expect(processSpy).toHaveBeenCalledWith(transactionBatch);
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* @target initializeWithExplorer should process all block transactions when
|
|
328
|
-
* the number of transactions in the block is more than API_LIMIT
|
|
329
|
-
* @dependencies
|
|
330
|
-
* - explorer network
|
|
331
|
-
* @scenario
|
|
332
|
-
* - mock extractor
|
|
333
|
-
* - mock `initWithRetrial` to run the job once
|
|
334
|
-
* - mock `getAddressTransactionsWithHeight` to return 100 transactions in one block
|
|
335
|
-
* - spy all other functions to check the calls
|
|
336
|
-
* - run test (call `initializeWithExplorer`)
|
|
337
|
-
* @expected
|
|
338
|
-
* - to process all transactions in block 1320000
|
|
339
|
-
* - not to stuck at a large block and complete the process
|
|
340
|
-
*/
|
|
341
|
-
it(`should process all block transactions when the number of transactions in
|
|
342
|
-
the block is more than API_LIMIT`, async () => {
|
|
343
|
-
// mock extractor
|
|
344
|
-
const extractor = new MockedInitializableErgoExtractor(
|
|
345
|
-
ErgoNetworkType.Explorer,
|
|
346
|
-
'explorer_url',
|
|
347
|
-
'address',
|
|
348
|
-
);
|
|
349
|
-
// mock `initWithRetrial` to run the job once
|
|
350
|
-
extractor['initWithRetrial'] = async (job: () => Promise<void>) => job();
|
|
351
|
-
// mock `getAddressTransactionsWithHeight` to return 100 transactions in one block
|
|
352
|
-
const exNetwork = extractor['network'] as ExplorerNetwork;
|
|
353
|
-
const addressTxSpy = vitest
|
|
354
|
-
.fn()
|
|
355
|
-
.mockImplementation(
|
|
356
|
-
(address: string, fromHeight: number, toHeight: number) => {
|
|
357
|
-
if (fromHeight <= 1320000 && toHeight >= 1320000)
|
|
358
|
-
return new Array(100).fill(transactionBatch[0]);
|
|
359
|
-
return [];
|
|
360
|
-
},
|
|
361
|
-
);
|
|
362
|
-
exNetwork.getAddressTransactionsWithHeight = addressTxSpy;
|
|
363
|
-
// spy all other functions to check the calls
|
|
364
|
-
const blockIdSpy = vi.fn().mockResolvedValue('blockId');
|
|
365
|
-
const blockTxsSpy = vi.fn().mockResolvedValue([]);
|
|
366
|
-
exNetwork.getBlockIdAtHeight = blockIdSpy;
|
|
367
|
-
exNetwork.getBlockTxs = blockTxsSpy;
|
|
368
|
-
const processSpy = vitest.fn();
|
|
369
|
-
const processBatchSpy = vitest.fn();
|
|
370
|
-
extractor.processTransactions = processSpy;
|
|
371
|
-
extractor['processTransactionBatch'] = processBatchSpy;
|
|
372
|
-
// run test (call `initializeWithExplorer`)
|
|
373
|
-
await extractor['initializeWithExplorer']({
|
|
374
|
-
hash: 'hash',
|
|
375
|
-
height: 1320800,
|
|
376
|
-
});
|
|
377
|
-
expect(blockIdSpy).toHaveBeenCalledWith(1320000);
|
|
378
|
-
expect(blockTxsSpy).toHaveBeenCalledWith('blockId');
|
|
379
|
-
expect(processSpy).toHaveBeenCalledWith([], {
|
|
380
|
-
hash: 'blockId',
|
|
381
|
-
height: 1320000,
|
|
382
|
-
});
|
|
383
|
-
expect(processBatchSpy).not.toBeCalled();
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
});
|