Skip to content

Commit

Permalink
fix(adex-cli): fix test_activation_scheme by removing old file (#1920)
Browse files Browse the repository at this point in the history
  • Loading branch information
rozhkovdmitrii authored Jul 18, 2023
1 parent 0dcaeea commit e72a0ab
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub(crate) async fn init_activation_scheme() -> Result<()> {
.map_err(|error| error_anyhow!("Failed to write activation_scheme: {error}"))
}

pub(super) fn get_activation_scheme_path() -> Result<PathBuf> {
pub(crate) fn get_activation_scheme_path() -> Result<PathBuf> {
let mut config_path = AdexConfigImpl::get_config_dir()?;
config_path.push(ACTIVATION_SCHEME_FILE);
Ok(config_path)
Expand Down
2 changes: 2 additions & 0 deletions mm2src/adex_cli/src/activation_scheme_db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ mod activation_scheme_impl;
mod init_activation_scheme;

pub(super) use activation_scheme_impl::get_activation_scheme;
#[cfg(test)]
pub(super) use init_activation_scheme::get_activation_scheme_path;
pub(super) use init_activation_scheme::init_activation_scheme;
2 changes: 1 addition & 1 deletion mm2src/adex_cli/src/adex_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl AdexConfigImpl {
Ok(config_path)
}

fn get_config_path() -> Result<PathBuf> {
pub(crate) fn get_config_path() -> Result<PathBuf> {
let mut config_path = Self::get_config_dir()?;
config_path.push(ADEX_CFG);
Ok(config_path)
Expand Down
5 changes: 3 additions & 2 deletions mm2src/adex_cli/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::time::Duration;
use tokio::io::AsyncWriteExt;
use tokio::net::{TcpListener, TcpStream};

use crate::activation_scheme_db::{get_activation_scheme, init_activation_scheme};
use crate::activation_scheme_db::{get_activation_scheme, get_activation_scheme_path, init_activation_scheme};
use crate::adex_config::AdexConfigImpl;
use crate::adex_proc::ResponseHandlerImpl;
use crate::cli::Cli;
Expand Down Expand Up @@ -142,13 +142,14 @@ async fn test_enable() {
}

async fn test_activation_scheme() {
let _ = std::fs::remove_file(get_activation_scheme_path().unwrap());
init_activation_scheme().await.unwrap();
let scheme = get_activation_scheme().unwrap();
let kmd_scheme = scheme.get_activation_method("KMD");
assert!(kmd_scheme.is_some());
let kmd_scheme = kmd_scheme.unwrap();
assert_eq!(kmd_scheme.get("method").unwrap().as_str().unwrap(), "electrum");
assert_eq!(kmd_scheme.get("servers").unwrap().as_array().unwrap().iter().count(), 3);
assert_ne!(kmd_scheme.get("servers").unwrap().as_array().unwrap().iter().count(), 0);
}

#[tokio::test]
Expand Down

0 comments on commit e72a0ab

Please sign in to comment.