When I run "anchor test", I am getting this error (for a sample Solana program"

84 views Asked by At

adithyakrishnaa@AdiLegion:~/myepicproject$ anchor test warning: unused variable: ctx --> programs/myepicproject/src/lib.rs:9:23 | 9 | pub fn initialize(ctx: Context) -> Result<()> { | ^^^ help: if this is intentional, prefix it with an underscore: _ctx | = note: #[warn(unused_variables)] on by default

warning: myepicproject (lib) generated 1 warning (run cargo fix --lib -p myepicproject to apply 1 suggestion) Finished release [optimized] target(s) in 0.06s

Found a 'test' script in the Anchor.toml. Running it as a test suite!

Running test suite: "/home/adithyakrishnaa/myepicproject/Anchor.toml"

yarn run v1.22.21 warning package.json: No license field $ /home/adithyakrishnaa/myepicproject/node_modules/.bin/mocha -t 1000000 tests/

myepicproject 1) Is initialized!

0 passing (41ms) 1 failing

  1. myepicproject Is initialized!: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: invalid account data for instruction at Connection.sendEncodedTransaction (node_modules/@solana/web3.js/lib/index.cjs.js:8031:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Connection.sendRawTransaction (node_modules/@solana/web3.js/lib/index.cjs.js:7997:20) at async sendAndConfirmRawTransaction (node_modules/@coral-xyz/anchor/dist/cjs/provider.js:247:23) at async AnchorProvider.sendAndConfirm (node_modules/@coral-xyz/anchor/dist/cjs/provider.js:98:20) at async MethodsBuilder.rpc [as _rpcFn] (node_modules/@coral-xyz/anchor/dist/cjs/program/namespace/rpc.js:15:24) at async Context. (tests/myepicproject.js:10:16)

error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I am following this tutorial as I am a beginner: https://github.com/LearnWithArjun/solana-env-setup/blob/main/windows_setup.md

I ran "yarn add ts-mocha" but it did not help.

1

There are 1 answers

0
Adithyakrishna A On

I found out that I just needed to run "npm update -g". Thanks everyone for looking to help me.