test.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import * as anchor from "@project-serum/anchor";
  2. import { Hand } from "../target/types/hand";
  3. import { Lever } from "../target/types/lever";
  4. describe("hello-solana", () => {
  5. const provider = anchor.AnchorProvider.env();
  6. anchor.setProvider(provider);
  7. const hand = anchor.workspace.Hand as anchor.Program<Hand>;
  8. const lever = anchor.workspace.Lever as anchor.Program<Lever>;
  9. const powerAccount = anchor.web3.Keypair.generate();
  10. it("Initialize the lever!", async () => {
  11. await lever.methods.initialize()
  12. .accounts({
  13. power: powerAccount.publicKey,
  14. user: provider.wallet.publicKey,
  15. systemProgram: anchor.web3.SystemProgram.programId,
  16. })
  17. .signers([powerAccount])
  18. .rpc();
  19. });
  20. it("Pull the lever!", async () => {
  21. await hand.methods.pullLever("Chris")
  22. .accounts({
  23. power: powerAccount.publicKey,
  24. leverProgram: lever.programId,
  25. })
  26. .rpc();
  27. });
  28. it("Pull it again!", async () => {
  29. await hand.methods.pullLever("Ashley")
  30. .accounts({
  31. power: powerAccount.publicKey,
  32. leverProgram: lever.programId,
  33. })
  34. .rpc();
  35. });
  36. });