Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 8a42e38

Browse files
committed
Use new polling util in integration tests
1 parent 5582a60 commit 8a42e38

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

test/integration/action/action-integration.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { rmdir, poll, isPortOpen } from './test-util';
1+
import { rmdir, isPortOpen } from './test-util';
22
import { Store } from '../../../src/store';
33
import IpcAction from '../../../src/action/ipc';
44
import GrpcAction from '../../../src/action/grpc';
@@ -12,7 +12,7 @@ import ChannelAction from '../../../src/action/channel';
1212
import TransactionAction from '../../../src/action/transaction';
1313
import PaymentAction from '../../../src/action/payment';
1414
import InvoiceAction from '../../../src/action/invoice';
15-
import { nap } from '../../../src/helper';
15+
import { nap, retry } from '../../../src/helper';
1616
import { EventEmitter } from 'events';
1717

1818
const {
@@ -108,7 +108,7 @@ describe('Action Integration Tests', function() {
108108
};
109109
btcdProcess = await startBtcdProcess(btcdArgs);
110110
await nap(NAP_TIME);
111-
await poll(() => isPortOpen(BTCD_PORT));
111+
await retry(() => isPortOpen(BTCD_PORT));
112112
const lndProcess1Promise = startLndProcess({
113113
isDev,
114114
lndSettingsDir: LND_SETTINGS_DIR_1,
@@ -227,12 +227,12 @@ describe('Action Integration Tests', function() {
227227
btcdArgs.miningAddress = store1.walletAddress;
228228
btcdProcess = await startBtcdProcess(btcdArgs);
229229
await nap(NAP_TIME);
230-
await poll(() => isPortOpen(BTCD_PORT));
230+
await retry(() => isPortOpen(BTCD_PORT));
231231
await mineAndSync({ blocks: 400 });
232232
});
233233

234234
it('should get public key node1', async () => {
235-
await info1.getInfo();
235+
await info1.pollInfo();
236236
expect(store1.pubKey, 'to be ok');
237237
});
238238

@@ -266,7 +266,7 @@ describe('Action Integration Tests', function() {
266266
});
267267

268268
it('should get public key node2', async () => {
269-
await info2.getInfo();
269+
await info2.pollInfo();
270270
expect(store2.pubKey, 'to be ok');
271271
});
272272

@@ -443,8 +443,8 @@ describe('Action Integration Tests', function() {
443443

444444
const mineAndSync = async ({ blocks }) => {
445445
await mineBlocks({ blocks, logger });
446-
await info1.getInfo();
447-
await info2.getInfo();
446+
await info1.pollInfo();
447+
await info2.pollInfo();
448448
};
449449

450450
const updateBalances = async () => {

test/integration/action/test-util.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import fs from 'fs';
22
import net from 'net';
3-
import { nap } from '../../../src/helper';
43

54
export const rmdir = path => {
65
if (fs.existsSync(path)) {
@@ -16,17 +15,6 @@ export const rmdir = path => {
1615
}
1716
};
1817

19-
export const poll = async (api, interval = 100, retries = 1000) => {
20-
while (retries--) {
21-
try {
22-
return await api();
23-
} catch (err) {
24-
if (!retries) throw err;
25-
}
26-
await nap(interval);
27-
}
28-
};
29-
3018
export const isPortOpen = async port => {
3119
await new Promise((resolve, reject) => {
3220
const client = new net.Socket();

0 commit comments

Comments
 (0)