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

Skip download #78

Merged
merged 2 commits into from
Apr 4, 2024
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
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ categories = ["cryptography::cryptocurrencies", "development-tools::testing"]
[dependencies]
bitcoind = { version = "0.34.0" }
electrum-client = { version = "0.19.0", default-features = false }
nix = { version = "0.25.0" }
log = "0.4"
which = "4.2.5"

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ if let Ok(exe_path) = electrsd::exe_path() {

Startup options could be configured via the `Conf` struct using `electrsD::with_conf` or `electrsD::from_downloaded_with_conf`.

## Nix

For determinisim, in nix you cannot hit the internet within the `build.rs`. Moreover, some downstream crates cannot remove the auto-download feature from their dev-deps. In this case you can set the `ELECTRSD_SKIP_DOWNLOAD` env var and provide the electrs executable in the `PATH` (or skip the test execution).

## Issues with traditional approach

I used integration testing based on external bash script launching needed external processes, there are many issues with this approach like:
Expand Down
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ mod download {
}

pub fn download() {
if std::env::var_os("ELECTRSD_SKIP_DOWNLOAD").is_some() {
return;
}

if !HAS_FEATURE {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ impl Drop for ElectrsD {
}
}

/// Provide the electrs executable path if a version feature has been specified
/// Provide the electrs executable path if a version feature has been specified and `ELECTRSD_SKIP_DOWNLOAD` is not set.
pub fn downloaded_exe_path() -> Option<String> {
if versions::HAS_FEATURE {
if versions::HAS_FEATURE && std::env::var_os("ELECTRSD_SKIP_DOWNLOAD").is_none() {
Some(format!(
"{}/electrs/{}/electrs",
env!("OUT_DIR"),
Expand Down
Loading