Skip to content

Commit 3496410

Browse files
Merge #42: Fix build-test workflow cache step
e634904 Include required async in async-https feature (Steve Myers) c2bd12d Fix rust 1.65.0 clippy warning derive-partial-eq-without-eq (Steve Myers) b538801 Add feature gates in doc tests (Steve Myers) 5ccb504 Pin de-dependency versions for zip and base64ct to work with MSRV 1.57 (Steve Myers) f28eb29 Fix build-test workflow cache step (Steve Myers) Pull request description: - Fix build-test workflow cache step - Pin de-dependency versions for zip and base64ct to work with MSRV 1.57 - Add feature gates in doc tests - Fix rust 1.65.0 clippy warning derive-partial-eq-without-eq - Include required async in async-https feature ACKs for top commit: vladimirfomene: ACK e634904 Tree-SHA512: 66111f250abc2a1b47a057338b54b243e177f374050c2cb6126ed53b1a01415c07e9c387e8445089833215fb6b9ab3ba8179aaac1a4956fbf0ba96da75af2a81
2 parents ad8aad4 + e634904 commit 3496410

File tree

4 files changed

+48
-38
lines changed

4 files changed

+48
-38
lines changed

.github/workflows/cont_integration.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ jobs:
3030
run: echo "${{ matrix.rust.version }} ${{ matrix.features }}" | tee .cache_key
3131
- name: cache
3232
uses: actions/cache@v3
33-
with:
34-
path: |
35-
~/.cargo/registry
36-
~/.cargo/git
37-
target
38-
key: ${{ runner.os }}-cargo-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
33+
with:
34+
path: |
35+
~/.cargo/registry
36+
~/.cargo/git
37+
target
38+
key: ${{ runner.os }}-cargo-${{ hashFiles('.cache_key') }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
3939
- name: Set default toolchain
4040
run: rustup default ${{ matrix.rust.version }}
4141
- name: Set profile

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ tokio = { version = "1.20.1", features = ["full"] }
2828
electrsd = { version = "0.22.0", features = ["legacy", "esplora_a33e97e1", "bitcoind_22_0"] }
2929
electrum-client = "0.12.0"
3030
lazy_static = "1.4.0"
31+
# zip versions after 0.6.3 don't work with our MSRV 1.57.0
32+
zip = "=0.6.3"
33+
# base64ct versions at 1.6.0 and higher have MSRV 1.60.0
34+
base64ct = "<1.6.0"
3135

3236
[features]
3337
default = ["blocking", "async", "async-https"]
3438
blocking = ["ureq", "ureq/socks-proxy"]
3539
async = ["reqwest", "reqwest/socks"]
36-
async-https = ["reqwest/default-tls"]
40+
async-https = ["async", "reqwest/default-tls"]

src/api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ pub struct Tx {
7373
pub fee: u64,
7474
}
7575

76-
#[derive(Deserialize, Clone, Debug, PartialEq)]
76+
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
7777
pub struct BlockTime {
7878
pub timestamp: u64,
7979
pub height: u32,
8080
}
8181

82-
#[derive(Debug, Clone, Deserialize, PartialEq)]
82+
#[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
8383
pub struct BlockSummary {
8484
pub id: BlockHash,
8585
#[serde(flatten)]

src/lib.rs

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,25 @@
1414
//! You can create a blocking client as follows:
1515
//!
1616
//! ```no_run
17+
//! # #[cfg(feature = "blocking")]
18+
//! # {
1719
//! use esplora_client::Builder;
1820
//! let builder = Builder::new("https://blockstream.info/testnet/api");
1921
//! let blocking_client = builder.build_blocking();
2022
//! # Ok::<(), esplora_client::Error>(());
23+
//! # }
2124
//! ```
2225
//!
2326
//! Here is an example of how to create an asynchronous client.
2427
//!
2528
//! ```no_run
29+
//! # #[cfg(feature = "async")]
30+
//! # {
2631
//! use esplora_client::Builder;
2732
//! let builder = Builder::new("https://blockstream.info/testnet/api");
2833
//! let async_client = builder.build_async();
2934
//! # Ok::<(), esplora_client::Error>(());
35+
//! # }
3036
//! ```
3137
//!
3238
//! ## Features
@@ -54,15 +60,15 @@ use bitcoin::{BlockHash, Txid};
5460

5561
pub mod api;
5662

57-
#[cfg(any(feature = "async", feature = "async-https"))]
63+
#[cfg(feature = "async")]
5864
pub mod r#async;
5965
#[cfg(feature = "blocking")]
6066
pub mod blocking;
6167

6268
pub use api::*;
6369
#[cfg(feature = "blocking")]
6470
pub use blocking::BlockingClient;
65-
#[cfg(any(feature = "async", feature = "async-https"))]
71+
#[cfg(feature = "async")]
6672
pub use r#async::AsyncClient;
6773

6874
/// Get a fee value in sats/vbytes from the estimates
@@ -146,7 +152,7 @@ pub enum Error {
146152
#[cfg(feature = "blocking")]
147153
UreqTransport(::ureq::Transport),
148154
/// Error during reqwest HTTP request
149-
#[cfg(any(feature = "async", feature = "async-https"))]
155+
#[cfg(feature = "async")]
150156
Reqwest(::reqwest::Error),
151157
/// HTTP response error
152158
HttpResponse(u16),
@@ -191,7 +197,7 @@ macro_rules! impl_error {
191197
impl std::error::Error for Error {}
192198
#[cfg(feature = "blocking")]
193199
impl_error!(::ureq::Transport, UreqTransport, Error);
194-
#[cfg(any(feature = "async", feature = "async-https"))]
200+
#[cfg(feature = "async")]
195201
impl_error!(::reqwest::Error, Reqwest, Error);
196202
impl_error!(io::Error, Io, Error);
197203
impl_error!(std::num::ParseIntError, Parsing, Error);
@@ -205,7 +211,7 @@ mod test {
205211
use lazy_static::lazy_static;
206212
use std::env;
207213
use tokio::sync::Mutex;
208-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
214+
#[cfg(all(feature = "blocking", feature = "async"))]
209215
use {
210216
bitcoin::hashes::Hash,
211217
bitcoin::Amount,
@@ -243,10 +249,10 @@ mod test {
243249
static ref MINER: Mutex<()> = Mutex::new(());
244250
}
245251

246-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
252+
#[cfg(all(feature = "blocking", feature = "async"))]
247253
static PREMINE: OnceCell<()> = OnceCell::const_new();
248254

249-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
255+
#[cfg(all(feature = "blocking", feature = "async"))]
250256
async fn setup_clients() -> (BlockingClient, AsyncClient) {
251257
PREMINE
252258
.get_or_init(|| async {
@@ -266,14 +272,14 @@ mod test {
266272
(blocking_client, async_client)
267273
}
268274

269-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
275+
#[cfg(all(feature = "blocking", feature = "async"))]
270276
fn generate_blocks_and_wait(num: usize) {
271277
let cur_height = BITCOIND.client.get_block_count().unwrap();
272278
generate_blocks(num);
273279
wait_for_block(cur_height as usize + num);
274280
}
275281

276-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
282+
#[cfg(all(feature = "blocking", feature = "async"))]
277283
fn generate_blocks(num: usize) {
278284
let address = BITCOIND
279285
.client
@@ -285,7 +291,7 @@ mod test {
285291
.unwrap();
286292
}
287293

288-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
294+
#[cfg(all(feature = "blocking", feature = "async"))]
289295
fn wait_for_block(min_height: usize) {
290296
let mut header = ELECTRSD.client.block_headers_subscribe().unwrap();
291297
loop {
@@ -300,7 +306,7 @@ mod test {
300306
}
301307
}
302308

303-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
309+
#[cfg(all(feature = "blocking", feature = "async"))]
304310
fn exponential_backoff_poll<T, F>(mut poll: F) -> T
305311
where
306312
F: FnMut() -> Option<T>,
@@ -361,7 +367,7 @@ mod test {
361367
);
362368
}
363369

364-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
370+
#[cfg(all(feature = "blocking", feature = "async"))]
365371
#[tokio::test]
366372
async fn test_get_tx() {
367373
let (blocking_client, async_client) = setup_clients().await;
@@ -391,7 +397,7 @@ mod test {
391397
assert_eq!(tx, tx_async);
392398
}
393399

394-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
400+
#[cfg(all(feature = "blocking", feature = "async"))]
395401
#[tokio::test]
396402
async fn test_get_tx_no_opt() {
397403
let (blocking_client, async_client) = setup_clients().await;
@@ -421,7 +427,7 @@ mod test {
421427
assert_eq!(tx_no_opt, tx_no_opt_async);
422428
}
423429

424-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
430+
#[cfg(all(feature = "blocking", feature = "async"))]
425431
#[tokio::test]
426432
async fn test_get_tx_status() {
427433
let (blocking_client, async_client) = setup_clients().await;
@@ -452,7 +458,7 @@ mod test {
452458
assert!(tx_status.confirmed);
453459
}
454460

455-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
461+
#[cfg(all(feature = "blocking", feature = "async"))]
456462
#[tokio::test]
457463
async fn test_get_header_by_hash() {
458464
let (blocking_client, async_client) = setup_clients().await;
@@ -464,7 +470,7 @@ mod test {
464470
assert_eq!(block_header, block_header_async);
465471
}
466472

467-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
473+
#[cfg(all(feature = "blocking", feature = "async"))]
468474
#[tokio::test]
469475
async fn test_get_block_status() {
470476
let (blocking_client, async_client) = setup_clients().await;
@@ -484,7 +490,7 @@ mod test {
484490
assert_eq!(expected, block_status_async);
485491
}
486492

487-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
493+
#[cfg(all(feature = "blocking", feature = "async"))]
488494
#[tokio::test]
489495
async fn test_get_non_existing_block_status() {
490496
// Esplora returns the same status for orphaned blocks as for non-existing blocks:
@@ -509,7 +515,7 @@ mod test {
509515
assert_eq!(expected, block_status_async);
510516
}
511517

512-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
518+
#[cfg(all(feature = "blocking", feature = "async"))]
513519
#[tokio::test]
514520
async fn test_get_block_by_hash() {
515521
let (blocking_client, async_client) = setup_clients().await;
@@ -524,7 +530,7 @@ mod test {
524530
assert_eq!(expected, block_async);
525531
}
526532

527-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
533+
#[cfg(all(feature = "blocking", feature = "async"))]
528534
#[tokio::test]
529535
async fn test_get_block_by_hash_not_existing() {
530536
let (blocking_client, async_client) = setup_clients().await;
@@ -540,7 +546,7 @@ mod test {
540546
assert!(block_async.is_none());
541547
}
542548

543-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
549+
#[cfg(all(feature = "blocking", feature = "async"))]
544550
#[tokio::test]
545551
async fn test_get_merkle_proof() {
546552
let (blocking_client, async_client) = setup_clients().await;
@@ -571,7 +577,7 @@ mod test {
571577
assert!(merkle_proof.pos > 0);
572578
}
573579

574-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
580+
#[cfg(all(feature = "blocking", feature = "async"))]
575581
#[tokio::test]
576582
async fn test_get_merkle_block() {
577583
let (blocking_client, async_client) = setup_clients().await;
@@ -611,7 +617,7 @@ mod test {
611617
assert!(indexes[0] > 0);
612618
}
613619

614-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
620+
#[cfg(all(feature = "blocking", feature = "async"))]
615621
#[tokio::test]
616622
async fn test_get_output_status() {
617623
let (blocking_client, async_client) = setup_clients().await;
@@ -649,7 +655,7 @@ mod test {
649655
assert_eq!(output_status, output_status_async);
650656
}
651657

652-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
658+
#[cfg(all(feature = "blocking", feature = "async"))]
653659
#[tokio::test]
654660
async fn test_get_height() {
655661
let (blocking_client, async_client) = setup_clients().await;
@@ -659,7 +665,7 @@ mod test {
659665
assert_eq!(block_height, block_height_async);
660666
}
661667

662-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
668+
#[cfg(all(feature = "blocking", feature = "async"))]
663669
#[tokio::test]
664670
async fn test_get_tip_hash() {
665671
let (blocking_client, async_client) = setup_clients().await;
@@ -668,7 +674,7 @@ mod test {
668674
assert_eq!(tip_hash, tip_hash_async);
669675
}
670676

671-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
677+
#[cfg(all(feature = "blocking", feature = "async"))]
672678
#[tokio::test]
673679
async fn test_get_block_hash() {
674680
let (blocking_client, async_client) = setup_clients().await;
@@ -681,7 +687,7 @@ mod test {
681687
assert_eq!(block_hash, block_hash_async);
682688
}
683689

684-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
690+
#[cfg(all(feature = "blocking", feature = "async"))]
685691
#[tokio::test]
686692
async fn test_get_txid_at_block_index() {
687693
let (blocking_client, async_client) = setup_clients().await;
@@ -700,7 +706,7 @@ mod test {
700706
assert_eq!(txid_at_block_index, txid_at_block_index_async);
701707
}
702708

703-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
709+
#[cfg(all(feature = "blocking", feature = "async"))]
704710
#[tokio::test]
705711
async fn test_get_fee_estimates() {
706712
let (blocking_client, async_client) = setup_clients().await;
@@ -709,7 +715,7 @@ mod test {
709715
assert_eq!(fee_estimates.len(), fee_estimates_async.len());
710716
}
711717

712-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
718+
#[cfg(all(feature = "blocking", feature = "async"))]
713719
#[tokio::test]
714720
async fn test_scripthash_txs() {
715721
let (blocking_client, async_client) = setup_clients().await;
@@ -757,7 +763,7 @@ mod test {
757763
assert_eq!(scripthash_txs_txids, scripthash_txs_txids_async);
758764
}
759765

760-
#[cfg(all(feature = "blocking", any(feature = "async", feature = "async-https")))]
766+
#[cfg(all(feature = "blocking", feature = "async"))]
761767
#[tokio::test]
762768
async fn test_get_blocks() {
763769
let (blocking_client, async_client) = setup_clients().await;

0 commit comments

Comments
 (0)