solang.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import * as anchor from "@coral-xyz/anchor";
  2. import { Program } from "@coral-xyz/anchor";
  3. import { Flipper } from "../target/types/flipper";
  4. describe("flipper", () => {
  5. // Configure the client to use the local cluster.
  6. const provider = anchor.AnchorProvider.env();
  7. anchor.setProvider(provider);
  8. const dataAccount = anchor.web3.Keypair.generate();
  9. const wallet = provider.wallet;
  10. const program = anchor.workspace.Flipper as Program<Flipper>;
  11. it("Is initialized!", async () => {
  12. // Add your test here.
  13. const tx = await program.methods
  14. .new()
  15. .accounts({ dataAccount: dataAccount.publicKey })
  16. .signers([dataAccount])
  17. .rpc();
  18. console.log("Your transaction signature", tx);
  19. const val1 = await program.methods
  20. .get()
  21. .accounts({ dataAccount: dataAccount.publicKey })
  22. .view();
  23. console.log("state", val1);
  24. await program.methods
  25. .flip()
  26. .accounts({ dataAccount: dataAccount.publicKey })
  27. .rpc();
  28. const val2 = await program.methods
  29. .get()
  30. .accounts({ dataAccount: dataAccount.publicKey })
  31. .view();
  32. console.log("state", val2);
  33. });
  34. });