Questions tagged [anchor-test]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
7 views

Error: IDL for program `loss_harvester` does not have `metadata.address` field

When running anchor test on my solana program it complains that the IDL is missing the metadata.address field. But when I add it, it disappears again after running anchor test. My program built fine. ...
samuelshix's user avatar
0 votes
0 answers
16 views

Failed to get validator identity over RPC: HTTP status server error (502 Bad Gateway) for url (http://127.0.0.1:8899/) while testing with anchor

I just want to have a simple test with anchor. So I use anchor init to build up a simple program, without changing any code. When I try to run anchor test, the terminal seems to stop here: warning: ...
Hikari's user avatar
  • 1
0 votes
0 answers
25 views

How to increase the system clock timestamp in tests?

This is potentially related to Mocking the Clock sysvar in solana_program_test, but I didn't find a sufficient answer/discussion there. I have a program instruction that contains logic such that ...
Ammon Werner's user avatar
0 votes
0 answers
11 views

spl-token library failing to fetch rent exemption minumum?

I'm working with the @solana/spl-token lib, and when running createMint, I keep getting hit with TypeError: fetch failed. I have narrowed this down to the getMinimumBalanceForRentExemptMint function ...
Morgandril's user avatar
1 vote
1 answer
30 views

NFTs on anchor tests

I'm trying to use this guide to create an NFT to test with my anchor program. When I attempt to mint the NFT, I am met with the following error. FailedToSendTransactionError: The transaction could not ...
Morgandril's user avatar
2 votes
1 answer
27 views

Signer issues with anchor tests

i'm getting a weird signer error when running my tests; Error: Signature verification failed. Missing signature for public key [`6jAudYFBbfQS59oPNjYcMkqr9MqBf312T7oP6WSYRjsg`]. In this case, ...
Morgandril's user avatar
0 votes
1 answer
47 views

What is the meaning of "custom program error: 0x1771" erro?

what is the meaning of custom program error: 0x1771 error?
blackhorse's user avatar
1 vote
1 answer
40 views

Token2022 testing interest bearing token doesn't update balance and freeze when updateRate

I need some help/insight to fix/make the tests work. I'm trying to test locally a complete case of Token2022 with interest, but I have 2 problems locally (in devnet everything works as expected). The ...
Shelvak's user avatar
  • 11
0 votes
1 answer
40 views

Localnet transaction stuck finalizing

I attempted to run my test using anchor on Localnet but got my test stuck like this ⠤ [0/1] Finalizing transaction ...
Kombi's user avatar
  • 1
2 votes
1 answer
58 views

What is the meaning of custom program error code 0xc?

I am trying to test my program but I am getting Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0xc Can someone suggest the ...
blackhorse's user avatar
0 votes
1 answer
28 views

I get "yarn: error: no such option: -p" when try run tests

When I attempt to run anchor tests through anchor test I get the following error: warning: `hello` (lib) generated 1 warning (run `cargo fix --lib -p hello` to apply 1 suggestion) Finished release ...
Amir reza Riahi's user avatar
3 votes
1 answer
43 views

No tests running when running `anchor test`

I cloned my anchor repo but after installing the modules and building, testing the program results in 0 of the test cases running. Here are the logs Found a 'test' script in the Anchor.toml. Running ...
Jimii's user avatar
  • 1,438
1 vote
0 answers
48 views

Getting error "An account required by the instruction is missing" while creating associated token address

I am trying to create associated token address on solana program with below configuration #[derive(Accounts)] #[instruction(params: TokenParams)] pub struct MintToken<'info> { /// CHECK: ...
blackhorse's user avatar
2 votes
1 answer
24 views

canonical method of calling programs functions in script format

I have a couple deployed programs on Devnet. Is there a standard way of calling functions on a deployed program, assuming I have the IDL? Obviously I could write a test but a test typically deploys a ...
AceGravity's user avatar
2 votes
1 answer
41 views

How can I fix Error Code: InstructionFallbackNotFound?

Today I had this error that took me a while to determine what was happening. 1) Create suscription Is initialized!: Error: AnchorError occurred. Error Code: InstructionFallbackNotFound. ...
Mateo Lafalce's user avatar
1 vote
1 answer
38 views

How to convert Vec<u8> to typescript bytes?

In my rust solana smart contact, build with anchor framework, there is one of my variable that is of type in below format struct X { a: Vec<u8> } while building the contract with anchor ...
blackhorse's user avatar
1 vote
1 answer
50 views

Error: unknown signer for SPL Token Transfer

i'm writing an SPL token in anchor for learning but am running into issues when transferring my test SPL token from a newly created anchor keypair. the transfer works for provider.wallet signer (which ...
AceGravity's user avatar
1 vote
1 answer
127 views

Transaction simulation failed: Error processing Instruction 0: Program failed to complete

I'm trying to get an example lottery project to run in my local environment. Anchor test projects and all that work for me. Anchor build - deploy - test all runs well. However on this https://github....
vonyi's user avatar
  • 13
2 votes
2 answers
95 views

Creating Address Lookup Table in localnet fails with "invalid instruction data" error

As the title says, I'm unable to create an Address Lookup Table in localnet. I'm trying to create it in an anchor test and using the following code (which works in devnet/mainnet): const slot = await ...
meditatingsloth's user avatar
2 votes
1 answer
57 views

Multiple Signers on Anchor

I'm writing some tests for an anchor program. I'm passing into the program 2 signers because it seems like the IDL is asking for it, but I don't quite understand how / why this works. Any help in ...
AceGravity's user avatar
1 vote
1 answer
58 views

Custom Program Error 0x0 When Running Test

I've looked around and I see this is a common error that devs run into based on the fact that an account was already initialized. I'm just wondering how to fix it so that I can run tests without ...
Brian M.'s user avatar
  • 111
1 vote
1 answer
29 views

Account data is not persisting for a really simple instruction

I am calling an Anchor instruction (see below) from my tests to extend the lock date for this account. Here is the Anchor code: #[derive(Accounts)] #[instruction(duration: u64)] pub struct ExtendLock&...
mmelvin0x's user avatar
1 vote
1 answer
112 views

What does anchor error `2003` mean

What does the error for A raw constraint was violated mean? errorCode: { code: 'ConstraintRaw', number: 2003 }, errorMessage: 'A raw constraint was violated',
Jimii's user avatar
  • 1,438
0 votes
0 answers
27 views

Problem with testing a name service smart contract written in Solang

I'm trying to run a benchmark for a Solana node using this name service I wrote in Solang within an Anchor project. This is the Solang smart contract. import 'solana'; contract eclipse_ns { ...
Pratham Prasoon's user avatar
1 vote
1 answer
78 views

How to run ONLY ONE test in Anchor 0.29.0?

This error came back in 2023 after the previous post here from 2022 August. anchor run test1 now gave me Error: failed to get recent blockhash: TypeError: fetch failed !!?? That is because it does not ...
Russo's user avatar
  • 193
1 vote
2 answers
54 views

Are enums with associated values permitted?

Not sure if this is really an anchor or solana related question, since I am able to compile, just not to run tests. I can run code and test against code that has an account that has following enum: #[...
mega_creamery's user avatar
2 votes
2 answers
403 views

is there a limit to the number of functions that can consume anchor Context?

I currently Have four functions, that consume the context for my Dummy Accounts struct, Two of the functions work as expected but the other two fail. #[derive(Accounts)] #[instruction(bump: u8)] pub ...
Jimii's user avatar
  • 1,438
0 votes
1 answer
120 views

IdlError: Type not found for custom struct

I got started with writing smart contracts 2 days ago so please bear with me. The function emit_event emits an event. I want to call the function via a CPI form another program. I have written code ...
Wilfred Almeida's user avatar
1 vote
1 answer
66 views

How do I pass in `Option<MyEnum>` as an argument when testing

I have a functions looks somewhat like this in the program enum DummyState { one, two } fn dummy(ctx: Context<Dummy>, state: Option<DummyState>) { ... } How do I pass in the ...
Jimii's user avatar
  • 1,438
0 votes
1 answer
772 views

TypeError: Cannot convert a Symbol value to a string error

I'm back with new question. I'm stucked with this error: TypeError: Cannot convert a Symbol value to a string Weird thing is, My code is exactly same at both linux and window WSL. but when I copy and ...
0xLuckycig's user avatar
2 votes
1 answer
273 views

problem with running tests for every program in local env

Problem with local env. tests fail Account doesn't get initiated every time for other program tests as well, but works on solpg anchor test Finished release [optimized] target(s) in 0.10s Found a '...
0xmadhan's user avatar
1 vote
0 answers
57 views

Anchor Metadata Creation: insufficient account keys for instruction

I'm getting an error while creating a new token mint. I'm passing all the accounts but still get "Error: NotEnoughAccountKeys". Here's my Anchor Program: pub fn create_mint( ctx: ...
Ace's user avatar
  • 41
0 votes
1 answer
53 views

Error while trying to build an anchor project

I am trying to build a new anchor project with boilerplate code. However, I am failing to do so and getting the error: error[E0658]: let...else statements are unstable Anchor version: 0.27.0 OS: macOS ...
Shubham Singh's user avatar
2 votes
1 answer
90 views

I can't figure out why this transaction simulation is failing

I'm working on a simple proof of concept guessing game like Clue, written in Anchor Lang, and I'm having trouble getting one of my transactions to work correctly. Here is the code in question: // lib....
mmelvin0x's user avatar
1 vote
1 answer
106 views

Don't understand why I am getting errors: custom attribute panicked - and - unexpected closing delimiter: `)`

I am trying create a simple Solana/Rust app using Anchor that publishes a single set of setters and getters like so: use anchor_lang::prelude::*; #[program] mod my_program { use super::*; #[...
Bob Reselman's user avatar
0 votes
1 answer
124 views

Error Message: You cannot/should not initialize the payer account as a program account

I have a program and when I run the tests using anchor test I keep getting the error that I cannot and shouldn't initialize the payer account as the program account. Here is the rust code: use ...
kattyd's user avatar
  • 1
0 votes
1 answer
64 views

Mac M1 Max `anchor test --skip-local-validator` infinite looop

I'm running solana v1.13.7 locally for solana-test-validator on my Mac M1 Max (13.3). You can see my left terminal has the local test validator is running on port 8899. The right side, I am running ...
AceGravity's user avatar
1 vote
1 answer
118 views

Illegal instruction (Mac M1 Max 13.3)

I've scoured discord and stack exchange but haven't found any solution that works for me. When I run a local validator (Solana test validator built from source), I get error: Ledger location: test-...
AceGravity's user avatar
1 vote
1 answer
4k views

How do I fix error Syntax Error: Unexpected token '.' when running anchor test

I get the following error when I run anchor test to test my smart contract using typescript: Error snippet abortSignal: options?.abortSignal, ^ SyntaxError: ...
dsapalo's user avatar
  • 125
2 votes
1 answer
88 views

TypeScript production code to mint an NFT vs anchor testing code

How would I go about converting the following testing code (from an anchor project) to something that would interact with my frontend in production (or convert it into a function to be used in react ...
xkycc's user avatar
  • 99
2 votes
1 answer
260 views

Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Cross-program invocation with unauthorized signer

I am trying to run a test on anchor/metaplex code that should be minting a new NFT/creating a master edition account, however my test is failing and I'm not sure why. Here is the error message: 0 ...
xkycc's user avatar
  • 99
3 votes
1 answer
228 views

Can't run Anchor test with the basic project

I just created an Anchor project with anchor init and tried to run anchor test but it didn't work. I always get the error: Unable to get latest blockhash. Test validator does not look started. Check ....
Lano's user avatar
  • 153
2 votes
1 answer
121 views

Control time anchor test

I want to control time like moving forward to a specified block or time so that we can check if the function after the block/time lasts works well. Is there any way to do that in anchor solana?
marethyu's user avatar
  • 333
3 votes
2 answers
878 views

Error trying to run anchor test

trying to learn anchor dev, following soldev.app. I have a problem, when I run anchor test, this is the error I get: Unable to get the latest blockhash. The test validator does not look started. Check ...
LAUR_NASA's user avatar
  • 173
1 vote
2 answers
391 views

How can I test the anchor has_one check?

I want to test the anchor "has one" authority check so that only the signer that initialized the account can call a function in the smart contract. This way only the wallet that called the ...
djd's user avatar
  • 83
3 votes
1 answer
863 views

Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete

I get this error when I am calling an instruction of a program from a client. I am using Seahorse library to write smart contract. The library transpiles python code to anchor rust program. Here's the ...
denimcodes's user avatar
3 votes
1 answer
149 views

How to pass instruction data in anchor tests?

I wrote an anchor program which initializes a counter account and sets its inital value to instruction_data. pub fn initialize(ctx: Context<Initialize>, instruction_data: u64) -> Result<()&...
Thomas Gehrmann's user avatar
3 votes
1 answer
1k views

Insufficient lamports but my balance already is 7 SOL

I'm trying to transfer sol via smart contract but when I make a transfer tx, it return insufficent lamports, and it says I have 0 lamports. pub fn buy_nft( ctx: Context<BuyNft>, ...
marethyu's user avatar
  • 333
1 vote
1 answer
858 views

The program expected this account to be already initialized

When I do anchor build, the compiler returns this error caused by mint, ownerTokenAccount, and buyerTokenAccount. Here is my code: it("Is initialized!", async () => { // let ...
marethyu's user avatar
  • 333
1 vote
0 answers
68 views

When using Event listener the rpc call to program function does nothing and eventualy time limit will exceed and test fails

This block of code is giving the trouble.. let listener = null; //@ts-ignore let [event, slot] = await new Promise((resolve, _reject) => { listener = program.addEventListener(&...
Lobo1897's user avatar
  • 153