Skip to content

Commit

Permalink
fix: check_contracts_node handles skip_confirm (#396)
Browse files Browse the repository at this point in the history
* fix: check_contracts_node_handles_skip_confirm

* style: remove unused import
  • Loading branch information
al3mart authored Jan 3, 2025
1 parent cbf722a commit ca1cd92
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions crates/pop-cli/src/common/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ pub async fn check_contracts_node_and_prompt(
let mut node_path = binary.path();
if !binary.exists() {
cli.warning("⚠️ The substrate-contracts-node binary is not found.")?;
if cli
.confirm("📦 Would you like to source it automatically now?")
.initial_value(true)
.interact()?
{
let latest = if !skip_confirm {
cli.confirm("📦 Would you like to source it automatically now?")
.initial_value(true)
.interact()?
} else {
true
};
if latest {
let spinner = spinner();
spinner.start("📦 Sourcing substrate-contracts-node...");

Expand Down Expand Up @@ -174,6 +177,21 @@ mod tests {
cli.verify()
}

#[tokio::test]
async fn check_contracts_node_and_prompt_handles_skip_confirm() -> anyhow::Result<()> {
let cache_path = tempfile::tempdir().expect("Could create temp dir");
let mut cli =
MockCli::new().expect_warning("⚠️ The substrate-contracts-node binary is not found.");

let node_path = check_contracts_node_and_prompt(&mut cli, cache_path.path(), true).await?;
// Binary path is at least equal to the cache path + "substrate-contracts-node".
assert!(node_path
.to_str()
.unwrap()
.starts_with(&cache_path.path().join("substrate-contracts-node").to_str().unwrap()));
cli.verify()
}

#[tokio::test]
async fn node_is_terminated() -> anyhow::Result<()> {
let cache = tempfile::tempdir().expect("Could not create temp dir");
Expand Down

0 comments on commit ca1cd92

Please sign in to comment.