Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit bc2870f

Browse files
authored
Merge pull request #8 from tcharding/06-17-docs
regtest: Try to fix docs
2 parents 04cae1e + ef2a501 commit bc2870f

8 files changed

+33
-50
lines changed

Cargo-minimal.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ dependencies = [
8686

8787
[[package]]
8888
name = "bitcoind-json-rpc-client"
89-
version = "0.2.0"
89+
version = "0.2.1"
9090
dependencies = [
9191
"bitcoin",
9292
"bitcoind-json-rpc-types",

Cargo-recent.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ dependencies = [
8686

8787
[[package]]
8888
name = "bitcoind-json-rpc-client"
89-
version = "0.2.0"
89+
version = "0.2.1"
9090
dependencies = [
9191
"bitcoin",
9292
"bitcoind-json-rpc-types",

regtest/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 0.2.1 - 2024-06-17
2+
3+
Do various little fixes to try and make the docs on `Client` more legible, specifically to alleviate
4+
confusion around the flag on `docs.rs` that says "Available on crate feature 26_0 only."
5+
16
# 0.2.0 - 2024-06-13
27

38
- Use Bitcoin Core 0.17.1 (0.17.2 seems to not exist and have been a mistake).

regtest/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bitcoind-json-rpc-regtest"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
authors = ["Riccardo Casatta <[email protected]>", "Tobin C. Harding <[email protected]>"]
55
license = "MIT"
66
repository = "https://github.com/tcharding/rust-bitcoind-json-rpc"
@@ -65,7 +65,7 @@ anyhow = "1.0.66"
6565

6666

6767
[package.metadata.docs.rs]
68-
features = ["download", "doc"]
68+
features = ["download", "doc", "26_0"]
6969
rustdoc-args = ["--cfg", "docsrs"]
7070

7171
[patch.crates-io.bitcoind-json-rpc-client]

regtest/README.md

Lines changed: 14 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
[![MIT license](https://img.shields.io/github/license/RCasatta/bitcoind)](https://github.com/RCasatta/bitcoind/blob/master/LICENSE)
2-
[![Crates](https://img.shields.io/crates/v/bitcoind.svg)](https://crates.io/crates/bitcoind)
3-
[![Docs](https://img.shields.io/badge/docs.rs-bitcoind-green)](https://docs.rs/bitcoind)
4-
51
# Bitcoind
62

73
Utility to run a regtest bitcoind process, useful in integration testing environment.
@@ -19,8 +15,7 @@ for bitcoin core 25.1, starting a regtest node is as simple as that:
1915
```
2016

2117
The build script will automatically download the bitcoin core version 25.1 from [bitcoin core](https://bitcoincore.org),
22-
verify the hashes and place it in the build directory for this crate. If you wish to download from an
23-
alternate location, for example locally for CI, use the `BITCOIND_DOWNLOAD_ENDPOINT` env var.
18+
verify the binary hash and place it in the build directory for this crate.
2419

2520
When you don't use the auto-download feature you have the following options:
2621

@@ -37,22 +32,15 @@ if let Ok(exe_path) = bitcoind::exe_path() {
3732
Startup options could be configured via the [`Conf`] struct using [`BitcoinD::with_conf`] or
3833
[`BitcoinD::from_downloaded_with_conf`]
3934

40-
## Issues with traditional approach
41-
42-
I used integration testing based on external bash script launching needed external processes, there
43-
are many issues with this approach like:
44-
45-
* External script may interfere with local development environment [1](https://github.com/rust-bitcoin/rust-bitcoincore-rpc/blob/200fc8247c1896709a673b82a89ca0da5e7aa2ce/integration_test/run.sh#L9)
46-
* Use of a single huge test to test everything [2](https://github.com/rust-bitcoin/rust-bitcoincore-rpc/blob/200fc8247c1896709a673b82a89ca0da5e7aa2ce/integration_test/src/main.rs#L122-L203)
47-
* 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)
48-
* bash script are hard, especially support different OS and versions
49-
5035
## Features
5136

52-
* It waits until bitcoind daemon become ready to accept RPC commands
53-
* `bitcoind` use a temporary directory as datadir. You can specify the root of your temp directories so that you have node's datadir in a RAM disk (eg `/dev/shm`)
54-
* Free ports are asked to the OS. Since you can't reserve the given port, a low probability race condition is still possible, for this reason the process is tried to be spawn 3 times with different ports.
55-
* The process is killed when the struct goes out of scope no matter how the test finishes
37+
* Waits until bitcoind daemon becomes ready to accept RPC commands
38+
* `bitcoind` uses a temporary directory as datadir. You can specify the root of your temp
39+
directories so that you have the node's datadir in a RAM disk (eg `/dev/shm`)
40+
* Free ports are requested from the OS. Since you can't reserve the given port, a low probability
41+
race condition is still possible, for this reason the process attempts spawning 3 times with
42+
different ports.
43+
* The process is killed when the struct goes out of scope no matter how the test finishes.
5644
* Allows easy spawning of dependent processes like:
5745
- [electrs](https://github.com/RCasatta/electrsd)
5846
- [cln](https://github.com/RCasatta/lightningd)
@@ -85,28 +73,11 @@ Pinning in `Cargo.toml` is avoided because it could cause compilation issues dow
8573

8674
## Nix
8775

88-
For reproducibility reasons, Nix build scripts cannot hit the internet, but the
89-
auto-download feature does exactly that. To successfully build under Nix the
90-
user must provide the tarball locally and specify its location via the
91-
`BITCOIND_TARBALL_FILE` env var.
92-
93-
Another option is to specify the `BITCOIND_SKIP_DOWNLOAD` env var and provide the
94-
executable via the `PATH`.
95-
96-
Alternatively, use the dep without auto-download feature.
97-
98-
## Used by
99-
100-
* [firma](https://github.com/RCasatta/firma/)
101-
* [payjoin](https://github.com/Kixunil/payjoin)
102-
* [rust-miniscript](https://github.com/rust-bitcoin/rust-miniscript/tree/4a3ba11c2fd5063be960741d557f3f7a28041e1f/bitcoind-tests)
103-
104-
### Via bdk dependency
105-
106-
* [gun](https://github.com/LLFourn/gun)
76+
For reproducibility reasons, Nix build scripts cannot hit the internet, but the auto-download
77+
feature does exactly that. To successfully build under Nix the user must provide the tarball locally
78+
and specify its location via the `BITCOIND_TARBALL_FILE` env var.
10779

108-
### Via electrsd dependency:
80+
Another option is to specify the `BITCOIND_SKIP_DOWNLOAD` env var and provide the executable via the
81+
`PATH`.
10982

110-
* [bdk](https://github.com/bitcoindevkit/bdk)
111-
* [BEWallet](https://github.com/LeoComandini/BEWallet)
112-
* [gdk rust](https://github.com/Blockstream/gdk/blob/master/subprojects/gdk_rust/)
83+
Alternatively, use the dep without the auto-download feature.

regtest/src/client_versions.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
// All features uses 26_0
2+
/// The version specific client and json types.
3+
///
4+
/// **THIS IS AVAILABLE FOR ALL VERSION NUMBER FEATURES** (eg `25_0`, `24_2` etc). This crate is
5+
/// unusual in that it expects exactly one version number feature to be selected, docs.rs is not set
6+
/// up to handle such oddity.
7+
///
28
#[cfg(feature = "26_0")]
39
#[allow(unused_imports)] // Not all users need the json types.
410
pub use bitcoind_json_rpc_client::{client_sync::v26::{Client, AddressType}, json::v26 as json};
@@ -67,7 +73,7 @@ pub use bitcoind_json_rpc_client::{client_sync::v18::{Client, AddressType}, json
6773
#[allow(unused_imports)] // Not all users need the json types.
6874
pub use bitcoind_json_rpc_client::{client_sync::v17::{Client, AddressType}, json::v17 as json};
6975

70-
// To make --no-default-features work we have to enable some feature, use most recent version same as for default.
71-
#[cfg(all(not(feature = "26_0"), not(feature = "25_2"), not(feature = "25_1"), not(feature = "25_0"), not(feature = "24_2"),not(feadure = "24_1"), not(feature = "24_0_1"), not(feature = "23_2"), not(feature = "23_1"), not(feature = "23_0"), not(feature = "22_1"), not(feature = "22_0"), not(feature = "0_21_2"), not(feature = "0_20_2"), not(feature = "0_19_1"), not(feature = "0_18_1"), not(feature = "0_17_1")))]
76+
// To make --no-default-features work we have to re-export a the types, use most recent version same as we do for all features.
77+
#[cfg(all(not(feature = "26_0"), not(feature = "25_2"), not(feature = "25_1"), not(feature = "25_0"), not(feature = "24_2"),not(feature = "24_1"), not(feature = "24_0_1"), not(feature = "23_2"), not(feature = "23_1"), not(feature = "23_0"), not(feature = "22_1"), not(feature = "22_0"), not(feature = "0_21_2"), not(feature = "0_20_2"), not(feature = "0_19_1"), not(feature = "0_18_1"), not(feature = "0_17_1")))]
7278
#[allow(unused_imports)] // Not all users need the json types.
7379
pub use bitcoind_json_rpc_client::{client_sync::v26::{Client, AddressType}, json::v26 as json};

regtest/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use tempfile::TempDir;
2121
pub use {anyhow, tempfile, which};
2222

2323
#[rustfmt::skip] // Keep pubic re-exports separate.
24+
#[doc(inline)]
2425
pub use self::{
2526
client_versions::{json, Client, AddressType},
2627
versions::VERSION,

regtest/src/versions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ pub const VERSION: &str = "0.18.1";
5050
pub const VERSION: &str = "0.17.1";
5151

5252
// To make --no-default-features work we have to enable some feature, use most recent version same as for default.
53-
#[cfg(all(not(feature = "26_0"), not(feature = "25_2"), not(feature = "25_1"), not(feature = "25_0"), not(feature = "24_2"),not(feadure = "24_1"), not(feature = "24_0_1"), not(feature = "23_2"), not(feature = "23_1"), not(feature = "23_0"), not(feature = "22_1"), not(feature = "22_0"), not(feature = "0_21_2"), not(feature = "0_20_2"), not(feature = "0_19_1"), not(feature = "0_18_1"), not(feature = "0_17_1")))]
53+
#[cfg(all(not(feature = "26_0"), not(feature = "25_2"), not(feature = "25_1"), not(feature = "25_0"), not(feature = "24_2"),not(feature = "24_1"), not(feature = "24_0_1"), not(feature = "23_2"), not(feature = "23_1"), not(feature = "23_0"), not(feature = "22_1"), not(feature = "22_0"), not(feature = "0_21_2"), not(feature = "0_20_2"), not(feature = "0_19_1"), not(feature = "0_18_1"), not(feature = "0_17_1")))]
5454
#[allow(dead_code)] // for --no-default-features
5555
pub const VERSION: &str = "26.0";

0 commit comments

Comments
 (0)