coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.73k stars 1.37k forks source link

anchor test error #1064

Closed Mictat closed 3 years ago

Mictat commented 3 years ago

I'm running windows 11 x64 with WSL.

When I run anchor test I get the following:

BPF SDK: /home/michael/.local/share/solana/install/releases/1.8.5/solana-release/bin/sdk/bpf
cargo-build-bpf child: rustup toolchain list -v
cargo-build-bpf child: cargo +bpf build --target bpfel-unknown-unknown --release
    Finished release [optimized] target(s) in 1.55s
cargo-build-bpf child: /home/michael/.local/share/solana/install/releases/1.8.5/solana-release/bin/sdk/bpf/dependencies/bpf-tools/llvm/bin/llvm-readelf --dyn-symbols /mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/target/deploy/mysolanaapp.so

To deploy this program:
  $ solana program deploy /mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/target/deploy/mysolanaapp.so
The program address will default to this keypair (override with --program-id):
  /mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/target/deploy/mysolanaapp-keypair.json
Error: Unable to read keypair file

The keypair file exists in both the Linux subsystem, and in my windows directory. Both solana cli's are configured to point to identical keypair json files, which I have verified by making sure they correspond to the same address.

I've also tried running a local validator manually, and deploying manually. I then run anchor test --skip-local-validator --skip-deploy. I have also ensured that src/lib.rs declare_id! macro, and the Anchor.toml, have the correct program id, however I run into this error all the same:

BPF SDK: /home/michael/.local/share/solana/install/releases/1.8.5/solana-release/bin/sdk/bpf
cargo-build-bpf child: rustup toolchain list -v
cargo-build-bpf child: cargo +bpf build --target bpfel-unknown-unknown --release
    Finished release [optimized] target(s) in 3.15s
cargo-build-bpf child: /home/michael/.local/share/solana/install/releases/1.8.5/solana-release/bin/sdk/bpf/dependencies/bpf-tools/llvm/bin/llvm-readelf --dyn-symbols /mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/target/deploy/mysolanaapp.so

To deploy this program:
  $ solana program deploy /mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/target/deploy/mysolanaapp.so
The program address will default to this keypair (override with --program-id):
  /mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/target/deploy/mysolanaapp-keypair.json
yarn run v1.22.15
warning package.json: No license field
$ /mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/node_modules/.bin/mocha -t 1000000 tests/

Error: ENOENT: no such file or directory, open 'C:\Users\mrtat\.config/solana/id.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at Function.local (/mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/node_modules/@project-serum/anchor/dist/cjs/provider.js:154:92)  
    at Function.env (/mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/node_modules/@project-serum/anchor/dist/cjs/provider.js:58:35)     
    at Suite.<anonymous> (/mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/tests/mysolanaapp.js:7:36)
    at Object.create (/mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/node_modules/mocha/lib/interfaces/common.js:148:19)
    at context.describe.context.context (/mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/node_modules/mocha/lib/interfaces/bdd.js:42:27)
    at Object.<anonymous> (/mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/tests/mysolanaapp.js:5:1)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:190:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:331:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at async formattedImport (/mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/node_modules/mocha/lib/nodejs/esm-utils.js:7:14)
    at async Object.exports.requireOrImport (/mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/node_modules/mocha/lib/nodejs/esm-utils.js:48:32)
    at async Object.exports.loadFilesAsync (/mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/node_modules/mocha/lib/nodejs/esm-utils.js:88:20)
    at async singleRun (/mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/node_modules/mocha/lib/cli/run-helpers.js:125:3)
    at async Object.exports.handler (/mnt/c/Users/mrtat/source/repos/solana-full-stack/mysolanaapp/node_modules/mocha/lib/cli/run.js:374:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Program address not found.

I can literally ctrl+click C:\Users\mrtat.config/solana/id.json and it exists. Of course there must be something (hopefully obvious) that I'm missing.

All my dependencies are up to date as far as I'm aware.

Any help would be appreciated. Thanks

Mictat commented 3 years ago

Fixed. Solution was to initialize the entire project in the Linux subsystem instead of trying to staddle both.