declare-id.ts 688 B

123456789101112131415161718192021
  1. import * as anchor from "@coral-xyz/anchor";
  2. import { AnchorError, Program } from "@coral-xyz/anchor";
  3. import splToken from "@solana/spl-token";
  4. import { DeclareId } from "../target/types/declare_id";
  5. import { assert } from "chai";
  6. describe("declare_id", () => {
  7. anchor.setProvider(anchor.AnchorProvider.local());
  8. const program = anchor.workspace.DeclareId as Program<DeclareId>;
  9. it("throws error!", async () => {
  10. try {
  11. await program.methods.initialize().rpc();
  12. assert.ok(false);
  13. } catch (_err) {
  14. assert.isTrue(_err instanceof AnchorError);
  15. const err: AnchorError = _err;
  16. assert.strictEqual(err.error.errorCode.number, 4100);
  17. }
  18. });
  19. });