Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Build
run: cargo build --features ${{ matrix.features }} --no-default-features
- name: Test
run: cargo test --features ${{ matrix.features }} --no-default-features -- --test-threads=1
run: cargo test --features ${{ matrix.features }} --no-default-features -- --test-threads=16

fmt:
name: Rust Formatting
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ tokio = { version = "1", features = ["time"], optional = true }
[dev-dependencies]
tokio = { version = "1.20.1", features = ["full"] }
electrsd = { version = "0.36.1", features = ["legacy", "esplora_a33e97e1", "corepc-node_29_0"] }
lazy_static = "1.4.0"

[features]
default = ["blocking", "async", "async-https", "tokio"]
Expand Down
4 changes: 2 additions & 2 deletions ci/pin-msrv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail

# Pin dependencies for MSRV (1.75.0)
cargo update -p minreq --precise "2.13.2"
cargo update -p native-tls --precise "0.2.11"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you have to pin this down to 0.2.11, if the 0.2.13 already has 1.53.0 as MSRV ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some transitive dependency was breaking our MSRV.

cargo update -p idna_adapter --precise "1.2.0"
cargo update -p native-tls --precise "0.2.13"
cargo update -p zerofrom --precise "0.1.5"
cargo update -p litemap --precise "0.7.4"
cargo update -p zerofrom --precise "0.1.5"
11 changes: 6 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ fmt:

# Build and test using the MSRV toolchain (1.75.0)
msrv:
bash ci/pin-msrv.sh
cargo +1.75.0 build --all-features
cargo +1.75.0 test --all-features -- --test-threads=1
rm -rf Cargo.lock
bash ci/pin-msrv.sh
cargo +1.75.0 build --all-features
cargo +1.75.0 test --all-features -- --test-threads=16

# Run pre-push suite: format, check, and test
pre-push: fmt check test
pre-push: fmt check test msrv

# Run all tests on the workspace with all features
test:
cargo test --all-features -- --test-threads=1
cargo test --all-features -- --test-threads=16
7 changes: 7 additions & 0 deletions src/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ pub struct AsyncClient<S = DefaultSleeper> {
max_retries: usize,
/// Marker for the type of sleeper used
marker: PhantomData<S>,
#[allow(unused)]
/// HTTP headers to append on every request made to Esplora server.
pub(crate) headers: HashMap<String, String>, // TODO: remove this when `bitreq` is implemented
Comment on lines +48 to +50
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NACK on adding this field.

AsyncClient already handles the headers properly, as they're passed to reqwest::Client when building it.

I agree that having test_build_client_with_headers is a good idea, thought the right way to do it is asserting that final requests built from both clients contains the expected headers, and not that the client struct has the header field.

As an example, you can do it by updating test_build_client_with_headers to build a GET request with blocking_client.get_request() and async_client.client().get()... and assert that both requests have the expected headers.

}

impl<S: Sleeper> AsyncClient<S> {
Expand All @@ -62,6 +65,8 @@ impl<S: Sleeper> AsyncClient<S> {
client_builder = client_builder.timeout(core::time::Duration::from_secs(timeout));
}

// TODO: remove this when `bitreq` is implemented
let headers = builder.headers.clone();
if !builder.headers.is_empty() {
let mut headers = header::HeaderMap::new();
for (k, v) in builder.headers {
Expand All @@ -78,6 +83,7 @@ impl<S: Sleeper> AsyncClient<S> {
url: builder.base_url,
client: client_builder.build()?,
max_retries: builder.max_retries,
headers,
marker: PhantomData,
})
}
Expand All @@ -87,6 +93,7 @@ impl<S: Sleeper> AsyncClient<S> {
AsyncClient {
url,
client,
headers: HashMap::new(),
max_retries: crate::DEFAULT_MAX_RETRIES,
marker: PhantomData,
}
Expand Down
Loading
Loading