|
@@ -1,6 +1,6 @@
|
|
|
import {
|
|
|
Connection,
|
|
|
- Keypair,
|
|
|
+ Keypair, LAMPORTS_PER_SOL,
|
|
|
sendAndConfirmTransaction,
|
|
|
SystemProgram,
|
|
|
Transaction,
|
|
@@ -21,7 +21,7 @@ describe("Create a system account", async () => {
|
|
|
const payer = createKeypairFromFile(require('os').homedir() + '/.config/solana/id.json');
|
|
|
const program = createKeypairFromFile('./program/target/so/program-keypair.json');
|
|
|
|
|
|
- it("Create the account", async () => {
|
|
|
+ it("Create the account via a cross program invocation", async () => {
|
|
|
|
|
|
const newKeypair = Keypair.generate();
|
|
|
|
|
@@ -41,5 +41,23 @@ describe("Create a system account", async () => {
|
|
|
[payer, newKeypair]
|
|
|
);
|
|
|
});
|
|
|
+
|
|
|
+ it("Create the account via direct call to system program", async () => {
|
|
|
+
|
|
|
+ const newKeypair = Keypair.generate();
|
|
|
+
|
|
|
+ const ix = SystemProgram.createAccount({
|
|
|
+ fromPubkey: payer.publicKey,
|
|
|
+ newAccountPubkey: newKeypair.publicKey,
|
|
|
+ lamports: LAMPORTS_PER_SOL,
|
|
|
+ space: 0,
|
|
|
+ programId: SystemProgram.programId
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ await sendAndConfirmTransaction(connection,
|
|
|
+ new Transaction().add(ix),
|
|
|
+ [payer, newKeypair]);
|
|
|
+ });
|
|
|
});
|
|
|
|