1

I'm writing an Anchor program and would like to include a couple functions that modify certain values during tests in a way that would be tedious to do with the real program interface. I don't want to keep this for my production code. What is the standard way of doing this in Anchor?

1 Answer 1

1

You should be able to use conditional compiling like this:

#[cfg(feature = "is-test")]
pub fn increase_counter_function(mut count: u64) -> u64 {
    count += 1;
    count
}

and then you set the value in the cargo.toml

[features]
is-test = []

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.