Skip to content

Commit

Permalink
chore: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexD10S committed Mar 26, 2024
1 parent ef67d36 commit 074670e
Show file tree
Hide file tree
Showing 9 changed files with 237 additions and 198 deletions.
12 changes: 8 additions & 4 deletions src/commands/new/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ mod tests {
#[test]
fn test_new_contract_command_execute_success() -> Result<()> {
let temp_contract_dir = tempfile::tempdir().expect("Could not create temp dir");
let command =
NewContractCommand { name: "test_contract".to_string(), path: Some(PathBuf::from(temp_contract_dir.path())) };
let command = NewContractCommand {
name: "test_contract".to_string(),
path: Some(PathBuf::from(temp_contract_dir.path())),
};
let result = command.execute();
assert!(result.is_ok());

Expand All @@ -76,8 +78,10 @@ mod tests {
#[test]
fn test_new_contract_command_execute_fails_path_no_exist() -> Result<()> {
let temp_contract_dir = tempfile::tempdir().expect("Could not create temp dir");
let command =
NewContractCommand { name: "test_contract".to_string(), path: Some(temp_contract_dir.path().join("new_contract")) };
let command = NewContractCommand {
name: "test_contract".to_string(),
path: Some(temp_contract_dir.path().join("new_contract")),
};
let result_error = command.execute();
assert!(result_error.is_err());
Ok(())
Expand Down
5 changes: 4 additions & 1 deletion src/commands/up/parachain.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::{style::{style, Theme}, parachains::zombienet::Zombienet};
use crate::{
parachains::zombienet::Zombienet,
style::{style, Theme},
};
use clap::Args;
use cliclack::{clear_screen, confirm, intro, log, outro, outro_cancel, set_theme};
use console::{Emoji, Style};
Expand Down
19 changes: 14 additions & 5 deletions src/engines/contract_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ pub async fn dry_run_call(
#[cfg(test)]
mod tests {
use super::*;
use anyhow::{Error, Result};
use std::{fs, path::PathBuf};
use anyhow::{Result, Error};

fn setup_test_environment() -> Result<tempfile::TempDir, Error> {
let temp_contract_dir = tempfile::tempdir().expect("Could not create temp dir");
Expand Down Expand Up @@ -199,7 +199,7 @@ mod tests {

// Verify that the generated Cargo.toml file contains the expected content
fs::read_to_string(temp_contract_dir.path().join("test_contract/Cargo.toml"))
.expect("Could not read file");
.expect("Could not read file");
Ok(())
}

Expand All @@ -213,9 +213,18 @@ mod tests {
// Verify that the folder target has been created
assert!(temp_contract_dir.path().join("test_contract/target").exists());
// Verify that all the artifacts has been generated
assert!(temp_contract_dir.path().join("test_contract/target/ink/test_contract.contract").exists());
assert!(temp_contract_dir.path().join("test_contract/target/ink/test_contract.wasm").exists());
assert!(temp_contract_dir.path().join("test_contract/target/ink/test_contract.json").exists());
assert!(temp_contract_dir
.path()
.join("test_contract/target/ink/test_contract.contract")
.exists());
assert!(temp_contract_dir
.path()
.join("test_contract/target/ink/test_contract.wasm")
.exists());
assert!(temp_contract_dir
.path()
.join("test_contract/target/ink/test_contract.json")
.exists());

Ok(())
}
Expand Down
9 changes: 6 additions & 3 deletions src/engines/parachain_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ mod tests {
let generated_file_content =
fs::read_to_string(temp_dir.path().join("node/src/chain_spec.rs"))
.expect("Failed to read file");
assert!(generated_file_content.contains("properties.insert(\"tokenSymbol\".into(), \"DOT\".into());"));
assert!(generated_file_content.contains("properties.insert(\"tokenDecimals\".into(), 18.into());"));
assert!(generated_file_content
.contains("properties.insert(\"tokenSymbol\".into(), \"DOT\".into());"));
assert!(generated_file_content
.contains("properties.insert(\"tokenDecimals\".into(), 18.into());"));
assert!(generated_file_content.contains("1000000"));

// Verify network.toml contains expected content
Expand All @@ -124,7 +126,8 @@ mod tests {

#[test]
fn test_parachain_build_after_instantiating_template() -> Result<()> {
let temp_dir = setup_template_and_instantiate().expect("Failed to setup template and instantiate");
let temp_dir =
setup_template_and_instantiate().expect("Failed to setup template and instantiate");
let build = build_parachain(&Some(temp_dir.path().to_path_buf()));
assert!(build.is_ok(), "Result should be Ok");
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ impl GitHub {
pub(crate) fn release(repo: &Url, tag: &str, artifact: &str) -> String {
format!("{}/releases/download/{tag}/{artifact}", repo.as_str())
}
}
}
2 changes: 1 addition & 1 deletion src/parachains/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub(crate) mod zombienet;
pub(crate) mod zombienet;
Loading

0 comments on commit 074670e

Please sign in to comment.