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: check_contracts_node handles skip_confirm #396

Merged
merged 2 commits into from
Jan 3, 2025
Merged
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
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
Loading