seahorse.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import * as anchor from "@coral-xyz/anchor";
  2. import { Program } from "@coral-xyz/anchor";
  3. import { Seahorse } from "../target/types/seahorse";
  4. describe("seahorse", () => {
  5. // Configure the client to use the local cluster.
  6. anchor.setProvider(anchor.AnchorProvider.env());
  7. const program = anchor.workspace.Seahorse as Program<Seahorse>;
  8. const mockAccount = anchor.web3.PublicKey.findProgramAddressSync(
  9. [Buffer.from("mock_account")],
  10. program.programId
  11. );
  12. it("Initialize the Mock account to send our SOL to", async () => {
  13. const tx = await program.methods
  14. .initMockAccount()
  15. .accounts({
  16. mockAccount: mockAccount[0],
  17. signer: program.provider.publicKey,
  18. })
  19. .rpc();
  20. });
  21. it("Send SOL To Mock account", async () => {
  22. const amount = 1;
  23. // Convert to lamport.
  24. const lamports: number = anchor.web3.LAMPORTS_PER_SOL * amount;
  25. const tx = await program.methods
  26. .transferSolWithCpi(new anchor.BN(lamports))
  27. .accounts({
  28. recipient: mockAccount[0],
  29. sender: program.provider.publicKey,
  30. })
  31. .rpc();
  32. console.log("Your transaction signature: ", tx);
  33. });
  34. });