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';
|
2019-03-05 17:52:13 -08:00
|
|
|
import {newAccountWithLamports} from './new-account-with-lamports';
|
2018-10-17 09:35:24 -07:00
|
|
|
|
2018-10-22 16:18:54 -07:00
|
|
|
if (!mockRpcEnabled) {
|
|
|
|
// The default of 5 seconds is too slow for live testing sometimes
|
2018-10-24 08:41:13 -07:00
|
|
|
jest.setTimeout(15000);
|
2018-10-22 16:18:54 -07:00
|
|
|
}
|
|
|
|
|
2018-10-23 20:56:54 -07:00
|
|
|
test('load native program', async () => {
|
2018-10-17 09:35:24 -07:00
|
|
|
if (mockRpcEnabled) {
|
|
|
|
console.log('non-live test skipped');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const connection = new Connection(url);
|
2019-03-05 17:52:13 -08:00
|
|
|
const from = await newAccountWithLamports(connection, 1024);
|
2019-04-23 09:53:26 -07:00
|
|
|
const programId = await NativeLoader.load(
|
|
|
|
connection,
|
|
|
|
from,
|
|
|
|
'solana_noop_program',
|
|
|
|
);
|
2018-10-23 20:56:54 -07:00
|
|
|
const transaction = new Transaction().add({
|
2019-04-10 12:31:50 -07:00
|
|
|
keys: [{pubkey: from.publicKey, isSigner: true}],
|
2018-10-23 20:56:54 -07:00
|
|
|
programId,
|
2018-10-17 09:35:24 -07:00
|
|
|
});
|
2018-10-23 20:56:54 -07:00
|
|
|
|
2018-11-18 08:48:14 -08:00
|
|
|
await sendAndConfirmTransaction(connection, transaction, from);
|
2018-10-17 09:35:24 -07:00
|
|
|
});
|