-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(contract-e2e): auto-source substrate-contracts-node with e2e tes…
…ts (#254) * feat(contracts-e2e): auto-source contracts-node binary if not present * chore(contract-e2e): deprecate --features e2e-tests * fix: remove unnecessary async function * refactor(contracts-node): reduce duplicated code with binary sourcing (#255) * refactor(up-contract): use Binary struct from parachains -> up -> sourcing to auto-launch contracts-node * refactor(contracts_node): reduce duplicated code -- checkpoint, not working * refactor(contracts_node): use Binary and Source structs for substrate-contracts-node * chore: small changes * chore: small changes * chore: add e2e help, prevent cmd output, and cleanup * refactor(contracts_node): introduce helper to download contracts node if it does not exist * refactor(sourcing): move sourcing functionality to `pop-common` (#258) * refactor(sourcing): move sourcing to pop-common * refactor(sourcing-tests): move sourcing tests to pop-common * refactor(sourcing): better imports * refactor(sourcing): clean sourcing module with better component categorization. Other cleanups * fix: failing tests * fix: needed to download contracts_node for test * fix: add contracts feature, more tests need s c n downloaded * fix: manually create temp dir * fix: append pop_tmp folder in tests * refactor: e2e test improvements (#263) * fix: use async sleep in async context * refactor: remove unnecessary module * refactor: standardise sourcing ux * fix: temp dir issue * chore: component locations, minor improvements --------- Co-authored-by: Frank Bell <[email protected]>
- Loading branch information
1 parent
a2b88f8
commit 5d2a940
Showing
28 changed files
with
921 additions
and
766 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use cliclack::{confirm, log::warning, spinner}; | ||
use pop_contracts::{does_contracts_node_exist, download_contracts_node}; | ||
use std::path::PathBuf; | ||
|
||
/// Helper function to check if the contracts node binary exists, and if not download it. | ||
/// returns: | ||
/// - Some("") if the standalone binary exists | ||
/// - Some(binary_cache_location) if the binary exists in pop's cache | ||
/// - None if the binary does not exist | ||
pub async fn check_contracts_node_and_prompt() -> anyhow::Result<Option<PathBuf>> { | ||
let mut node_path = None; | ||
|
||
// if the contracts node binary does not exist, prompt the user to download it | ||
let maybe_contract_node_path = does_contracts_node_exist(crate::cache()?); | ||
if maybe_contract_node_path == None { | ||
warning("⚠️ The substrate-contracts-node binary is not found.")?; | ||
if confirm("📦 Would you like to source it automatically now?") | ||
.initial_value(true) | ||
.interact()? | ||
{ | ||
let spinner = spinner(); | ||
spinner.start("📦 Sourcing substrate-contracts-node..."); | ||
|
||
let cache_path = crate::cache()?; | ||
let binary = download_contracts_node(cache_path.clone()).await?; | ||
|
||
spinner.stop(format!( | ||
"✅ substrate-contracts-node successfully sourced. Cached at: {}", | ||
binary.path().to_str().unwrap() | ||
)); | ||
node_path = Some(binary.path()); | ||
} | ||
} else { | ||
if let Some(contract_node_path) = maybe_contract_node_path { | ||
// If the node_path is not empty (cached binary). Otherwise, the standalone binary will be used by cargo-contract. | ||
node_path = Some(contract_node_path.0); | ||
} | ||
} | ||
|
||
Ok(node_path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#[cfg(feature = "contract")] | ||
pub mod contracts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.