12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import * as anchor from "@project-serum/anchor";
- import { Program } from "@project-serum/anchor";
- import {
- Keypair,
- PublicKey,
- SystemProgram
- } from '@solana/web3.js';
- import { assert } from "chai";
- import { CounterSeahorse } from "../target/types/counter_seahorse";
- describe("counter_seahorse", () => {
- // Configure the client to use the local cluster.
- anchor.setProvider(anchor.AnchorProvider.env());
- const program = anchor.workspace.CounterSeahorse as Program<CounterSeahorse>;
- it("Increment counter", async () => {
- const seed = 69;
- const counter = PublicKey.findProgramAddressSync(
- [Buffer.from([0x45])],
- program.programId
- )[0];
- // Initialize counter
- await program.methods
- .initializeCounter(seed)
- .accounts({
- payer: program.provider.publicKey,
- })
- .rpc();
- // Increment counter
- await program.methods
- .increment()
- .accounts({
- counter
- })
- .rpc();
- const count = (await program.account.counter.fetch(counter)).count.toNumber();
- assert(count === 1, "Expected count to be 1");
- });
- });
|