anchor: cli: Renaming program mod causes test to fail
Steps to reproduce
- anchor init hello
- anchor test
- change the progrma’s main
mod hello
tomod 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.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 18 (3 by maintainers)
@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).
ps au
cargo clean
rm -rf node_modules
yarn install
anchor test
My hunch is the issue has something to do with the hanging solana-test-validator process.
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
@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. 🤔I had similar problems here @ezy - did you try
anchor test --skip-local-validator
?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.
It’s sorted now actually. I had to update my Program ID after the initial deploy.
Thanks @tomjohn1028, followed the instructions more closely and got it working.