fix(cleanup): validate faucet args for non-framework testnets#3424
Merged
fix(cleanup): validate faucet args for non-framework testnets#3424
Conversation
Replace the BOOTSTRAP_DIR-based precondition with a socket-path check so cleanup fails fast when run against a non-framework testnet without explicit faucet address and skey. Extract the CARDANO_NODE_SOCKET_PATH validation from conftest into helpers so it can be reused by testnet_cleanup and guarded against short paths. Add a faucet.addr existence check and a clearer error when inference is not possible.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the ergonomics and safety of running testnet_cleanup against non-framework testnets by replacing a BOOTSTRAP_DIR-based assumption with a reusable CARDANO_NODE_SOCKET_PATH validation and by making faucet inference failures more explicit.
Changes:
- Extract
CARDANO_NODE_SOCKET_PATHvalidation fromconftest.pyintoutils/helpers.py(with added guarding for short/invalid paths). - Add
is_framework_testnet()and tighten faucet inference behavior inutils/testnet_cleanup.py(includingfaucet.addrexistence check). - Update the standalone
cardano_node_tests/testnet_cleanup.pyCLI precondition to require explicit faucet args when not running on a framework-managed testnet.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cardano_node_tests/utils/testnet_cleanup.py | Adds framework-testnet detection via socket-path validation and improves faucet inference errors. |
| cardano_node_tests/utils/helpers.py | Introduces a shared check_cardano_node_socket_path() validator for reuse across modules. |
| cardano_node_tests/tests/conftest.py | Switches pytest startup socket-path validation to the shared helper. |
| cardano_node_tests/testnet_cleanup.py | Updates CLI precondition logic to use framework-testnet detection instead of BOOTSTRAP_DIR. |
Comments suppressed due to low confidence (1)
cardano_node_tests/testnet_cleanup.py:74
- The CLI pre-check uses
is_framework_testnet()to decide whether faucet inference is possible, buttestnet_cleanup.cleanup()can still raiseFileNotFoundError/ValueErrorwhen inference fails (e.g., missingfaucet.addr/keys). Sincemain()doesn’t catch those, the script can exit with a stack trace instead of a clean log message + return code. Suggest wrapping thecleanup(...)call in a try/except for these expected failures and logging an actionable error before returning 1.
if not (args.address or testnet_cleanup.is_framework_testnet()):
LOGGER.error(
"The address and skey file must be provided when running with non-framework testnet."
)
return 1
state_dir = pl.Path(socket_env).parent
cluster_obj = clusterlib.ClusterLib(state_dir=state_dir)
testnet_cleanup.cleanup(
cluster_obj=cluster_obj,
location=args.artifacts_base_dir,
faucet_address=args.address,
faucet_skey_file=args.skey_file,
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Replace the BOOTSTRAP_DIR-based precondition with a socket-path check so cleanup fails fast when run against a non-framework testnet without explicit faucet address and skey.
Extract the CARDANO_NODE_SOCKET_PATH validation from conftest into helpers so it can be reused by testnet_cleanup and guarded against short paths. Add a faucet.addr existence check and a clearer error when inference is not possible.