fix: stabilize tests
This commit is contained in:
@ -497,8 +497,6 @@ test('account change notification', async () => {
|
|||||||
const loader = new Loader(connection, BpfLoader.programId);
|
const loader = new Loader(connection, BpfLoader.programId);
|
||||||
await loader.load(programAccount, [1, 2, 3]);
|
await loader.load(programAccount, [1, 2, 3]);
|
||||||
|
|
||||||
await connection.removeAccountChangeListener(subscriptionId);
|
|
||||||
|
|
||||||
// mockCallback should be called twice
|
// mockCallback should be called twice
|
||||||
//
|
//
|
||||||
// retry a couple times if needed
|
// retry a couple times if needed
|
||||||
@ -515,6 +513,8 @@ test('account change notification', async () => {
|
|||||||
await sleep(500);
|
await sleep(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await connection.removeAccountChangeListener(subscriptionId);
|
||||||
|
|
||||||
// First mockCallback call is due to SystemProgram.createAccount()
|
// First mockCallback call is due to SystemProgram.createAccount()
|
||||||
expect(mockCallback.mock.calls[0][0].tokens).toBe(42);
|
expect(mockCallback.mock.calls[0][0].tokens).toBe(42);
|
||||||
expect(mockCallback.mock.calls[0][0].executable).toBe(false);
|
expect(mockCallback.mock.calls[0][0].executable).toBe(false);
|
||||||
|
@ -6,6 +6,7 @@ import {mockRpc, mockRpcEnabled} from './__mocks__/node-fetch';
|
|||||||
import {url} from './url';
|
import {url} from './url';
|
||||||
import {newAccountWithTokens} from './new-account-with-tokens';
|
import {newAccountWithTokens} from './new-account-with-tokens';
|
||||||
import {mockGetLastId} from './mockrpc/getlastid';
|
import {mockGetLastId} from './mockrpc/getlastid';
|
||||||
|
import {sleep} from '../src/util/sleep';
|
||||||
|
|
||||||
if (!mockRpcEnabled) {
|
if (!mockRpcEnabled) {
|
||||||
// The default of 5 seconds is too slow for live testing sometimes
|
// The default of 5 seconds is too slow for live testing sometimes
|
||||||
@ -546,6 +547,8 @@ test('transfer', async () => {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await sleep(500);
|
||||||
|
|
||||||
const destAccountInfo = await testToken.accountInfo(dest);
|
const destAccountInfo = await testToken.accountInfo(dest);
|
||||||
expect(destAccountInfo.amount.toNumber()).toBe(123);
|
expect(destAccountInfo.amount.toNumber()).toBe(123);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user