Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
test: add confirmation retries when testing live
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed Oct 23, 2018
1 parent f71bc0b commit 71df4de
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/connection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import {mockRpc, mockRpcEnabled} from './__mocks__/node-fetch';
import {mockGetLastId} from './mockrpc/getlastid';
import {url} from './url';
import {sleep} from '../src/util/sleep';

if (!mockRpcEnabled) {
// The default of 5 seconds is too slow for live testing sometimes
Expand Down Expand Up @@ -307,7 +308,17 @@ test('transaction', async () => {
}
]
);
await expect(connection.confirmTransaction(signature)).resolves.toBe(true);

let i = 0;
for (;;) {
if (await connection.confirmTransaction(signature)) {
break;
}

expect(mockRpcEnabled).toBe(false);
expect(++i).toBeLessThan(10);
await sleep(500);
}

mockRpc.push([
url,
Expand Down

0 comments on commit 71df4de

Please sign in to comment.