-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
#2841
base: master
Are you sure you want to change the base?
Add solana-program-test
compatibility test in CI
#2841
Conversation
The compatibility-testing package contains a simple compatibility test defined in compatibility-testing/programs/compatibility-testing/tests/solana_program_test.rs that checks for entrypoint lifetime compatibility
This CI job executes the newly added solana_program_test entrypoint_lifetime test. “continue-on-error: true” is included as the compatibility test is currently expected to fail
@dfy313 is attempting to deploy a commit to the coral-xyz Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for starting on this!
The lifetimes of the entry
function are not compatible with what processor!
macro from solana-program-test
expects, and it's quite challenging to fix it from Anchor side.
If more people start reporting about it, we might PR to solana-program-test
crate to include an anchor
feature with Anchor's expected lifetimes, but for now, passing None
to the builtin_function
argument and letting the programs get resolved from workspace/fixtures seem to be the easier option.
@@ -365,6 +365,49 @@ jobs: | |||
# - run: cd "$(mktemp -d)" && anchor init hello-anchor && cd hello-anchor && yarn link @coral-xyz/anchor && yarn && anchor test && yarn lint:fix | |||
# - uses: ./.github/actions/git-diff/ | |||
|
|||
test-anchor-compatibility: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to add this in the test-programs
section as it's much shorter and requires less duplication for CI code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
run: | | ||
cd tests/compatibility-testing | ||
test_output=$(cargo test --package compatibility-testing --test solana_program_test entrypoint_lifetime 2>&1) || test_exit_code=$? | ||
echo "$test_output" | ||
|
||
# Success exit code | ||
if [ "$test_exit_code" -eq 0 ]; then | ||
echo "solana_program_test entrypoint_lifetime compatibility test passed with exit code: $test_exit_code" | ||
# Unrecoverable error exit code | ||
elif [ "$test_exit_code" -eq 101 ]; then | ||
echo "solana_program_test entrypoint_lifetime compatibility test failed with exit code: $test_exit_code" | ||
exit 1 | ||
else | ||
echo "Unexpected exit code: $test_exit_code" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create a script file and run it instead e.g. test.sh
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had originally expected the compatibility test to fail so it made sense to use a script in conjunction with continue-on-error
.
With the updated test case logic (passing None
to the builtin_function
argument and removing the processor!
macro), the test case should pass, so this is no longer needed.
@@ -0,0 +1,20 @@ | |||
[package] | |||
name = "compatibility-testing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can we rename compatibility-test
to something that indicates solana-program-test
compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed the package to solana-program-test-compatibility
. Additionally, I renamed the test file to compatibility_test.rs
and the test case to check_entrypoint
let _pt = ProgramTest::new( | ||
"compatibility_testing", | ||
compatibility_testing::id(), | ||
processor!(compatibility_testing::entry), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think people started passing None
to the builtin_function
argument, and let cargo test-sbf
load the programs:
That way, the incompatibility of the lifetimes is not an issue and solana-program-test
can be used with the generated entry
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the context! Done!
…-test-compatability
This commit renames the compatibility-testing package, test file, and test case to: solana-program-test-compatibility, compatibility-test.rs, and check_entrypoint. This commit also updates the compatibility test by passing None to the builtin_function argument, and letting cargo test-sbf load the programs. Finally, this commit updates the CI job in reusable-tests to take advantage of existing structure.
Closes #2738
This PR adds the
tests/solana-program-test-compatibility
package which contains a simple test that checks entrypoint compatibility betweenanchor-lang
andsolana-program-test
.Executing compatibility tests
cd tests/solana-program-test-compatibility
cargo test-sbf --package solana-program-test-compatibility --test compatibility_test check_entrypoint_lifetime
Verifying entrypoint lifetime compatibility before #2656
git checkout -b temp-branch
git log --since="2023-10-9" --until="2023-10-12"
git checkout 243ab7573865a7296dd2af1153f44bffbf488458
git checkout temp-branch -- tests/solana-program-test-compatibility
cd tests/solana-program-test-compatibility
entry
function to useprocessor!
macrocargo test-sbf --package solana-program-test-compatibility --test compatibility_test check_entrypoint_lifetime
Code walkthrough (old):
https://www.loom.com/share/533e36b7a6594dcdac3b7add900eec97