Skip to content

Commit 9ab0e9b

Browse files
committed
upgrade Readme.md
1 parent d269bdd commit 9ab0e9b

1 file changed

Lines changed: 40 additions & 16 deletions

File tree

Readme.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,40 @@ let bitcoind = bitcoind::BitcoinD::new("/usr/local/bin/bitcoind").unwrap();
1111
assert_eq!(0, bitcoind.client.get_blockchain_info().unwrap().blocks);
1212
```
1313

14+
## Automatic binaries download
15+
16+
When a feature like `22_0` is selected, the build script will automatically download the bitcoin core version `22.0`, verify the hashes and place it in the build directory for this crate.
17+
Use utility function `downloaded_exe_path()` to get the downloaded executable path.
18+
19+
### Example
20+
21+
In your project Cargo.toml, activate the following features
22+
23+
```toml
24+
25+
[dev-dependencies]
26+
bitcoind = { version = "0.20.0", features = "22_0" }
27+
```
28+
29+
Then use it:
30+
31+
```rust
32+
let bitcoind = bitcoind::BitcoinD::new(bitcoind::downloaded_exe_path().unwrap()).unwrap();
33+
```
34+
1435
## MSRV
1536

1637
1.41.1
1738

39+
## Issues with traditional approach
40+
41+
I used integration testing based on external bash script launching needed external processes, there are many issues with this approach like:
42+
43+
* External script may interfere with local development environment https://github.com/rust-bitcoin/rust-bitcoincore-rpc/blob/200fc8247c1896709a673b82a89ca0da5e7aa2ce/integration_test/run.sh#L9
44+
* Use of a single huge test to test everything https://github.com/rust-bitcoin/rust-bitcoincore-rpc/blob/200fc8247c1896709a673b82a89ca0da5e7aa2ce/integration_test/src/main.rs#L122-L203
45+
* If test are separated, a failing test may fail to leave a clean situation, causing other test to fail (because of the initial situation, not a real failure)
46+
* bash script are hard, especially support different OS and versions
47+
1848
## Features
1949

2050
* It waits until bitcoind daemon become ready to accept RPC commands
@@ -23,25 +53,19 @@ assert_eq!(0, bitcoind.client.get_blockchain_info().unwrap().blocks);
2353
* the process is killed when the struct goes out of scope no matter how the test finishes
2454
* allows easy spawning of dependent process like https://github.com/RCasatta/electrsd
2555

26-
## Cargo features
56+
Thanks to these features every `#[test]` could easily run isolated with its own environment.
2757

28-
When a feature like `0_21_1` is selected, the build script will automatically download the bitcoin core version 0.21.1
29-
and verify the hashes and place it in the build directory for this crate.
30-
Use utility function `downloaded_exe_path()` to get the downloaded executable path.
58+
## Used by
3159

32-
### Example
60+
* [firma](https://github.com/RCasatta/firma/)
61+
* [payjoin](https://github.com/Kixunil/payjoin)
3362

34-
##### Cargo.toml
63+
### Via bdk dependency
3564

36-
```toml
65+
* [gun](https://github.com/LLFourn/gun)
3766

38-
[dev-dependencies]
39-
bitcoind = { version = "0.12.0", features = "0_21_1" }
40-
```
41-
42-
#### In your tests
43-
44-
```rust
45-
let bitcoind = bitcoind::BitcoinD::new(bitcoind::downloaded_exe_path().unwrap()).unwrap();
46-
```
67+
### Via electrsd dependency:
4768

69+
* [bdk](https://github.com/bitcoindevkit/bdk)
70+
* [BEWallet](https://github.com/LeoComandini/BEWallet)
71+
* [gdk rust](https://github.com/Blockstream/gdk/blob/master/subprojects/gdk_rust/)

0 commit comments

Comments
 (0)