processing-instructions.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import * as anchor from "@coral-xyz/anchor";
  2. import { Program } from "@coral-xyz/anchor";
  3. import { ProcessingInstructions } from "../target/types/processing_instructions";
  4. describe("processing-instructions", () => {
  5. // Configure the client to use the local cluster.
  6. const provider = anchor.AnchorProvider.env();
  7. anchor.setProvider(provider);
  8. // Generate a new keypair for the data account for the program
  9. const dataAccount = anchor.web3.Keypair.generate();
  10. const wallet = provider.wallet;
  11. const program = anchor.workspace
  12. .ProcessingInstructions as Program<ProcessingInstructions>;
  13. it("Is initialized!", async () => {
  14. // Initialize data account for the program, which is required by Solang
  15. const tx = await program.methods
  16. .new()
  17. .accounts({ dataAccount: dataAccount.publicKey })
  18. .signers([dataAccount])
  19. .rpc();
  20. console.log("Your transaction signature", tx);
  21. });
  22. it("Go to the park!", async () => {
  23. // Call the goToPark instruction on the program, providing the instruction data
  24. await program.methods
  25. .goToPark("Jimmy", 3)
  26. .accounts({ dataAccount: dataAccount.publicKey })
  27. .rpc();
  28. // Call the goToPark instruction on the program, providing the instruction data
  29. await program.methods
  30. .goToPark("Mary", 10)
  31. .accounts({ dataAccount: dataAccount.publicKey })
  32. .rpc();
  33. });
  34. });