feat: add unstable API for dynamic program loading
This commit is contained in:
@ -1,6 +1,15 @@
|
||||
// @flow
|
||||
|
||||
import {Account, SystemProgram, BudgetProgram} from '../src';
|
||||
import {
|
||||
Account,
|
||||
BudgetProgram,
|
||||
Connection,
|
||||
SystemProgram,
|
||||
Transaction,
|
||||
} from '../src';
|
||||
import {mockRpcEnabled} from './__mocks__/node-fetch';
|
||||
import {url} from './url';
|
||||
import {newAccountWithTokens} from './new-account-with-tokens';
|
||||
|
||||
test('createAccount', () => {
|
||||
const from = new Account();
|
||||
@ -52,4 +61,33 @@ test('assign', () => {
|
||||
// TODO: Validate transaction contents more
|
||||
});
|
||||
|
||||
test('unstable - load', async () => {
|
||||
if (mockRpcEnabled) {
|
||||
console.log('non-live test skipped');
|
||||
return;
|
||||
}
|
||||
|
||||
const connection = new Connection(url);
|
||||
const from = await newAccountWithTokens(connection);
|
||||
const noopProgramId = (new Account()).publicKey;
|
||||
|
||||
const loadTransaction = SystemProgram.load(
|
||||
from.publicKey,
|
||||
noopProgramId,
|
||||
'noop',
|
||||
);
|
||||
|
||||
let signature = await connection.sendTransaction(from, loadTransaction);
|
||||
expect(connection.confirmTransaction(signature)).resolves.toBe(true);
|
||||
|
||||
const noopTransaction = new Transaction({
|
||||
fee: 0,
|
||||
keys: [from.publicKey],
|
||||
programId: noopProgramId,
|
||||
});
|
||||
signature = await connection.sendTransaction(from, noopTransaction);
|
||||
expect(connection.confirmTransaction(signature)).resolves.toBe(true);
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user