2018-10-17 09:35:24 -07:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import {
|
|
|
|
Connection,
|
|
|
|
NativeLoader,
|
|
|
|
Transaction,
|
2018-10-22 21:32:15 -07:00
|
|
|
sendAndConfirmTransaction,
|
2018-10-17 09:35:24 -07:00
|
|
|
} from '../src';
|
|
|
|
import {mockRpcEnabled} from './__mocks__/node-fetch';
|
|
|
|
import {url} from './url';
|
|
|
|
import {newAccountWithTokens} from './new-account-with-tokens';
|
|
|
|
|
2018-10-22 16:18:54 -07:00
|
|
|
if (!mockRpcEnabled) {
|
|
|
|
// The default of 5 seconds is too slow for live testing sometimes
|
|
|
|
jest.setTimeout(10000);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-18 14:29:57 -07:00
|
|
|
test('load noop program', async () => {
|
2018-10-17 09:35:24 -07:00
|
|
|
if (mockRpcEnabled) {
|
|
|
|
console.log('non-live test skipped');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const connection = new Connection(url);
|
|
|
|
const from = await newAccountWithTokens(connection);
|
|
|
|
|
|
|
|
const noopProgramId = await NativeLoader.load(connection, from, 'noop');
|
|
|
|
const noopTransaction = new Transaction({
|
|
|
|
fee: 0,
|
|
|
|
keys: [from.publicKey],
|
|
|
|
programId: noopProgramId,
|
|
|
|
});
|
2018-10-22 21:32:15 -07:00
|
|
|
await expect(sendAndConfirmTransaction(connection, from, noopTransaction)).resolves.toBeUndefined();
|
2018-10-17 09:35:24 -07:00
|
|
|
});
|
|
|
|
|