-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add solana-program-test
compatibility test in CI
#2738
Comments
Hey! I'm interested in working on this issue and have explored an approach for compatibility testing in this draft PR: #2841. Does this align with the solution you had in mind? |
Hey! Is there any solution? I bumped into this |
@denisglotov this is a wrapper I'm using which seems to suppress the warnings. The program I'm testing is called use kickjump_launchpad::ID_CONST;
use solana_program::account_info::AccountInfo;
use solana_program::entrypoint::ProgramResult;
use solana_program::pubkey::Pubkey;
use solana_program_test::processor;
use solana_program_test::ProgramTest;
pub fn add_program() -> ProgramTest {
ProgramTest::new("kickjump_launchpad", ID_CONST, processor!(entry))
}
/// This is a wrapper to get the processor macro to work.
fn entry(program_id: &Pubkey, accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResult {
let accounts = Box::leak(Box::new(accounts.to_vec()));
kickjump_launchpad::entry(program_id, accounts, instruction_data)
} |
I've added the following workaround to my own codebase for testing. Would it be useful to others? If so, I can create a pull request. /// The current processor for [`solana_program_test`] doesn't support anchor
/// programs due to lifetime conflicts. This is a wrapper that supports the
/// anchor lifetimes by using [`Box::leak`] on the accounts array.
#[macro_export]
macro_rules! anchor_processor {
($program:ident) => {{
fn entry(
program_id: &::solana_program::pubkey::Pubkey,
accounts: &[::solana_program::account_info::AccountInfo],
instruction_data: &[u8],
) -> ::solana_program::entrypoint::ProgramResult {
let accounts = Box::leak(Box::new(accounts.to_vec()));
$program::entry(program_id, accounts, instruction_data)
}
::solana_program_test::processor!(entry)
}};
} |
Problem
The expected entrypoint lifetimes in
solana-program-test
is not compatible with the0.29.0
release due to the changes in #2656 but we have no tests for this case in CI.Solution
Add a simple test to check the compatibility between
anchor-lang
andsolana-program-test
.Related: #2711
The text was updated successfully, but these errors were encountered: