Repository navigation
test: add faucet E2E test #317
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
4043ea6
chore: list make targets whose name contains a digit
ricomateo 566223a
test: add an end-to-end test against a real node and funding service
ricomateo 70e9bbf
ci: run the end-to-end test
ricomateo 38bf444
test: run the end-to-end test through the client binary
ricomateo d7684b3
test: consume the note in the end-to-end test
ricomateo e59fc9a
fix: wait longer for the note before consuming it
ricomateo 26cfb3d
ci: share the release cargo cache between the test jobs
ricomateo 5871820
test: build the end-to-end binaries in a single invocation
ricomateo 6bc3b6d
test: give the end-to-end setup one make target and its own scripts d…
ricomateo 6a3a561
chore: cleanup docs
ricomateo b895caf
fix: re-clone the node repo when the cargo cache empties it
ricomateo 0b2612d
chore: restore error message
ricomateo 97eb0a7
chore: rename miden-client.sh to install-miden-client.sh
ricomateo 79c4770
chore: cleanup
ricomateo 8c6c8b1
test: replace the end-to-end shell test with a rust one
ricomateo c184092
chore: lint
ricomateo 94121fa
fix: pin NODE_VERSION to the latest available version with published …
ricomateo c8e7d40
Merge branch 'next' into ricomateo-e2e-test
ricomateo 70c7f6a
chore: unpin node version in ci e2e test
ricomateo f3f9b32
chore: address review comments
ricomateo d44a6e4
chore: reuse Endpoint::localhost() instead of redefining it
ricomateo 8f4a492
test: remove faucet.sh script and start the faucet in the rust test i…
ricomateo cd1b2c9
Merge branch 'next' into ricomateo-e2e-test
ricomateo 9a58f29
fix: change network.sh to read node version from Cargo.lock instead o…
ricomateo 82e4a64
fix: add missing field when creating FaucetConfig
ricomateo f4c580d
fix(test): sync the client before waiting for the note to be committed
ricomateo 3dfc5ce
chore: restore main.rs
ricomateo 17ffd52
fix: github security bot comment
TomasArrachea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Runs the faucet against a real node and funding service. | ||
|
|
||
| name: test-e2e | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, next] | ||
| pull_request: | ||
| types: [opened, reopened, synchronize] | ||
|
|
||
| # Limits workflow concurrency to only the latest commit in the PR. | ||
| concurrency: | ||
| group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test-e2e: | ||
| name: test-e2e | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - uses: actions/checkout@main | ||
| - name: Rustup | ||
| run: rustup update --no-self-update | ||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| # `make test` builds the whole workspace in release, which covers everything this job | ||
| # compiles, so both share one cache instead of each filling its own. | ||
| shared-key: release | ||
| # Saving on a pull request too means a second push to the same branch does not recompile. | ||
| # GitHub scopes a branch's cache to that branch, so this does not disturb other runs. | ||
| save-if: true | ||
|
|
||
| - name: Start the node and the funding service | ||
| run: scripts/e2e/network.sh up | ||
|
|
||
| - name: Run the test | ||
| run: cargo test --release --locked -p miden-faucet-client --test e2e -- --ignored --nocapture | ||
|
|
||
| - name: Network logs | ||
| if: failure() | ||
| run: scripts/e2e/network.sh logs | ||
|
|
||
| - name: Stop everything | ||
| if: always() | ||
| run: scripts/e2e/network.sh down |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ use tokio::task; | |
|
|
||
| const DEFAULT_FAUCET_URL: &str = "https://faucet-api.testnet.miden.io"; | ||
| const REQUEST_TIMEOUT_MS: u64 = 30_000; | ||
| const MAX_SYNC_RETRIES: u32 = 3; | ||
| const MAX_SYNC_RETRIES: u32 = 10; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I increased this because 3 attempts was not enough when running the E2E test in the CI |
||
| const SYNC_RETRY_DELAY_SECS: u64 = 5; | ||
|
|
||
| // CLI | ||
|
|
@@ -166,15 +166,15 @@ impl MintCmd { | |
|
|
||
| /// HTTP client for interacting with the faucet API. | ||
| #[derive(Clone)] | ||
| struct FaucetHttpClient { | ||
| pub struct FaucetHttpClient { | ||
| http_client: HttpClient, | ||
| base_url: Url, | ||
| api_key: Option<String>, | ||
| } | ||
|
|
||
| impl FaucetHttpClient { | ||
| /// Creates a new `FaucetHttpClient` instance. | ||
| fn new( | ||
| pub fn new( | ||
| endpoint: &str, | ||
| timeout_ms: u64, | ||
| api_key: Option<String>, | ||
|
|
@@ -191,7 +191,7 @@ impl FaucetHttpClient { | |
| } | ||
|
|
||
| /// Requests a `PoW` challenge from the faucet API. | ||
| async fn request_pow( | ||
| pub async fn request_pow( | ||
| &self, | ||
| account_id: &AccountId, | ||
| amount: u64, | ||
|
|
@@ -231,7 +231,7 @@ impl FaucetHttpClient { | |
| } | ||
|
|
||
| /// Requests tokens from the faucet API. | ||
| async fn request_tokens( | ||
| pub async fn request_tokens( | ||
| &self, | ||
| challenge: &str, | ||
| nonce: u64, | ||
|
|
@@ -349,7 +349,7 @@ fn parse_account_id(input: &str) -> Result<AccountId, MintClientError> { | |
| /// Solves the `PoW` challenge and returns the nonce that satisfies the target. | ||
| /// | ||
| /// Heavy work runs on a blocking thread so we don't stall the async runtime. | ||
| async fn solve_challenge(challenge_hex: &str, target: u64) -> Result<u64, MintClientError> { | ||
| pub async fn solve_challenge(challenge_hex: &str, target: u64) -> Result<u64, MintClientError> { | ||
| if target == 0 { | ||
| return Err(MintClientError::ZeroTarget); | ||
| } | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 this dep is unused.
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.
Actually, this is for creating the client in the test itself
faucet/bin/faucet-client/tests/e2e.rs
Line 15 in f3f9b32