Skip to content

Commit

Permalink
arg install-upgrade bug (#196)
Browse files Browse the repository at this point in the history
* arg install-upgrade bug

* wrong doc

* typo

* Repalce deploy to transaction in send command help
  • Loading branch information
gRoussac authored Oct 31, 2024
1 parent 08bf74d commit 4c205fa
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
35 changes: 34 additions & 1 deletion src/transaction/creation_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ pub(super) mod is_install_upgrade {
}

pub fn get(matches: &ArgMatches) -> bool {
matches.args_present()
matches.get_flag(ARG_NAME)
}
}

Expand Down Expand Up @@ -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));
}
}
5 changes: 1 addition & 4 deletions src/transaction/put.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/transaction/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4c205fa

Please sign in to comment.