mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-24 23:19:34 -05:00
Simplify ASB initial setup signature
This commit is contained in:
parent
7f8af7926d
commit
cfa85e0bad
@ -180,12 +180,8 @@ pub fn read_config(config_path: PathBuf) -> Result<Result<Config, ConfigNotIniti
|
|||||||
Ok(Ok(file))
|
Ok(Ok(file))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn initial_setup<F>(config_path: PathBuf, config_file: F, testnet: bool) -> Result<()>
|
pub fn initial_setup(config_path: PathBuf, config: Config) -> Result<()> {
|
||||||
where
|
let toml = toml::to_string(&config)?;
|
||||||
F: Fn(bool) -> Result<Config>,
|
|
||||||
{
|
|
||||||
let initial_config = config_file(testnet)?;
|
|
||||||
let toml = toml::to_string(&initial_config)?;
|
|
||||||
|
|
||||||
ensure_directory_exists(config_path.as_path())?;
|
ensure_directory_exists(config_path.as_path())?;
|
||||||
fs::write(&config_path, toml)?;
|
fs::write(&config_path, toml)?;
|
||||||
@ -352,7 +348,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
initial_setup(config_path.clone(), |_| Ok(expected.clone()), false).unwrap();
|
initial_setup(config_path.clone(), expected.clone()).unwrap();
|
||||||
let actual = read_config(config_path).unwrap().unwrap();
|
let actual = read_config(config_path).unwrap().unwrap();
|
||||||
|
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
@ -392,7 +388,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
initial_setup(config_path.clone(), |_| Ok(expected.clone()), true).unwrap();
|
initial_setup(config_path.clone(), expected.clone()).unwrap();
|
||||||
let actual = read_config(config_path).unwrap().unwrap();
|
let actual = read_config(config_path).unwrap().unwrap();
|
||||||
|
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
|
@ -63,7 +63,7 @@ async fn main() -> Result<()> {
|
|||||||
let config = match read_config(config_path.clone())? {
|
let config = match read_config(config_path.clone())? {
|
||||||
Ok(config) => config,
|
Ok(config) => config,
|
||||||
Err(ConfigNotInitialized {}) => {
|
Err(ConfigNotInitialized {}) => {
|
||||||
initial_setup(config_path.clone(), query_user_for_initial_config, testnet)?;
|
initial_setup(config_path.clone(), query_user_for_initial_config(testnet)?)?;
|
||||||
read_config(config_path)?.expect("after initial setup config can be read")
|
read_config(config_path)?.expect("after initial setup config can be read")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user