Use is_amount clap validator (#7400)

* Fix up is_amount to handle floats for SOL; expand amount_of test

* Use required_lamports_from and is_amount across CLI

* Remove obsolete test (now handled by clap)
This commit is contained in:
Tyera Eulberg
2019-12-10 11:29:17 -07:00
committed by GitHub
parent 6f457292ff
commit 11521dca08
6 changed files with 49 additions and 23 deletions

View File

@@ -216,11 +216,18 @@ mod tests {
.clone()
.get_matches_from(vec!["test", "--single", "50", "--unit", "lamports"]);
assert_eq!(amount_of(&matches, "single", "unit"), Some(50));
assert_eq!(amount_of(&matches, "multiple", "unit"), None);
let matches = app()
.clone()
.get_matches_from(vec!["test", "--single", "50", "--unit", "SOL"]);
assert_eq!(amount_of(&matches, "single", "unit"), Some(50000000000));
assert_eq!(amount_of(&matches, "multiple", "unit"), None);
assert_eq!(amount_of(&matches, "multiple", "unit"), None);
let matches = app()
.clone()
.get_matches_from(vec!["test", "--single", "1.5", "--unit", "SOL"]);
assert_eq!(amount_of(&matches, "single", "unit"), Some(1500000000));
let matches = app()
.clone()
.get_matches_from(vec!["test", "--single", "1.5", "--unit", "lamports"]);
assert_eq!(amount_of(&matches, "single", "unit"), None);
}
}