Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(adex-cli): remove activation scheme before testing #1920

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
laruh marked this conversation as resolved.
Show resolved Hide resolved
}

#[tokio::test]
Expand Down