Skip to content

Commit 1f59c75

Browse files
authored
Merge pull request hyperledger-indy#859 from Artemkaaas/bugfix/fee-proccesing
Cli fixed parsing fees string
2 parents f5385d8 + 76426d6 commit 1f59c75

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

cli/src/commands/ledger.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,9 +1079,6 @@ fn set_request_fees(request: &mut String, wallet_handle: i32, submitter_did: &st
10791079
}
10801080

10811081
fn parse_payment_inputs(inputs: &Vec<&str>) -> Result<String, ()> {
1082-
if inputs.is_empty() {
1083-
return Err(println_err!("Inputs list is empty"));
1084-
}
10851082
serde_json::to_string(&inputs)
10861083
.map_err(|_| println_err!("Wrong data has been received"))
10871084
}
@@ -3433,6 +3430,28 @@ pub mod tests {
34333430
TestUtils::cleanup_storage();
34343431
}
34353432

3433+
#[test]
3434+
pub fn set_fees_prepare_works_for_empty_fees() {
3435+
TestUtils::cleanup_storage();
3436+
let ctx = CommandContext::new();
3437+
3438+
create_and_connect_pool(&ctx);
3439+
create_and_open_wallet(&ctx);
3440+
load_null_payment_plugin(&ctx);
3441+
new_did(&ctx, SEED_TRUSTEE);
3442+
use_did(&ctx, DID_TRUSTEE);
3443+
{
3444+
let cmd = set_fees_prepare_command::new();
3445+
let mut params = CommandParams::new();
3446+
params.insert("payment_method", NULL_PAYMENT_METHOD.to_string());
3447+
params.insert("fees", "".to_string());
3448+
cmd.execute(&ctx, &params).unwrap_err();
3449+
}
3450+
close_and_delete_wallet(&ctx);
3451+
disconnect_and_delete_pool(&ctx);
3452+
TestUtils::cleanup_storage();
3453+
}
3454+
34363455
#[test]
34373456
pub fn set_fees_prepare_works_for_no_active_wallet() {
34383457
TestUtils::cleanup_storage();

cli/src/commands/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ pub fn get_opt_bool_param(key: &str, params: &CommandParams) -> Result<Option<bo
8888

8989
pub fn get_str_array_param<'a>(name: &'a str, params: &'a CommandParams) -> Result<Vec<&'a str>, ()> {
9090
match params.get(name) {
91-
Some(v) => Ok(if v.is_empty() {Vec::new()} else { v.split(",").collect::<Vec<&'a str>>() }),
92-
None => Err(println_err!("No required \"{}\" parameter present", name))
91+
None => Err(println_err!("No required \"{}\" parameter present", name)),
92+
Some(v) if v.is_empty() => Err(println_err!("No required \"{}\" parameter present", name)),
93+
Some(v) => Ok(v.split(",").collect::<Vec<&'a str>>())
9394
}
9495
}
9596

0 commit comments

Comments
 (0)