basic-4.js 958 B

123456789101112131415161718192021222324252627282930313233343536
  1. const assert = require("assert");
  2. const anchor = require("@project-serum/anchor");
  3. describe("basic-4", () => {
  4. const provider = anchor.Provider.local();
  5. // Configure the client to use the local cluster.
  6. anchor.setProvider(provider);
  7. const program = anchor.workspace.Basic4;
  8. it("Is runs the constructor", async () => {
  9. // #region code
  10. // Initialize the program's state struct.
  11. await program.state.rpc.new({
  12. accounts: {
  13. authority: provider.wallet.publicKey,
  14. },
  15. });
  16. // Fetch the state struct from the network.
  17. const state = await program.state();
  18. // #endregion code
  19. assert.ok(state.count.eq(new anchor.BN(0)));
  20. });
  21. it("Executes a method on the program", async () => {
  22. await program.state.rpc.increment({
  23. accounts: {
  24. authority: provider.wallet.publicKey,
  25. },
  26. });
  27. const state = await program.state();
  28. assert.ok(state.count.eq(new anchor.BN(1)));
  29. });
  30. });