Skip to content

Commit

Permalink
wip(ci): add new features to matrix and include ignored tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oleonardolima committed Jan 12, 2024
1 parent 7f96586 commit d6e6b42
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/cont_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
- async-https-native
- async-https-rustls
- async-https-rustls-manual-roots
- async-arti-hyper
- async-arti-hyper-native
- async-arti-hyper-rustls
steps:
- uses: actions/checkout@v3
- name: Generate cache key
Expand Down Expand Up @@ -58,4 +61,4 @@ jobs:
if: ${{ matrix.rust.clippy }}
run: cargo clippy --all-targets --features ${{ matrix.features }} --no-default-features -- -D warnings
- name: Test
run: cargo test --features ${{ matrix.features }} --no-default-features
run: cargo test --features ${{ matrix.features }} --no-default-features -- --include-ignored
55 changes: 33 additions & 22 deletions src/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
use std::collections::HashMap;
use std::str::FromStr;

use arti_client::{TorClient, TorClientConfig};

use arti_hyper::ArtiHttpConnector;

use bitcoin::consensus::{deserialize, serialize};
use bitcoin::hashes::hex::FromHex;
use bitcoin::hashes::{sha256, Hash};
Expand All @@ -26,26 +22,38 @@ use bitcoin::{
};
use bitcoin_internals::hex::display::DisplayHex;

use hyper::{Body, Response, Uri};
#[allow(unused_imports)]
use log::{debug, error, info, trace};

use reqwest::{Client, StatusCode};
use tls_api::{TlsConnector as TlsConnectorTrait, TlsConnectorBuilder};
#[cfg(feature = "async")]
use reqwest::Client;

#[cfg(feature = "async-arti-hyper")]
use {
arti_client::{TorClient, TorClientConfig},
arti_hyper::ArtiHttpConnector,
hyper::{Body, Response, Uri},
tls_api::{TlsConnector as TlsConnectorTrait, TlsConnectorBuilder},
tor_rtcompat::PreferredRuntime,
};

#[cfg(feature = "async-arti-hyper")]
#[cfg(not(target_vendor = "apple"))]
use tls_api_native_tls::TlsConnector;
#[cfg(feature = "async-arti-hyper")]
#[cfg(target_vendor = "apple")]
use tls_api_openssl::TlsConnector;
use tor_rtcompat::PreferredRuntime;

use crate::{BlockStatus, BlockSummary, Builder, Error, MerkleProof, OutputStatus, Tx, TxStatus};

#[cfg(feature = "async")]
#[derive(Debug, Clone)]
pub struct AsyncClient {
url: String,
client: Client,
}

#[cfg(feature = "async")]
impl AsyncClient {
/// build an async client from a builder
pub fn from_builder(builder: Builder) -> Result<Self, Error> {
Expand Down Expand Up @@ -77,7 +85,7 @@ impl AsyncClient {
.send()
.await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let reqwest::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand Down Expand Up @@ -112,7 +120,7 @@ impl AsyncClient {
.send()
.await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let reqwest::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand Down Expand Up @@ -198,7 +206,7 @@ impl AsyncClient {
.send()
.await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let reqwest::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand All @@ -220,7 +228,7 @@ impl AsyncClient {
.send()
.await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let reqwest::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand All @@ -242,7 +250,7 @@ impl AsyncClient {
.send()
.await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let reqwest::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand All @@ -269,7 +277,7 @@ impl AsyncClient {
.send()
.await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let reqwest::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand Down Expand Up @@ -346,7 +354,7 @@ impl AsyncClient {
.send()
.await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let reqwest::StatusCode::NOT_FOUND = resp.status() {
return Err(Error::HeaderHeightNotFound(block_height));
}

Expand Down Expand Up @@ -441,12 +449,14 @@ impl AsyncClient {
}
}

#[cfg(feature = "async-arti-hyper")]
#[derive(Debug, Clone)]
pub struct AsyncAnonymizedClient {
url: String,
client: hyper::Client<ArtiHttpConnector<PreferredRuntime, TlsConnector>>,
}

#[cfg(feature = "async-arti-hyper")]
impl AsyncAnonymizedClient {
/// build an async [`TorClient`] with default Tor configuration
async fn create_tor_client() -> Result<TorClient<PreferredRuntime>, arti_client::Error> {
Expand Down Expand Up @@ -485,7 +495,7 @@ impl AsyncAnonymizedClient {

let resp = self.client.get(uri).await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let hyper::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand Down Expand Up @@ -521,7 +531,7 @@ impl AsyncAnonymizedClient {

let resp = self.client.get(uri).await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let hyper::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand Down Expand Up @@ -604,7 +614,7 @@ impl AsyncAnonymizedClient {
let uri = Uri::from_str(&path).map_err(|_| Error::InvalidUri)?;
let resp = self.client.get(uri).await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let hyper::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand All @@ -627,7 +637,7 @@ impl AsyncAnonymizedClient {

let resp = self.client.get(uri).await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let hyper::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand All @@ -652,7 +662,7 @@ impl AsyncAnonymizedClient {

let resp = self.client.get(uri).await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let hyper::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand All @@ -678,7 +688,7 @@ impl AsyncAnonymizedClient {
let uri = Uri::from_str(path).map_err(|_| Error::InvalidUri)?;
let resp = self.client.get(uri).await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let hyper::StatusCode::NOT_FOUND = resp.status() {
return Ok(None);
}

Expand All @@ -697,6 +707,7 @@ impl AsyncAnonymizedClient {
}
}

// TODO: (@leonardo)
// /// Broadcast a [`Transaction`] to Esplora
// pub async fn broadcast(&self, transaction: &Transaction) -> Result<(), Error> {
// let resp = self
Expand Down Expand Up @@ -761,7 +772,7 @@ impl AsyncAnonymizedClient {
let uri = Uri::from_str(path).map_err(|_| Error::InvalidUri)?;
let resp = self.client.get(uri).await?;

if let StatusCode::NOT_FOUND = resp.status() {
if let hyper::StatusCode::NOT_FOUND = resp.status() {
return Err(Error::HeaderHeightNotFound(block_height));
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ use bitcoin::consensus;

pub mod api;

#[cfg(feature = "async")]
#[cfg(any(feature = "async", feature = "async-arti-hyper"))]
pub mod r#async;
#[cfg(feature = "blocking")]
pub mod blocking;
Expand Down

0 comments on commit d6e6b42

Please sign in to comment.