diff --git a/src/transaction/creation_common.rs b/src/transaction/creation_common.rs index f55d5eb1..4e29bde7 100644 --- a/src/transaction/creation_common.rs +++ b/src/transaction/creation_common.rs @@ -741,7 +741,7 @@ pub(super) mod is_install_upgrade { } pub fn get(matches: &ArgMatches) -> bool { - matches.args_present() + matches.get_flag(ARG_NAME) } } @@ -1964,3 +1964,36 @@ pub(super) fn parse_rpc_args_and_run( verbosity_level, )) } + +#[cfg(test)] +mod tests { + use super::is_install_upgrade; + use clap::Command; + + // Helper function to build a command with `is_install_upgrade` argument + fn build_app() -> Command { + Command::new("put-transaction session").arg(is_install_upgrade::arg(1)) + } + + #[test] + fn test_is_install_upgrade_flag_present() { + // Simulate running with the `--install-upgrade` flag + let matches = build_app() + .try_get_matches_from(vec!["put-transaction session", "--install-upgrade"]) + .unwrap(); + + // Assert that `get` returns true when the flag is present + assert!(is_install_upgrade::get(&matches)); + } + + #[test] + fn test_is_install_upgrade_flag_absent() { + // Simulate running without the `--install-upgrade` flag + let matches = build_app() + .try_get_matches_from(vec!["put-transaction session"]) + .unwrap(); + + // Assert that `get` returns false when the flag is absent + assert!(!is_install_upgrade::get(&matches)); + } +} diff --git a/src/transaction/put.rs b/src/transaction/put.rs index fe209e0a..2150a47c 100644 --- a/src/transaction/put.rs +++ b/src/transaction/put.rs @@ -18,10 +18,7 @@ const ALIAS: &str = "put-txn"; impl ClientCommand for PutTransaction { const NAME: &'static str = "put-transaction"; - const ABOUT: &'static str = - "Create a transaction and output it to a file or stdout. As a file, the transaction can subsequently \ - be signed by other parties using the 'sign-transaction' subcommand and then sent to the network \ - for execution using the 'send-transaction' subcommand"; + const ABOUT: &'static str = "Create a transaction and send it to the network for execution"; fn build(display_order: usize) -> Command { Command::new(Self::NAME) diff --git a/src/transaction/send.rs b/src/transaction/send.rs index 86cb7082..7a1f7307 100644 --- a/src/transaction/send.rs +++ b/src/transaction/send.rs @@ -15,7 +15,7 @@ const ALIAS: &str = "send-txn"; impl ClientCommand for SendTransaction { const NAME: &'static str = "send-transaction"; const ABOUT: &'static str = - "Read a previously-saved deploy from a file and send it to the network for execution"; + "Read a previously-saved transaction from a file and send it to the network for execution"; fn build(display_order: usize) -> Command { Command::new(Self::NAME)