anchor icon indicating copy to clipboard operation
anchor copied to clipboard

cli: Renaming program mod causes test to fail

Open armaniferrante opened this issue 3 years ago • 18 comments

Steps to reproduce

  • anchor init hello
  • anchor test
  • change the progrma's main mod hello to mod fails_now_hello
  • anchor test

The test will throw Transaction simulation failed: Attempt to load a program that does not exist.

This is caused by the fact that there are two target/idl idls and only a single program.

armaniferrante avatar Apr 10 '21 17:04 armaniferrante

Related, or potentially a dup of https://github.com/project-serum/anchor/issues/109.

armaniferrante avatar Apr 10 '21 17:04 armaniferrante

This is reproducible now without changing the program name. Pretty big noob here, and I've got no idea why sorry. But pretty hard to get up and running when the init doesn't work :smile:

Steps to reproduce

  • anchor init hello
  • anchor build
  • anchor deploy
  • anchor test

The test will throw Transaction simulation failed: Attempt to load a program that does not exist.

When I log anchor import it shows workspace: {},

ezy avatar Aug 16 '21 04:08 ezy

@ezy I was able to get around this. I'm not sure what the underlying issue is, but I noticed that the solana-test-validator process was still running between tests (maybe there was an initially failed test that left it hanging...idk).

  1. Checked if local chain was running ps au
  2. killed local solana-test-validator process
  3. Cleaned out the workspace cargo clean
  4. Deleted node_modules rm -rf node_modules
  5. Reinstalled node modules yarn install
  6. Re-ran tests anchor test

My hunch is the issue has something to do with the hanging solana-test-validator process.

tomjohn1028 avatar Aug 19 '21 22:08 tomjohn1028

I had similar problems here @ezy - did you try anchor test --skip-local-validator?

h4rkl avatar Aug 19 '21 22:08 h4rkl

Thanks @tomjohn1028, followed the instructions more closely and got it working.

ezy avatar Aug 28 '21 19:08 ezy

Ran into the same issue, then realized I missed the line that said Make sure to turn off the validator before you begin testing Anchor programs. so I was able to get it running by simply stopping the validator 😅

As @h4rkl mentioned, you can also run anchor test --skip-local-validator

dabit3 avatar Sep 08 '21 15:09 dabit3

Anyone know why I might be hanging on the finalize transaction part of the "anchor tests"? M1 mac also

bbroeking avatar Sep 18 '21 01:09 bbroeking

Hi @bbroeking I am having the same issue on an m1 mac too

JIVIN0902 avatar Oct 05 '21 08:10 JIVIN0902

@tomjohn1028 For me, the issue ended up being that my solana-test-validator was already running. Killing that process did the trick. Surprisingly the extremely thorough Solana dapp tutorial here didn't mention making sure local Solana processes were stopped whilst testing. 🤔

ra0x3 avatar Nov 25 '21 18:11 ra0x3

Still not working... M1 Mac here.

Running solana-test-validator --no-bpf-jit and then anchor test --skip-local-validator still fails.

tavyy avatar Jan 22 '22 21:01 tavyy

It's sorted now actually. I had to update my Program ID after the initial deploy.

tavyy avatar Jan 22 '22 21:01 tavyy

It's sorted now actually. I had to update my Program ID after the initial deploy.

How did you update the program ID?

umair-mirza avatar Mar 08 '22 10:03 umair-mirza

@ezy I was able to get around this. I'm not sure what the underlying issue is, but I noticed that the solana-test-validator process was still running between tests (maybe there was an initially failed test that left it hanging...idk).

1. Checked if local chain was running `ps au`

2. killed local _solana-test-validator_ process

3. Cleaned out the workspace `cargo clean`

4. Deleted node_modules `rm -rf node_modules`

5. Reinstalled node modules `yarn install`

6. Re-ran tests `anchor test`

My hunch is the issue has something to do with the hanging solana-test-validator process.

When I turn off the solana-test-validator and run anchor test, I get this error: Unable to get recent blockhash. Test validator does not look started. Check .anchor/test-ledger/test-ledger-log.txt for errors. Consider increasing [test.startup_wait] in Anchor.toml.

umair-mirza avatar Mar 08 '22 10:03 umair-mirza

@umair-mirza I have the same issue

ELBEQQAL94 avatar Mar 27 '22 18:03 ELBEQQAL94

@ezy I was able to get around this. I'm not sure what the underlying issue is, but I noticed that the solana-test-validator process was still running between tests (maybe there was an initially failed test that left it hanging...idk).

1. Checked if local chain was running `ps au`

2. killed local _solana-test-validator_ process

3. Cleaned out the workspace `cargo clean`

4. Deleted node_modules `rm -rf node_modules`

5. Reinstalled node modules `yarn install`

6. Re-ran tests `anchor test`

My hunch is the issue has something to do with the hanging solana-test-validator process.

When I turn off the solana-test-validator and run anchor test, I get this error: Unable to get recent blockhash. Test validator does not look started. Check .anchor/test-ledger/test-ledger-log.txt for errors. Consider increasing [test.startup_wait] in Anchor.toml.

I'm facing the same issue. Did you find the solution to this? Please help

AbhaySarawgi avatar Apr 23 '22 14:04 AbhaySarawgi

@umair-mirza I have the same issue

Hey did you find the solution to this problem. i'm facing the same issue rn. Please help

AbhaySarawgi avatar Apr 23 '22 14:04 AbhaySarawgi

I had the same issue

metaversekingdom avatar Jun 13 '22 08:06 metaversekingdom

Please check the network rpc... I had a same issue on my side but I reset the network rpc to the right! Then it works

dev-tom-0108 avatar Jul 06 '22 19:07 dev-tom-0108