feat: rework test-harness for integration tests#896
feat: rework test-harness for integration tests#896lima-limon-inc wants to merge 4 commits into0xMiden:nextfrom
Conversation
|
@greenhat @bitwalker The PR is not yet finished, but what do you think about this approach? Any comments / recommendations are more than welcome. Thanks in advance! |
|
Good job!
The only problem with attribute macro DSLs I see is discoverability by the user. To this day I have to jump and search the docs when I'm using |
Thank you very much! 😊
Completely agree, The first thing that comes to mind is implementing a "help" command in the macro itself. Something like: #[miden_test(help)]
pub fn test_basic_wallet_p2id() {
(...)
}Which would display all of the supported attributes. Whilst I haven't seen this idea of a "help" command in macros, it's pretty standard in CLI tools; so maybe the it isn't too far out there. I'll tackle it and see how it goes. Do let me know if you have any thoughts! |
ed703ea to
6065281
Compare
I have just pushed the code that supports --> tests/integration-network/src/mockchain/basic_wallet.rs:20:1
|
| #[miden_test(help)]
| ^^^^^^^^^^^^^^^^^^^
|
= help: message:
<documentation string>Where A nifty detail is that it uses each struct's doc-comments to generate the help message. Which means that it remains consistent and up to date with the generated Additionally, I also added support for The actual displayed help message is still a bit rough around the edges, but all the "logic" to collect and generate the message is all there. I'll update the PR as soon as that is done. Just wanted to update the PR to show how things are shaping up 😊. Any comment/suggestion is more than welcome! Cheers! |
Nice! I have not thought about calling a macro to get help. |
a7eb5ca to
1ed5b54
Compare
2e7c626 to
30a9d0d
Compare
d2814c0 to
8207c15
Compare
|
@bitwalker @greenhat I believe the PR is ready for review. Do note that it mainly focuses on refactoring the present test harness infrastructure itself to make it compatible with integration tests.
The actual expansion of the present tests could probably be done in a separate PR since this already is quite extensive. Would love to hear your thoughts! PS: The CI is currently running but it should pass, I've just pushed a commit updating the documentation. |
bitwalker
left a comment
There was a problem hiding this comment.
Definitely cleans up the boilerplate!
I do have some reservations about the level of magic involved, but the help attribute does mitigate that for the most part (of course, one has to know to use that in the first place, but it's still better than nothing). I definitely wish that attribute macros supported the same "helper" attributes mechanism that derive macros do, since that would help with discoverability, but 🤷.
I would suggest we provide a higher-level "user guide"-type document as well, maybe in test-harness/README.md, which goes into detail how the different options stack/interact, what the defaults are, and whether some options require others to be provided, and if so, under what conditions. That sort of guidance is the main thing missing IMO, as currently we largely are just relying just on a small set of examples, and the minimal help documentation produced by the help argument (which isn't very discoverable/accessible unless you look at the examples where it is featured).
I'm marking this approved though, and we can merge this once an initial version of that document is added here, just ping me!
e474bfc to
b4f6844
Compare
I'm glad it helps 😊
@bitwalker |
|
Good job! Very thorough exploration of what's possible to achieve with macros. I think that the macro parameters approach in general cost/benefit is not looking good. Let's look at the following macro parameters: It is not much more concise than our current ad hoc and unoptimized API: let alice_account = builder
.add_account_from_builder(
Auth::BasicAuth,
build_existing_basic_wallet_account_builder(wallet_package.clone(), true, [5_u8; 32]),
AccountState::Exists,
);But it is significantly more expensive for the developers. I consider the following to be the extra price that the developers would pay for macros on top of Mockchain (which is not going anywhere):
With all that in mind I think that we should consider that macros might not be worth pursuing and we might need to change the direction. The alternatives I see:
|
b4f6844 to
133c669
Compare
I see, those are some great points! Thank you very much for the thorough explanation 😊 @greenhat
I have been working on a rework considering your comments and also taking as inspiration the Firstly, the let scenario = ScenarioBuilder::new()
.next()
.add_package("../../examples/basic-wallet", "wallet")
.add_package("../../examples/p2id-note", "p2id-note")
.add_package("../../examples/basic-wallet-tx-script", "tx-script")
.next()
.add_faucet(FaucetAccountConfig::default().with_alias("faucet"))
(...)Currently there are 4 of these: Additionally, similar to the previous macro PR, we take a "default if omitted" approach: if a value is not specified, we use a "sane" default. This is achieved with the I have just pushed an initial implementation of this approach, and used it in the What do you think of this new approach? Does it better tackle your points? Or should I change course in some/all aspects? Thanks in advance! Would love to hear your thoughts! 😊 |
|
Thank you! Good job experimenting with As we've discussed on the call, we should first explore improving the
|
a4383c8 to
517113c
Compare
|
|
||
| pub trait ComponentFromProject { | ||
| fn build_project(project_path: &str) -> Arc<Package> { | ||
| let output = std::process::Command::new("miden") |
There was a problem hiding this comment.
Let's check if miden is available and if not, print an instruction (or link to) on how to install it.
There was a problem hiding this comment.
Let's check if
midenis available and if not, print an instruction (or link to) on how to install it.
Great point, I'll add a validation!
Edit: here's the validation: c1f3086
8b185c1 to
add1b20
Compare
|
|
||
| [dependencies] | ||
| miden-client = { version = "0.13", features = ["std", "tonic", "testing"] } | ||
| miden-client = { branch = "fabrizioorsi/miden-testing-compiler-backport", git = "https://github.com/lambdaclass/miden-client.git", features = ["std", "tonic", "testing"] } |
There was a problem hiding this comment.
This branch contains the changes made in this PR, only backported to version 0.13 of the miden client.
6ddf17d to
66575a4
Compare
| - name: Install midenup | ||
| run: | | ||
| if ! miden help 2>/dev/null; then | ||
| cargo install --git https://github.com/0xMiden/midenup | ||
| fi |
There was a problem hiding this comment.
Currently, accessing the miden interface requires further intervention by adding some variables to the system's $PATH. This is not ideal for cases like this I believe.
There was a problem hiding this comment.
I'll create an issue on midenup to track this: 0xMiden/midenup#165
90bba64 to
e9fe1cc
Compare
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
e9fe1cc to
0eabee1
Compare
…oorsi/i876-harness-in-tests Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com>
|
@greenhat I believe the PR is reviewable with a couple of caveats:
I tried to use as much code from Would love to hear your thoughts. |
greenhat
left a comment
There was a problem hiding this comment.
Looking good! Nice job! Only one minor issue.
|
|
||
| if release { | ||
| builder.with_release(true); | ||
| pub(super) fn compile_rust_package(project_path: &str, release: bool) -> Arc<Package> { |
There was a problem hiding this comment.
This function is intended to be used by the users (smart contract developers in their tests). And I believe I saw some discussion of how to implement the package compilation in the miden-testing. Or am I missing something?
@lima-limon-inc For the compiler test suite we should use the previous version of the compile_rust_package that calls CompilerTestBuilder. This should eliminate the need for the CI job above.
There was a problem hiding this comment.
And I believe I saw some discussion of how to implement the package compilation in the
miden-testing. Or am I missing something?
If I'm not mistaken, the only mention of package compilation in miden-testing/miden-protocol was this comment by @PhilippGackstatter in #981 (comment).
PhilippGackstatter said:
I'm not sure what this will look like, but if these are compiler specifics, isn't this better suited to be an extension trait of MockChainBuilder instead of integrating the need for midenup into miden-testing (but maybe I'm imagining the wrong thing)?
Edit: I've adressed your comment in this commit: 4c3d1ea.
As an aside, currently the Cargo.toml file points to a branch I created as a backport. I believe that we can update it as soon as this PR 0xMiden/protocol#2502 gets merged, right?
Signed-off-by: Tomas Fabrizio Orsi <tomas.orsi@lambdaclass.com> Suggested-by: Dennis Zadorozhnyi <denys.z@miden.team>
Tackles #981
This PR aims to remove some functionality from the compiler's testing crate and rely on
miden-protocol's testing crate.This includes the following changes:
create_note_from_packagefunction. This now relies onmiden-protocol'sNoteBuilder(which gotPackagesupport added into it in this PR).account_component_from_packagefunction which was replaced withAccountoComponent::from_package.compile_rust_packagemethod callsmiden buildinstead of the compiler's library.build_existing_basic_wallet_account_builderfunction.MockChainBuilder::add_existing_account_from_componentswhich was also added in PRNoteCreationConfigsince it was superseded byNoteBuilder.