test.ts 780 B

123456789101112131415161718192021222324
  1. import * as anchor from "@coral-xyz/anchor";
  2. import { CreateSystemAccount } from "../target/types/create_system_account";
  3. describe("Create a system account", () => {
  4. const provider = anchor.AnchorProvider.env();
  5. anchor.setProvider(provider);
  6. const wallet = provider.wallet as anchor.Wallet;
  7. const program = anchor.workspace
  8. .CreateSystemAccount as anchor.Program<CreateSystemAccount>;
  9. it("Create the account", async () => {
  10. const newKeypair = anchor.web3.Keypair.generate();
  11. await program.methods
  12. .createSystemAccount()
  13. .accounts({
  14. payer: wallet.publicKey,
  15. newAccount: newKeypair.publicKey,
  16. systemProgram: anchor.web3.SystemProgram.programId,
  17. })
  18. .signers([wallet.payer, newKeypair])
  19. .rpc();
  20. });
  21. });