Skip to content

anchor test --skip-deploy issue #3961

@random1106

Description

@random1106

I am following rareskill's 60-day of solana course https://rareskills.io/post/solana-anchor-deploy day 5 to test solana project without deploying it.

However, no matter I run solana test --skip-local-validator or solana test --skip-local-validator --skip-deploy it will fail, unlike what was explained on rareskill.

Here is my lib.rs and day5.ts:

use anchor_lang::prelude::*;

declare_id!("Gp3W5ZxQsdaVpKVoq3QyQtMQZ1TWzJtcJW3RWXkpC2JG");

#[program]
pub mod day5 {
    use super::*;

    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
        msg!("Greetings from: {:?}", ctx.program_id);
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize {}
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";

import fs from 'fs'
let idl = JSON.parse(fs.readFileSync('target/idl/day5.json', 'utf-8'))

describe("deployed", () => {
  // Configure the client to use the local cluster.
  anchor.setProvider(anchor.AnchorProvider.env());

  // Change this to be your programID
  const programID = "Gp3W5ZxQsdaVpKVoq3QyQtMQZ1TWzJtcJW3RWXkpC2JG";
  const program = new Program(idl, programID, anchor.getProvider());

  it("Is initialized!", async () => {
    // Add your test here.
    const tx = await program.methods.initialize().rpc();
    console.log("Your transaction signature", tx);
  });
});

The error:

Image

I think the issue might due to typescript file cannot read initialize from idl file, here is my target/idl/day5.json file, which looks fine.

Image

I am using Ubuntu 24.04 on WSL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions