anchor: Anchor test failing on local devnet

Error: failed to send transaction: Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.

When I run anchor test command its failing due to this error . I don’t know what this is.

use anchor_lang::prelude::*;

declare_id!("JessifiGcYGSnfFpF6ffPFuGusKVFZUBcfhQDcGd3t2");

#[program]
pub mod mysolanaapp {
    use super::*;
    pub fn initialize(ctx: Context<Create>) -> ProgramResult {
        Ok(())
    }
}
#[derive(Accounts)]
pub struct Create {

}


#[account]
pub struct BaseAccount{
    pub count: u64
}
const assert = require("assert");
const anchor = require("@project-serum/anchor");
const { SystemProgram } = anchor.web3;

describe("mysolanaapp", () => {
	/* create and set a Provider */
	let _baseAccount;
	const provider = anchor.Provider.env();
	anchor.setProvider(provider);
	const program = anchor.workspace.Mysolanaapp;
	it("Is initialized!", async () => {
		const program = anchor.workspace.Mysolanaapp;
		const tx = await program.rpc.initialize();
		console.log("Your transaction signature", tx);
	});
})

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (3 by maintainers)

Most upvoted comments

@armaniferrante this solved the problem 👇

it seems anchor test runs solana-test-validator internally so I just terminated the solana-test-validator process and ran anchor test and it worked

https://user-images.githubusercontent.com/4649902/151736154-ff00ed07-5e64-404c-a031-be2db3c09d1b.mp4