2018-10-23 20:56:54 -07:00
|
|
|
// @flow
|
|
|
|
|
2018-10-25 10:41:18 -07:00
|
|
|
import fs from 'mz/fs';
|
|
|
|
|
2018-10-23 20:56:54 -07:00
|
|
|
import {
|
|
|
|
Connection,
|
|
|
|
BpfLoader,
|
|
|
|
Transaction,
|
|
|
|
sendAndConfirmTransaction,
|
|
|
|
} 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-23 20:56: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-23 20:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
test('load BPF program', async () => {
|
|
|
|
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);
|
2018-12-05 10:45:38 -08:00
|
|
|
const data = await fs.readFile('test/fixtures/noop/noop.so');
|
2018-10-25 10:41:18 -07:00
|
|
|
const programId = await BpfLoader.load(connection, from, data);
|
2018-10-23 20:56:54 -07:00
|
|
|
const transaction = new Transaction().add({
|
|
|
|
keys: [from.publicKey],
|
|
|
|
programId,
|
|
|
|
});
|
2018-11-18 08:48:14 -08:00
|
|
|
await sendAndConfirmTransaction(connection, transaction, from);
|
2018-10-23 20:56:54 -07:00
|
|
|
});
|