Skip to content

fix(cleanup): validate faucet args for non-framework testnets#3424

Merged
mkoura merged 1 commit intomasterfrom
more_robust_testnet_cleanup
Apr 17, 2026
Merged

fix(cleanup): validate faucet args for non-framework testnets#3424
mkoura merged 1 commit intomasterfrom
more_robust_testnet_cleanup

Conversation

@mkoura
Copy link
Copy Markdown
Collaborator

@mkoura mkoura commented Apr 17, 2026

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.

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.
@mkoura mkoura requested a review from saratomaz as a code owner April 17, 2026 12:11
@mkoura mkoura requested review from Copilot and removed request for saratomaz April 17, 2026 12:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_PATH validation from conftest.py into utils/helpers.py (with added guarding for short/invalid paths).
  • Add is_framework_testnet() and tighten faucet inference behavior in utils/testnet_cleanup.py (including faucet.addr existence check).
  • Update the standalone cardano_node_tests/testnet_cleanup.py CLI 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, but testnet_cleanup.cleanup() can still raise FileNotFoundError/ValueError when inference fails (e.g., missing faucet.addr/keys). Since main() doesn’t catch those, the script can exit with a stack trace instead of a clean log message + return code. Suggest wrapping the cleanup(...) 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.

Comment thread cardano_node_tests/utils/testnet_cleanup.py
@mkoura mkoura merged commit 4fcc12f into master Apr 17, 2026
7 checks passed
@mkoura mkoura deleted the more_robust_testnet_cleanup branch April 17, 2026 12:48
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.

2 participants