Skip to content
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 end-to-end testing workflow #282

Closed
wants to merge 23 commits into from
Closed

Add end-to-end testing workflow #282

wants to merge 23 commits into from

Conversation

phklive
Copy link
Contributor

@phklive phklive commented Mar 20, 2024

In this PR I add end-to-end tests for the Miden node.

closes: #222

bobbinth and others added 8 commits March 11, 2024 15:19
* ci: turn doc warnings into errors (#259)

* remove unnecessary comments

* Add script to check rust versions

* removed versions and editions except from root, updated script

* add back cargo make doc to ci

* Added section for testing

* Fixed typo

* Set versions to 0.1.0 + inherit all infos from workspace

* Fix use of versioning

* Set individual versions for crates

* Fixed nits, code organization and updated links

* Improve naming of ci job

* Fix formatting in contributing.md

* Add task to format not only check

* Reduced indent

---------

Co-authored-by: Augusto Hack <[email protected]>
* Working initial docker

* fmt

* added script

* Removed docker script + updated integration

* script works

* Need to install grpcurl

* Docker works

* Working Dockerfile

* ci: turn doc warnings into errors (#259)

* Removed makefile, removing start.sh file moving in Dockerfile

* Added bookworm + alpine + removed gcc + added caching

* Moved Dockerfile to node and added Makefile.toml

* cargo make works + builds dockerfile for node

* remove start script

* added comment regarding PID1

* Set labels at top of Dockerfile + added comments

* Added correct dependencies and explanation

* Volume works persisting db files between runs

* Added documentation

* Moved labels + enable mounting of miden-node.toml

* Added docker-run-node command + added build arguments

* Add git commit as arg to docker container

* Added spacing

---------

Co-authored-by: Augusto Hack <[email protected]>
* feat: implement nullifier tree wrapper over `Smt`

* refactor: move `NullifierTree` to separated file, renames ans small fixes

* fix: address review comments
* ci: turn doc warnings into errors (#259)

* Separated different CI jobs in their respective files

* Add next branch in ci

* Fix wrong naming in CI + use cargo make for doc

* Fixed badge + removed unnecessary additional file

* Change naming of ci and jobs

* Fix naming

* Fix comment

---------

Co-authored-by: Augusto Hack <[email protected]>
@phklive phklive changed the base branch from main to next March 20, 2024 12:40
@phklive phklive changed the title Phklive end to end Add end-to-end testing workflow Mar 20, 2024
@phklive phklive marked this pull request as draft March 20, 2024 14:50
@Dominik1999
Copy link
Contributor

Should we merge this?

@phklive
Copy link
Contributor Author

phklive commented Mar 22, 2024

Should we merge this?

I just want to go over, cleanup and should be ready for review & merge.

@phklive phklive marked this pull request as ready for review March 25, 2024 11:54
@phklive phklive mentioned this pull request Mar 25, 2024
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Thank you! Looks great! I did a very quick review and left a couple of nits/questions inline. I defer a more detailed review to @Dominik1999 or @hackaugusto.

One note for the future: these end-to-end tests will work only when node and client versions are in sync. But we won't be able to use them when the node has some breaking changes which haven't been propagated to the client yet. To address this, we'll need to create a separate "test runner" which will not rely on miden-client. Let's create an issue for this.

Comment on lines +39 to +48
- name: Install cargo make
run: cargo install cargo-make
- name: cargo make - docker-build-node
run: cargo make docker-build-node
- name: cargo make - docker-run-node
run: cargo make docker-run-node
- name: cargo install - miden-client
run: cargo install miden-client --features concurrent,testing
- name: cargo make - test-end-to-end
run: cargo make test-end-to-end
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: is the docker image built with concurrent,testing by default? Should we specify these features explicilty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed the docker image is built with the concurrent,testing features enabled by default.

Could you clarify by specify these features explicitly?

Copy link
Contributor

Choose a reason for hiding this comment

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

On line 46 we explicitly build miden-client with concurrent,testing features. Could we do something similar on line 42?

The main motivation is to make sure that that changing the defaults for docker build does not break this task.

.github/workflows/test.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@hackaugusto hackaugusto left a comment

Choose a reason for hiding this comment

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

LGTM

scripts/test-end-to-end.sh Outdated Show resolved Hide resolved
scripts/test-end-to-end.sh Show resolved Hide resolved
# Sync client and create tx between faucet and account
miden-client sync
miden-client tx new mint $basic_account $faucet_account 777
sleep 15
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this needed, can we get rid of this? sleep in tests is to me a big no-no.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The sleep is needed to leave some time for the rollup to include the transaction in a block and the block to be applied to the db. If not then the note does not have a commit height and it cannot be consumed by the Miden client.

Do you see a better solution than sleeping?

Copy link
Contributor

Choose a reason for hiding this comment

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

Polling would be the best option here. Probably the miden-client should have a command similar to miden-client wait-for-note <note_id> where the client would poll until the note_id is available.

Copy link
Collaborator

Choose a reason for hiding this comment

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

A couple of other ways to implement this now:

  • Wait for two blocks to be created before moving on (miden-client info returns the current block number; should be fairly easy to parse the response and sync until you are one or two blocks above the original count)
  • Wait until the transaction has been committed (although there is not any super simple way to programmatically get this from the client, but you can use tx list and check that the transaction ID is now committed)

[tasks.test-end-to-end]
workspace = false
script = '''
./scripts/test-end-to-end.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

I usually think of E2E as a category of tests, and not a single test. I would call this more of a smoketest. But eventually we will need something more robust to run additional tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea is that that the bash scripts can be extended with other flows enabling more testing opportunities. For now there is only 1 indeed.

Copy link
Contributor

Choose a reason for hiding this comment

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

What I was trying to say with "something more robust" is that shell script is not a good language to write E2E tests. It works for a single test like this, which does a good job of covering the happy path and being a smoke test. But once we have a handful of tests we should be able to do other things, for example:

  • have test selection, similar to how we do cargo test -- <test_name>
  • have tests run in parallel, similar to how cargo test uses runners
  • have the ability to debug the test scripts, and here shell scripts really lose the upper hand

To get the above, we will eventually have to translate the .sh into a .rs or .py. But I don't think we have to do this now.

phklive and others added 3 commits March 29, 2024 10:55
* ci: turn doc warnings into errors (#259)

* Boilerplate done

* pushed fix for miden-client

* Fix formatting

* Pulled after client fix

* Fixed typos + added build_client fn

* Added configs + figment

* Fix client implementation in faucet + use released client

* updated cargo

* Fixed Miden node when importing Miden client, db errors

* Format files

* Added proper support of configuration file + logging

* Improved config file handling

* Removed superfluous file

* First pass at improvements

* Change naming of note

* Fixed html + added metadata endpoint

* Want to implement Display for NoteId

* Upgraded js to use async + NoteId does not impl Display in main

* cargo updated

---------

Co-authored-by: Augusto Hack <[email protected]>
@phklive
Copy link
Contributor Author

phklive commented Mar 29, 2024

Thank you! Looks great! I did a very quick review and left a couple of nits/questions inline. I defer a more detailed review to @Dominik1999 or @hackaugusto.

One note for the future: these end-to-end tests will work only when node and client versions are in sync. But we won't be able to use them when the node has some breaking changes which haven't been propagated to the client yet. To address this, we'll need to create a separate "test runner" which will not rely on miden-client. Let's create an issue for this.

Created here: #291

@phklive
Copy link
Contributor Author

phklive commented Apr 18, 2024

This PR does not encompass what we need for end-to-end testing on the Miden node. Some of these tests are already covered by the Miden client. We will implement more robust end-to-end testing when the Miden node and general Miden crates are ready.

@phklive phklive closed this Apr 18, 2024
@hackaugusto hackaugusto deleted the phklive-end-to-end branch April 18, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants