test.ts 765 B

1234567891011121314151617181920212223242526
  1. import * as anchor from "@project-serum/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.CreateSystemAccount as anchor.Program<CreateSystemAccount>;
  8. it("Create the account", async () => {
  9. const newKeypair = anchor.web3.Keypair.generate();
  10. await program.methods.createSystemAccount()
  11. .accounts({
  12. payer: wallet.publicKey,
  13. newAccount: newKeypair.publicKey,
  14. systemProgram: anchor.web3.SystemProgram.programId
  15. })
  16. .signers([wallet.payer, newKeypair])
  17. .rpc();
  18. });
  19. });