test: add confirmation retries when testing live

This commit is contained in:
Michael Vines 2018-10-22 22:14:59 -07:00
parent 70d22476cf
commit bc097ec04b
1 changed files with 12 additions and 1 deletions

View File

@ -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
@ -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,