@rosen-bridge/abstract-extractor 2.0.3 → 2.1.1

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/abstractExtractor.js +1 -1
  3. package/dist/ergo/AbstractErgoExtractor.js +2 -3
  4. package/dist/ergo/AbstractErgoExtractorAction.d.ts +1 -1
  5. package/dist/ergo/AbstractErgoExtractorAction.d.ts.map +1 -1
  6. package/dist/ergo/AbstractErgoExtractorAction.js +4 -6
  7. package/dist/ergo/AbstractErgoExtractorEntity.d.ts.map +1 -1
  8. package/dist/ergo/AbstractErgoExtractorEntity.js +2 -2
  9. package/dist/ergo/initializable/AbstractInitializable.js +1 -1
  10. package/dist/ergo/initializable/AbstractInitializableAction.d.ts +1 -1
  11. package/dist/ergo/initializable/AbstractInitializableAction.d.ts.map +1 -1
  12. package/dist/ergo/initializable/AbstractInitializableAction.js +1 -1
  13. package/dist/ergo/network/AbstractNetwork.js +1 -1
  14. package/dist/ergo/network/ExplorerNetwork.js +1 -1
  15. package/dist/ergo/network/NodeNetwork.js +1 -1
  16. package/package.json +23 -21
  17. package/.eslintignore +0 -1
  18. package/lib/abstractExtractor.ts +0 -31
  19. package/lib/constants.ts +0 -3
  20. package/lib/ergo/AbstractErgoExtractor.ts +0 -227
  21. package/lib/ergo/AbstractErgoExtractorAction.ts +0 -324
  22. package/lib/ergo/AbstractErgoExtractorEntity.ts +0 -28
  23. package/lib/ergo/index.ts +0 -9
  24. package/lib/ergo/initializable/AbstractInitializable.ts +0 -228
  25. package/lib/ergo/initializable/AbstractInitializableAction.ts +0 -29
  26. package/lib/ergo/initializable/index.ts +0 -2
  27. package/lib/ergo/interfaces.ts +0 -51
  28. package/lib/ergo/network/AbstractNetwork.ts +0 -29
  29. package/lib/ergo/network/ExplorerNetwork.ts +0 -237
  30. package/lib/ergo/network/NodeNetwork.ts +0 -169
  31. package/lib/ergo/utils.ts +0 -15
  32. package/lib/index.ts +0 -3
  33. package/tests/AbstractErgoExtractor.mock.ts +0 -33
  34. package/tests/AbstractErgoExtractor.spec.ts +0 -285
  35. package/tests/AbstractErgoExtractorAction.mock.ts +0 -45
  36. package/tests/AbstractErgoExtractorAction.spec.ts +0 -269
  37. package/tests/initializable/AbstractInitializable.mock.ts +0 -44
  38. package/tests/initializable/AbstractInitializable.spec.ts +0 -387
  39. package/tests/initializable/AbstractInitializableAction.mock.ts +0 -45
  40. package/tests/initializable/AbstractInitializableAction.spec.ts +0 -65
  41. package/tests/initializable/testData.ts +0 -283
  42. package/tests/network/ExplorerNetwork.spec.ts +0 -75
  43. package/tests/network/NodeNetwork.spec.ts +0 -57
  44. package/tests/network/testData.ts +0 -1708
  45. package/tests/testData.ts +0 -140
  46. package/tests/testUtils.ts +0 -22
  47. package/tsconfig.build.json +0 -9
  48. package/tsconfig.build.tsbuildinfo +0 -1
  49. package/tsconfig.json +0 -8
  50. package/vitest.config.ts +0 -17
@@ -1,45 +0,0 @@
1
- import { DataSource } from 'typeorm';
2
- import { pick } from 'lodash-es';
3
- import { BlockInfo } from '@rosen-bridge/scanner-interfaces';
4
-
5
- import {
6
- AbstractErgoExtractorEntity,
7
- AbstractBoxData,
8
- AbstractInitializableErgoExtractorAction,
9
- } from '../../lib';
10
- import { TestEntity } from '../testUtils';
11
-
12
- export class TestInitializableErgoExtractorAction extends AbstractInitializableErgoExtractorAction<
13
- AbstractBoxData,
14
- AbstractErgoExtractorEntity
15
- > {
16
- constructor(dataSource: DataSource) {
17
- super(dataSource, TestEntity);
18
- }
19
-
20
- /**
21
- * create the test database entity from data and block information
22
- */
23
- createEntity = (
24
- boxes: AbstractBoxData[],
25
- block: BlockInfo,
26
- extractor: string
27
- ): Omit<AbstractErgoExtractorEntity, 'id'>[] => {
28
- return boxes.map((box) => ({
29
- boxId: box.boxId,
30
- block: block.hash,
31
- height: block.height,
32
- serialized: box.serialized,
33
- extractor: extractor,
34
- }));
35
- };
36
-
37
- /**
38
- * convert the database entity back to raw data
39
- */
40
- convertEntityToData = (
41
- entities: AbstractErgoExtractorEntity[]
42
- ): AbstractBoxData[] => {
43
- return entities.map((data) => pick(data, ['boxId', 'serialized']));
44
- };
45
- }
@@ -1,65 +0,0 @@
1
- import { DataSource, Repository } from 'typeorm';
2
- import { describe, it, expect, beforeEach } from 'vitest';
3
-
4
- import { TestInitializableErgoExtractorAction } from './AbstractInitializableAction.mock';
5
- import { createDatabase, TestEntity } from '../testUtils';
6
- import { sampleEntities } from '../testData';
7
-
8
- describe('AbstractErgoExtractorAction', () => {
9
- let dataSource: DataSource;
10
- let action: TestInitializableErgoExtractorAction;
11
- let repository: Repository<TestEntity>;
12
- beforeEach(async () => {
13
- dataSource = await createDatabase();
14
- action = new TestInitializableErgoExtractorAction(dataSource);
15
- repository = dataSource.getRepository(TestEntity);
16
- });
17
-
18
- describe('removeAllData', () => {
19
- /**
20
- * @target removeAllData should remove all available data related to this extractor
21
- * @dependencies
22
- * @scenario
23
- * - insert 4 entities related to this extractor
24
- * - run test (call `removeAllData`)
25
- * @expected
26
- * - to have 4 entities before removing
27
- * - to have no remaining entities after remove
28
- */
29
- it(`should remove all available data related to this extractor`, async () => {
30
- await dataSource.getRepository(TestEntity).insert(sampleEntities);
31
- const countBefore = await repository.count();
32
-
33
- await action.removeAllData('extractor');
34
- const countAfter = await repository.count();
35
-
36
- expect(countBefore).toEqual(4);
37
- expect(countAfter).toEqual(0);
38
- });
39
-
40
- /**
41
- * @target removeAllData should not remove any data related to another extractor
42
- * @dependencies
43
- * @scenario
44
- * - insert 4 entities related to another extractor
45
- * - run test (call `removeAllData`)
46
- * @expected
47
- * - to have 4 entities after removing
48
- */
49
- it(`should not remove any data related to another extractor`, async () => {
50
- await dataSource.getRepository(TestEntity).insert(
51
- sampleEntities.map((entity) => ({
52
- ...entity,
53
- extractor: 'extractor-new',
54
- }))
55
- );
56
- const countBefore = await repository.count();
57
-
58
- await action.removeAllData('extractor');
59
- const countAfter = await repository.count();
60
-
61
- expect(countBefore).toEqual(4);
62
- expect(countAfter).toEqual(4);
63
- });
64
- });
65
- });
@@ -1,283 +0,0 @@
1
- export const ergoBoxes = [
2
- {
3
- boxId: '57d8334d8b6095393d9c6e471e25b477caba54adcc9757ea4f24d366fe72cdb3',
4
- transactionId:
5
- '793724eec1c6fa4ec68d93186c6403a071154cfc6e5931038791e447a69e1207',
6
- blockId: '4674c0e9a4f26e24e083c8b5b3bbe0c63cd786c32a317f742be1228281b45b26',
7
- value: 14948300000n,
8
- index: 1,
9
- creationHeight: 1252681,
10
- inclusionHeight: 1252681,
11
- ergoTree:
12
- '0008cd03e5f5f63b27f9cdc47a9a8b799a26e5ee66a1e2a5d41d64640df3e64f4d050c18',
13
- address: '9iD5jMoLjK9azTdigyT8z1QY6qHrA6gVrJamMF8MJ2qt45pJpDc',
14
- assets: [
15
- {
16
- tokenId:
17
- 'e023c5f382b6e96fbd878f6811aac73345489032157ad5affb84aefd4956c297',
18
- index: 0,
19
- amount: 4983552n,
20
- name: 'rsADA',
21
- decimals: 6,
22
- },
23
- ],
24
- additionalRegisters: {},
25
- },
26
- {
27
- boxId: '2708cc15be42eff988c7194c86912d305361c8c12cf9dae2b750dbf5c1519bd0',
28
- transactionId:
29
- 'd18aaa53c20ff5a8989f6b26d2e84c9bd439abb7b61e9e53f48e73a6f311e712',
30
- blockId: '95e73453f5824158e89946bf2efb6f7bf808c6c4b6d380d7f588e770a1de1ad0',
31
- value: 14981300000n,
32
- index: 2,
33
- creationHeight: 1252677,
34
- inclusionHeight: 1252677,
35
- ergoTree:
36
- '0008cd03e5f5f63b27f9cdc47a9a8b799a26e5ee66a1e2a5d41d64640df3e64f4d050c18',
37
- address: '9iD5jMoLjK9azTdigyT8z1QY6qHrA6gVrJamMF8MJ2qt45pJpDc',
38
- assets: [
39
- {
40
- tokenId:
41
- 'e023c5f382b6e96fbd878f6811aac73345489032157ad5affb84aefd4956c297',
42
- index: 0,
43
- amount: 4983552n,
44
- name: 'rsADA',
45
- decimals: 6,
46
- },
47
- ],
48
- additionalRegisters: {},
49
- spentHeight: 1252680,
50
- spentBlockId:
51
- '9239ebca7b3b10701895e491a2213da4e07a37abc413d05434a5fab04993a19d',
52
- spentTransactionId:
53
- 'b08fa920a6907d0e76eb0ad754439f1a26fa112b39f4de489620e4e6241930b7',
54
- spentIndex: 1,
55
- },
56
- ];
57
-
58
- export const extractedData = {
59
- boxId: 'boxId1',
60
- address: 'address1',
61
- serialized: 'serialized1',
62
- blockId: 'blockId1',
63
- height: 98,
64
- };
65
-
66
- export const transactionBatch = [
67
- {
68
- id: 'c0bd3194b04c7d44159d57a532d2d00f6db3c9a1e4aa1a7dc3dee6e8ae3f0f80',
69
- inclusionHeight: 1320705,
70
- blockId: 'b861e2134821fcf1fcdad7e6edd56c4e4495b42b2fd72762a4c79ed1db78b44b',
71
- outputs: [
72
- {
73
- transactionId:
74
- 'c0bd3194b04c7d44159d57a532d2d00f6db3c9a1e4aa1a7dc3dee6e8ae3f0f80',
75
- index: 0,
76
- value: 1000000n,
77
- ergoTree:
78
- '100504000400050004000e20011d3364de07e5a26f0c4eef0852cddb387039a921b7154ef3cab22c6eda887fd803d601b2a5730000d602e4c6a70407d603b2db6501fe730100ea02d1ededededed93e4c672010407720293e4c67201050ec5720391e4c672010605730293c27201c2a793db63087201db6308a7938cb2db63087203730300017304cd7202',
79
- creationHeight: 1320705,
80
- assets: [
81
- {
82
- tokenId:
83
- '8c27dd9d8a35aac1e3167d58858c0a8b4059b277da790552e37eba22df9b9035',
84
- amount: 1n,
85
- },
86
- ],
87
- additionalRegisters: {
88
- R4: '0702c1d434dac8765fc1269af82958d8aa350da53907096b35f7747cc372a7e6e69d',
89
- R5: '0e2056b8b7c2ae45876ec9a79c575d66f6be1ead5498879f08df00b40daa62ae1b94',
90
- R6: '058cee94aa09',
91
- },
92
- boxId:
93
- '0881528fb109938778ec5da029b8e076b3ee8a48c3fbb46eadf020f3caa25800',
94
- },
95
- {
96
- transactionId:
97
- 'c0bd3194b04c7d44159d57a532d2d00f6db3c9a1e4aa1a7dc3dee6e8ae3f0f80',
98
- index: 1,
99
- value: 1500000n,
100
- ergoTree:
101
- '1005040004000e36100204a00b08cd0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ea02d192a39a8cc7a701730073011001020402d19683030193a38cc7b2a57300000193c2b2a57301007473027303830108cdeeac93b1a57304',
102
- creationHeight: 1320705,
103
- assets: [],
104
- additionalRegisters: {},
105
- boxId:
106
- '6c92ec246cc30aa12353e35438f0a130dcd088be3535636b81fd73d131e32ac7',
107
- },
108
- {
109
- transactionId:
110
- 'c0bd3194b04c7d44159d57a532d2d00f6db3c9a1e4aa1a7dc3dee6e8ae3f0f80',
111
- index: 2,
112
- value: 23278478571n,
113
- ergoTree:
114
- '0008cd02c1d434dac8765fc1269af82958d8aa350da53907096b35f7747cc372a7e6e69d',
115
- creationHeight: 1320705,
116
- assets: [],
117
- additionalRegisters: {},
118
- boxId:
119
- '70b5811a0678f7e634dcff9b862467f2b5620f2a4e4ffd5a6a37f331b9194c68',
120
- },
121
- ],
122
- inputs: [
123
- {
124
- boxId:
125
- 'be50cf8b4bf156e082c1f48199811cec081b123834422ac64e9659b36bc029f2',
126
- },
127
- {
128
- boxId:
129
- 'b6db0c5629850b62a58a9c0dae956e1ce14438f5d48ca75c3e55e60df17836cb',
130
- },
131
- ],
132
- dataInputs: [
133
- {
134
- boxId:
135
- '56b8b7c2ae45876ec9a79c575d66f6be1ead5498879f08df00b40daa62ae1b94',
136
- },
137
- ],
138
- },
139
- {
140
- id: '41d16484deab78069aaa2fa7bce4797f55768bde4687d4357ac502e086d26d08',
141
- inclusionHeight: 1320705,
142
- blockId: 'b861e2134821fcf1fcdad7e6edd56c4e4495b42b2fd72762a4c79ed1db78b44b',
143
- outputs: [
144
- {
145
- transactionId:
146
- '41d16484deab78069aaa2fa7bce4797f55768bde4687d4357ac502e086d26d08',
147
- index: 0,
148
- value: 1000000n,
149
- ergoTree:
150
- '100504000400050004000e20011d3364de07e5a26f0c4eef0852cddb387039a921b7154ef3cab22c6eda887fd803d601b2a5730000d602e4c6a70407d603b2db6501fe730100ea02d1ededededed93e4c672010407720293e4c67201050ec5720391e4c672010605730293c27201c2a793db63087201db6308a7938cb2db63087203730300017304cd7202',
151
- creationHeight: 1320701,
152
- assets: [
153
- {
154
- tokenId:
155
- '8c27dd9d8a35aac1e3167d58858c0a8b4059b277da790552e37eba22df9b9035',
156
- amount: 1n,
157
- },
158
- ],
159
- additionalRegisters: {
160
- R4: '0702c1d434dac8765fc1269af82958d8aa350da53907096b35f7747cc372a7e6e69d',
161
- R5: '0e2056b8b7c2ae45876ec9a79c575d66f6be1ead5498879f08df00b40daa62ae1b94',
162
- R6: '058cee94aa09',
163
- },
164
- boxId:
165
- 'be50cf8b4bf156e082c1f48199811cec081b123834422ac64e9659b36bc029f2',
166
- },
167
- {
168
- transactionId:
169
- '41d16484deab78069aaa2fa7bce4797f55768bde4687d4357ac502e086d26d08',
170
- index: 1,
171
- value: 1500000n,
172
- ergoTree:
173
- '1005040004000e36100204a00b08cd0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ea02d192a39a8cc7a701730073011001020402d19683030193a38cc7b2a57300000193c2b2a57301007473027303830108cdeeac93b1a57304',
174
- creationHeight: 1320701,
175
- assets: [],
176
- additionalRegisters: {},
177
- boxId:
178
- '9df85ba11e07c6fa7bd39f74731bb03538d36dedb5874f313bf6b32a3adddaa3',
179
- },
180
- {
181
- transactionId:
182
- '41d16484deab78069aaa2fa7bce4797f55768bde4687d4357ac502e086d26d08',
183
- index: 2,
184
- value: 3730116410n,
185
- ergoTree:
186
- '0008cd02c1d434dac8765fc1269af82958d8aa350da53907096b35f7747cc372a7e6e69d',
187
- creationHeight: 1320701,
188
- assets: [],
189
- additionalRegisters: {},
190
- boxId:
191
- '0cf4f4a3638464612dc710ff0c9613e10e23e090bf8ad21f830277fa0a4f4c1b',
192
- },
193
- ],
194
- inputs: [
195
- {
196
- boxId:
197
- '3715c953269a829641db0022f3a7ab67917911491c6f363ab863d7ad42785437',
198
- },
199
- {
200
- boxId:
201
- '88105776d682d645de57a1aa1569665ebfc57138ca9072c7472274dc0e1f6746',
202
- },
203
- ],
204
- dataInputs: [
205
- {
206
- boxId:
207
- '56b8b7c2ae45876ec9a79c575d66f6be1ead5498879f08df00b40daa62ae1b94',
208
- },
209
- ],
210
- },
211
- {
212
- id: '0fbd5c82dc0a4316a40a9d1de4f0949c503b39c5fe0e3e113e26d43558285ef7',
213
- inclusionHeight: 1320698,
214
- blockId: '92eaff11a4a1c29b8654473258f9d837e9ce99fc0a8a4f27c484d5871afcde64',
215
- outputs: [
216
- {
217
- transactionId:
218
- '0fbd5c82dc0a4316a40a9d1de4f0949c503b39c5fe0e3e113e26d43558285ef7',
219
- index: 0,
220
- value: 1000000n,
221
- ergoTree:
222
- '100504000400050004000e20011d3364de07e5a26f0c4eef0852cddb387039a921b7154ef3cab22c6eda887fd803d601b2a5730000d602e4c6a70407d603b2db6501fe730100ea02d1ededededed93e4c672010407720293e4c67201050ec5720391e4c672010605730293c27201c2a793db63087201db6308a7938cb2db63087203730300017304cd7202',
223
- creationHeight: 1320696,
224
- assets: [
225
- {
226
- tokenId:
227
- '8c27dd9d8a35aac1e3167d58858c0a8b4059b277da790552e37eba22df9b9035',
228
- amount: 1n,
229
- },
230
- ],
231
- additionalRegisters: {
232
- R4: '0702c1d434dac8765fc1269af82958d8aa350da53907096b35f7747cc372a7e6e69d',
233
- R5: '0e2056b8b7c2ae45876ec9a79c575d66f6be1ead5498879f08df00b40daa62ae1b94',
234
- R6: '058cee94aa09',
235
- },
236
- boxId:
237
- '3715c953269a829641db0022f3a7ab67917911491c6f363ab863d7ad42785437',
238
- },
239
- {
240
- transactionId:
241
- '0fbd5c82dc0a4316a40a9d1de4f0949c503b39c5fe0e3e113e26d43558285ef7',
242
- index: 1,
243
- value: 1500000n,
244
- ergoTree:
245
- '1005040004000e36100204a00b08cd0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ea02d192a39a8cc7a701730073011001020402d19683030193a38cc7b2a57300000193c2b2a57301007473027303830108cdeeac93b1a57304',
246
- creationHeight: 1320696,
247
- assets: [],
248
- additionalRegisters: {},
249
- boxId:
250
- 'ef31d4cea3cd9fa960d254d07742d759cf4076690d0fd1ffe442912bc8a0fb18',
251
- },
252
- {
253
- transactionId:
254
- '0fbd5c82dc0a4316a40a9d1de4f0949c503b39c5fe0e3e113e26d43558285ef7',
255
- index: 2,
256
- value: 23279978571n,
257
- ergoTree:
258
- '0008cd02c1d434dac8765fc1269af82958d8aa350da53907096b35f7747cc372a7e6e69d',
259
- creationHeight: 1320696,
260
- assets: [],
261
- additionalRegisters: {},
262
- boxId:
263
- 'b6db0c5629850b62a58a9c0dae956e1ce14438f5d48ca75c3e55e60df17836cb',
264
- },
265
- ],
266
- inputs: [
267
- {
268
- boxId:
269
- '55cec880dcdce1c914de20a1fcaf949a76f1e5e5b2d474e351c9d11f2a00472c',
270
- },
271
- {
272
- boxId:
273
- '111d487d65d5ad5f715a6e0ff1bbd588596f73f7d8394eb7f50f1d278e482b88',
274
- },
275
- ],
276
- dataInputs: [
277
- {
278
- boxId:
279
- '56b8b7c2ae45876ec9a79c575d66f6be1ead5498879f08df00b40daa62ae1b94',
280
- },
281
- ],
282
- },
283
- ];
@@ -1,75 +0,0 @@
1
- import { describe, expect, it, vitest } from 'vitest';
2
- import ergoExplorerClientFactory from '@rosen-clients/ergo-explorer';
3
- import { omit } from 'lodash-es';
4
-
5
- import { ExplorerNetwork } from '../../lib';
6
- import {
7
- convertedBox,
8
- explorerBox,
9
- explorerTxInfo,
10
- convertedTx,
11
- explorerTx,
12
- explorerBlockTx,
13
- } from './testData';
14
-
15
- vitest.mock('@rosen-clients/ergo-explorer');
16
-
17
- describe('ExplorerNetwork', () => {
18
- describe('convertBox', () => {
19
- /**
20
- * @target covertBox should properly convert explorer api box to ergo box
21
- * @dependencies
22
- * @scenario
23
- * - mock getApiV1TransactionsP1 to return spending transaction
24
- * - run test (call `covertBox`)
25
- * @expected
26
- * - to convert box properly
27
- */
28
- it('should properly convert explorer api box to ergo box', async () => {
29
- vitest.mocked(ergoExplorerClientFactory).mockReturnValue({
30
- v1: {
31
- getApiV1TransactionsP1: async () => explorerTxInfo,
32
- },
33
- } as unknown as ReturnType<typeof ergoExplorerClientFactory>);
34
- const explorerNetwork = new ExplorerNetwork('explorer_url');
35
- const ergoBox = await explorerNetwork['convertBox'](explorerBox);
36
- expect(ergoBox).toEqual(convertedBox);
37
- });
38
- });
39
-
40
- describe('convertTransaction', () => {
41
- /**
42
- * @target convertTransaction should properly convert explorer api tx to
43
- * extractor transaction
44
- * @dependencies
45
- * @scenario
46
- * - run test (call `convertTransaction`)
47
- * @expected
48
- * - to convert tx properly
49
- */
50
- it('should properly convert explorer api tx to extractor transaction', async () => {
51
- const explorerNetwork = new ExplorerNetwork('explorer_url');
52
- const tx = await explorerNetwork['convertTransaction'](explorerTx);
53
- expect(tx).toEqual(convertedTx);
54
- });
55
- });
56
-
57
- describe('convertBlockTransaction', () => {
58
- /**
59
- * @target convertBlockTransaction should properly convert explorer api tx to
60
- * transaction type
61
- * @dependencies
62
- * @scenario
63
- * - run test (call `convertBlockTransaction`)
64
- * @expected
65
- * - to convert tx properly
66
- */
67
- it('should properly convert explorer api tx to transaction type', async () => {
68
- const explorerNetwork = new ExplorerNetwork('explorer_url');
69
- const tx = await explorerNetwork['convertBlockTransaction'](
70
- explorerBlockTx
71
- );
72
- expect(tx).toEqual(omit(convertedTx, ['blockId', 'inclusionHeight']));
73
- });
74
- });
75
- });
@@ -1,57 +0,0 @@
1
- import { describe, expect, it, vitest } from 'vitest';
2
- import ergoNodeClientFactory from '@rosen-clients/ergo-node';
3
-
4
- import { NodeNetwork } from '../../lib';
5
- import {
6
- convertedBox,
7
- nodeBox,
8
- nodeSpendingTxInfo,
9
- nodeCreationTxInfo,
10
- nodeTx,
11
- convertedTx,
12
- } from './testData';
13
-
14
- vitest.mock('@rosen-clients/ergo-node');
15
-
16
- describe('NodeNetwork', () => {
17
- describe('convertBox', () => {
18
- /**
19
- * @target covertBox should properly convert node api box to ergo box
20
- * @dependencies
21
- * @scenario
22
- * - mock getTxById to return creation and spending transaction
23
- * - run test (call `covertBox`)
24
- * @expected
25
- * - to convert box properly
26
- */
27
- it('should properly convert node api box to ergo box', async () => {
28
- vitest.mocked(ergoNodeClientFactory).mockReturnValue({
29
- getTxById: async (txId: string) => {
30
- if (txId == nodeSpendingTxInfo.id) return nodeSpendingTxInfo;
31
- else return nodeCreationTxInfo;
32
- },
33
- } as unknown as ReturnType<typeof ergoNodeClientFactory>);
34
- const nodeNetwork = new NodeNetwork('node_url');
35
- const ergoBox = await nodeNetwork['convertBox'](nodeBox);
36
- expect(ergoBox).toEqual(convertedBox);
37
- });
38
- });
39
-
40
- describe('convertTransaction', () => {
41
- /**
42
- * @target convertTransaction should properly convert node api tx to
43
- * extractor transaction
44
- * @dependencies
45
- * @scenario
46
- * - mock getTxById to return creation and spending transaction
47
- * - run test (call `convertTransaction`)
48
- * @expected
49
- * - to convert tx properly
50
- */
51
- it('should properly convert node api tx to extractor transaction', async () => {
52
- const nodeNetwork = new NodeNetwork('node_url');
53
- const tx = await nodeNetwork['convertTransaction'](nodeTx);
54
- expect(tx).toEqual(convertedTx);
55
- });
56
- });
57
- });