Skip to content

test templates: add mollusk#3352

Merged
acheroncrypto merged 3 commits into
otter-sec:masterfrom
buffalojoec:mollusk-test-template
Nov 12, 2024
Merged

test templates: add mollusk#3352
acheroncrypto merged 3 commits into
otter-sec:masterfrom
buffalojoec:mollusk-test-template

Conversation

@buffalojoec

@buffalojoec buffalojoec commented Nov 8, 2024

Copy link
Copy Markdown
Contributor

This PR adds a test template for Mollusk!

Note: Unlike other test templates, this one actually puts the tests in the program crate, since it plays the best with cargo test-sbf. I think it's cleaner this way as well.

@vercel

vercel Bot commented Nov 8, 2024

Copy link
Copy Markdown

@buffalojoec is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

@buffalojoec buffalojoec marked this pull request as ready for review November 8, 2024 12:29

@acheroncrypto acheroncrypto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

Note: Unlike other test templates, this one actually puts the tests in the program crate, since it plays the best with cargo test-sbf. I think it's cleaner this way as well.

This might cause issues with the IDL generation since it runs cargo test. The main issue should be fixed in #3058, but just to make sure, could you check whether mollusk tests run during the IDL generation?

Also, it would be great to have a test for this template in CI.

@buffalojoec

Copy link
Copy Markdown
Contributor Author

just to make sure, could you check whether mollusk tests run during the IDL generation?

Let me know if there are other IDL-build scenarios, but I ran anchor idl build as well as anchor build and neither runs the Mollusk tests. Probably since they're gated behind --features test-sbf, which is enabled by cargo test-sbf but not by cargo test.

Also, it would be great to have a test for this template in CI.

Done! I actually decided to turn the "CLI init" tests into a matrix and test all of the examples, to ensure they compile and run. Let me know what you think!

@acheroncrypto acheroncrypto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually decided to turn the "CLI init" tests into a matrix and test all of the examples, to ensure they compile and run. Let me know what you think!

That's even better, thanks!


Could you also note this feature in the CHANGELOG before we merge?

Comment thread cli/src/rust_template.rs
let dev_dependencies = if with_mollusk {
r#"
[dev-dependencies]
mollusk-svm = "=0.0.6-solana-1.18"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason to use fixed versions? We're also on Solana v2 now (I see mollusk-svm 0.0.7-solana-2.0 available), but I guess it doesn't matter much.

This is not a blocker for getting this in, but please let me me know if we can relax this requirement to avoid repetitive bumps.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, maybe I wasn't understanding how the versioning worked with master. It seemed like the tip was generating a template for Anchor 0.30, which should be running 1.18, right? My lockfile was pulling in two versions when I used a version of Mollusk compatible with >2.0.

But yeah, there's a 2.0-compat release line as well as the main release line which supports 2.1.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anchor init creates templates with anchor-lang 0.30.1 because that's what the current master version is. However, master branch is already on Solana v2.1, so when we bump the version to v0.31.0 (#3259), it will use the latest Solana version of v2.

In short, the init command is not up-to-date with master, as it always uses the last released version rather than directly depending on the master branch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So does that mean we'd adjust the version for mollusk-svm after the next Anchor release? Because trying to do it now causes the test job to fail.
https://github.com/coral-xyz/anchor/actions/runs/11814814004/job/32914710753?pr=3361

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think that would make sense, since people would have the incompatible version with the new release that way.

The init test is a bit weird because it's testing the past release compared to all other tests using the latest master. It's probably best to bump mollusk-svm version during Anchor version bumps e.g. in #3259. We could also bump it beforehand, but then we'd have CI failures until the next version is released.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh cool, yeah that makes sense to me. Do you want to add it to #3259? Version 0.0.8 is compatible with Solana 2.1.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, will add it to #3259

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants