|
1 | | -import { Torii, type ToriiRequirementsForApiHttp, setCrypto } from '@iroha2/client' |
2 | | -import { FREE_HEAP } from '@iroha2/crypto-core' |
3 | | -import { crypto } from '@iroha2/crypto-target-node' |
4 | | -import { type RustResult, Logger as ScaleLogger, datamodel, sugar, variant } from '@iroha2/data-model' |
5 | | -import * as TestPeer from '@iroha2/test-peer' |
| 1 | +import { Torii } from '@iroha2/client' |
| 2 | +import { type RustResult, datamodel, sugar, variant } from '@iroha2/data-model' |
6 | 3 | import { CLIENT_CONFIG } from '@iroha2/test-configuration' |
7 | 4 | import { Seq } from 'immutable' |
8 | | -import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'vitest' |
9 | | -import { delay } from '../../util' |
10 | | -import { clientFactory, keyPair } from './test-util' |
| 5 | +import { describe, expect, test } from 'vitest' |
| 6 | +import { clientFactory, setupPeerTestsLifecycle } from './util' |
11 | 7 | import { pipe } from 'fp-ts/function' |
12 | 8 |
|
13 | | -// for debugging convenience |
14 | | -new ScaleLogger().mount() |
15 | | -setCrypto(crypto) |
| 9 | +setupPeerTestsLifecycle() |
16 | 10 |
|
17 | | -let startedPeer: TestPeer.StartPeerReturn | null = null |
18 | | - |
19 | | -async function killStartedPeer() { |
20 | | - await startedPeer?.kill() |
21 | | - startedPeer = null |
22 | | -} |
23 | | - |
24 | | -async function waitForGenesisCommitted(pre: ToriiRequirementsForApiHttp) { |
25 | | - while (true) { |
26 | | - const { blocks } = await Torii.getStatus(pre) |
27 | | - if (blocks >= 1) return |
28 | | - await delay(50) |
29 | | - } |
30 | | -} |
31 | | - |
32 | | -// and now tests... |
33 | | - |
34 | | -beforeAll(async () => { |
35 | | - await TestPeer.clearAll() |
36 | | - await TestPeer.prepareConfiguration() |
37 | | -}) |
38 | | - |
39 | | -beforeEach(async () => { |
40 | | - await TestPeer.clearPeerStorage() |
41 | | - startedPeer = await TestPeer.startPeer() |
42 | | - await waitForGenesisCommitted(clientFactory().pre) |
43 | | -}) |
44 | | - |
45 | | -afterEach(async () => { |
46 | | - await killStartedPeer() |
47 | | -}) |
48 | | - |
49 | | -afterAll(async () => { |
50 | | - keyPair.free() |
51 | | - expect(FREE_HEAP.size).toEqual(0) |
52 | | -}) |
53 | | - |
54 | | -// Actually it is already tested within `@iroha2/test-peer` |
| 11 | +// Actually, it is already tested within `@iroha2/test-peer` |
55 | 12 | test('Peer is healthy', async () => { |
56 | 13 | const { pre } = clientFactory() |
57 | 14 |
|
@@ -209,10 +166,6 @@ test('When querying for not existing domain, returns FindError', async () => { |
209 | 166 | expect(result.as('Err').enum.as('QueryFailed').enum.as('Find').enum.as('AssetDefinition').name).toBe('XOR') |
210 | 167 | }) |
211 | 168 |
|
212 | | -test('Multisignature', async () => { |
213 | | - await import('./multisignature') |
214 | | -}) |
215 | | - |
216 | 169 | describe('Events API', () => { |
217 | 170 | test('transaction-committed event is triggered after AddAsset instruction has been committed', async () => { |
218 | 171 | const { pre, client } = clientFactory() |
|
0 commit comments