Fixing unlock parsing (#1802)
This commit is contained in:
parent
326a51a5c2
commit
b165059327
@ -102,7 +102,7 @@ pub fn to_address(s: Option<String>) -> Result<Address, String> {
|
|||||||
|
|
||||||
pub fn to_addresses(s: &Option<String>) -> Result<Vec<Address>, String> {
|
pub fn to_addresses(s: &Option<String>) -> Result<Vec<Address>, String> {
|
||||||
match *s {
|
match *s {
|
||||||
Some(ref adds) if adds.is_empty() => adds.split(',')
|
Some(ref adds) if !adds.is_empty() => adds.split(',')
|
||||||
.map(|a| clean_0x(a).parse().map_err(|_| format!("Invalid address: {:?}", a)))
|
.map(|a| clean_0x(a).parse().map_err(|_| format!("Invalid address: {:?}", a)))
|
||||||
.collect(),
|
.collect(),
|
||||||
_ => Ok(Vec::new()),
|
_ => Ok(Vec::new()),
|
||||||
@ -299,7 +299,7 @@ mod tests {
|
|||||||
use util::{U256};
|
use util::{U256};
|
||||||
use ethcore::client::{Mode, BlockID};
|
use ethcore::client::{Mode, BlockID};
|
||||||
use ethcore::miner::PendingSet;
|
use ethcore::miner::PendingSet;
|
||||||
use super::{to_duration, to_mode, to_block_id, to_u256, to_pending_set, to_address, to_price, geth_ipc_path, to_bootnodes};
|
use super::{to_duration, to_mode, to_block_id, to_u256, to_pending_set, to_address, to_addresses, to_price, geth_ipc_path, to_bootnodes};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_to_duration() {
|
fn test_to_duration() {
|
||||||
@ -370,6 +370,18 @@ mod tests {
|
|||||||
assert_eq!(to_address(None).unwrap(), Default::default());
|
assert_eq!(to_address(None).unwrap(), Default::default());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_to_addresses() {
|
||||||
|
let addresses = to_addresses(&Some("0xD9A111feda3f362f55Ef1744347CDC8Dd9964a41,D9A111feda3f362f55Ef1744347CDC8Dd9964a42".into())).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
addresses,
|
||||||
|
vec![
|
||||||
|
"D9A111feda3f362f55Ef1744347CDC8Dd9964a41".parse().unwrap(),
|
||||||
|
"D9A111feda3f362f55Ef1744347CDC8Dd9964a42".parse().unwrap(),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(feature = "dev", allow(float_cmp))]
|
#[cfg_attr(feature = "dev", allow(float_cmp))]
|
||||||
fn test_to_price() {
|
fn test_to_price() {
|
||||||
|
@ -311,7 +311,7 @@ fn prepare_account_provider(dirs: &Directories, cfg: AccountsConfig) -> Result<A
|
|||||||
|
|
||||||
for a in cfg.unlocked_accounts {
|
for a in cfg.unlocked_accounts {
|
||||||
if passwords.iter().find(|p| account_service.unlock_account_permanently(a, (*p).clone()).is_ok()).is_none() {
|
if passwords.iter().find(|p| account_service.unlock_account_permanently(a, (*p).clone()).is_ok()).is_none() {
|
||||||
return Err(format!("No password given to unlock account {}. Pass the password using `--password`.", a));
|
return Err(format!("No password found to unlock account {}. Make sure valid password is present in files passed using `--password`.", a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user