From 2705c124d68b70d1346edee23dc140a4cb138748 Mon Sep 17 00:00:00 2001 From: Martin Kourim Date: Thu, 21 Nov 2024 17:58:04 +0100 Subject: [PATCH] fix(testnet_cleanup): update argument requirements - Removed required constraints for address and skey-file arguments to retain backwards compatibility - Added validation to ensure both or neither are provided - Require address and skey-file arguments when BOOTSTRAP_DIR env variable is not set --- cardano_node_tests/testnet_cleanup.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cardano_node_tests/testnet_cleanup.py b/cardano_node_tests/testnet_cleanup.py index 27e6ddee7..c543d18fb 100755 --- a/cardano_node_tests/testnet_cleanup.py +++ b/cardano_node_tests/testnet_cleanup.py @@ -34,13 +34,11 @@ def get_args() -> argparse.Namespace: parser.add_argument( "-f", "--address", - required=True, help="Faucet address", ) parser.add_argument( "-s", "--skey-file", - required=True, type=helpers.check_file_arg, help="Path to faucet skey file", ) @@ -58,8 +56,15 @@ def main() -> int: if not socket_env: LOGGER.error("The `CARDANO_NODE_SOCKET_PATH` environment variable is not set.") return 1 - if not os.environ.get("BOOTSTRAP_DIR"): - LOGGER.error("The `BOOTSTRAP_DIR` environment variable is not set.") + if bool(args.address) ^ bool(args.skey_file): + LOGGER.error( + "Both address and skey file must be provided, or neither of them should be provided." + ) + return 1 + if not (args.address or os.environ.get("BOOTSTRAP_DIR")): + LOGGER.error( + "The address must be provided, or `BOOTSTRAP_DIR` environment variable must be set." + ) return 1 state_dir = pl.Path(socket_env).parent