diff --git a/crates/esplora/tests/async_ext.rs b/crates/esplora/tests/async_ext.rs index e8ce24d064..a1eea7ba92 100644 --- a/crates/esplora/tests/async_ext.rs +++ b/crates/esplora/tests/async_ext.rs @@ -123,23 +123,3 @@ pub async fn test_update_tx_graph_without_keychain() -> anyhow::Result<()> { assert_eq!(graph_update_txids, expected_txids); Ok(()) } -#[test] -fn simple_test() -> anyhow::Result<()> { - let bitcoind_exe = - bitcoind::exe_path().expect("Cannot find bitcoind daemon, set BITCOIND_EXEC environment variable with the path to bitcoind"); - let mut bitcoind_conf = bitcoind::Conf::default(); - bitcoind_conf.p2p = bitcoind::P2P::Yes; - let bitcoind = BitcoinD::with_conf(&bitcoind_exe, &bitcoind_conf)?; - - let mut electrs_conf = Conf::default(); - electrs_conf.http_enabled = true; - let electrs_exe = electrsd::exe_path().expect("Cannot find electrs daemon, set ELECTRS_EXEC environment variable with the path to electrs"); - let electrsd = ElectrsD::with_conf(&electrs_exe, &bitcoind, &electrs_conf)?; - - // Alive checks - let _ = bitcoind.client.ping().unwrap(); // without using bitcoind, it is dropped and all the rest fails. - let _ = electrsd.client.ping().unwrap(); - assert!(bitcoind.client.ping().is_ok()); - assert!(electrsd.client.ping().is_ok()); - Ok(()) -} diff --git a/flake.nix b/flake.nix index ecf6c9d617..ab0d804033 100644 --- a/flake.nix +++ b/flake.nix @@ -32,12 +32,45 @@ let overlays = [ (import rust-overlay) ]; lib = pkgs.lib; + stdenv = pkgs.stdenv; + isDarwin = stdenv.isDarwin; + libsDarwin = with pkgs.darwin.apple_sdk.frameworks; [ + # Additional darwin specific inputs can be set here + Security + SystemConfiguration + CoreServices + ]; + pkgs = import nixpkgs { inherit system overlays; }; pkgs-bitcoind = import nixpkgs-bitcoind { inherit system overlays; }; + # pin electrs to a specific version + # pinned to esplora_a33e97e1 + electrs_base_url = "https://github.com/RCasatta/electrsd/releases/download/electrs_releases/"; + electrs_url = + if isDarwin then + electrs_base_url + "electrs_macos_esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254.zip" + else + electrs_base_url + "electrs_linux_esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254.zip"; + electrs_hash = + if isDarwin then + "sha256-xfkllY8ovVih469hJuw+GTcf2kZ0g0JAK8diEh5FFsw=" + else + lib.fakeHash; + electrs = stdenv.mkDerivation { + name = "electrs"; + src = pkgs.fetchzip { + url = electrs_url; + hash = electrs_hash; + }; + installPhase = '' + mkdir -p $out/bin + cp electrs $out/bin + ''; + }; # Toolchains # latest stable @@ -67,18 +100,13 @@ buildInputs = [ # Add additional build inputs here pkgs-bitcoind.bitcoind - pkgs.electrs + electrs pkgs.openssl pkgs.openssl.dev pkgs.pkg-config pkgs.curl pkgs.libiconv - ] ++ lib.optionals pkgs.stdenv.isDarwin [ - # Additional darwin specific inputs can be set here - pkgs.darwin.apple_sdk.frameworks.Security - pkgs.darwin.apple_sdk.frameworks.SystemConfiguration - pkgs.darwin.apple_sdk.frameworks.CoreServices - ]; + ] ++ lib.optionals isDarwin libsDarwin; # WASM deps wasmInputs = [ @@ -89,7 +117,7 @@ nativeBuildInputs = [ # Add additional build inputs here pkgs.python3 - ] ++ lib.optionals pkgs.stdenv.isDarwin [ + ] ++ lib.optionals isDarwin [ # Additional darwin specific native inputs can be set here ]; @@ -118,7 +146,7 @@ inherit nativeBuildInputs; # Additional environment variables can be set directly BITCOIND_EXEC = "${pkgs.bitcoind}/bin/bitcoind"; - ELECTRS_EXEC = "${pkgs.electrs}/bin/electrs"; + ELECTRS_EXEC = "${electrs}/bin/electrs"; }; # MSRV derivation arguments