Skip to content

Commit

Permalink
Ensure each and every feature flags can be used independently (#1455)
Browse files Browse the repository at this point in the history
  • Loading branch information
tony-iqlusion authored Aug 8, 2024
1 parent 439abf5 commit 685d104
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/bug-fixes/1454-fix-feature-flags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix newly introduced `std` and `json-schema` features, and ensure all feature flag can be used independently and in isolation.
([\#1454](https://github.com/informalsystems/tendermint-rs/issues/1454))
20 changes: 12 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,36 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test-all-features -p tendermint
- uses: taiki-e/install-action@cargo-hack
- run: cargo test -p tendermint
- run: cargo hack test --each-feature -p tendermint

tendermint-rpc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test-all-features -p tendermint-rpc
- uses: taiki-e/install-action@cargo-hack
- run: cargo test -p tendermint-rpc
- run: cargo hack test --each-feature -p tendermint-rpc

tendermint-proto:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test-all-features -p tendermint-proto
- uses: taiki-e/install-action@cargo-hack
- run: cargo test -p tendermint-proto
- run: cargo hack test --each-feature -p tendermint-proto

tendermint-light-client:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
# NOTE: We test with default features to make sure things work without "unstable".
- name: Test with default features
run: cargo test -p tendermint-light-client
- name: Test with all features
run: cargo test-all-features -p tendermint-light-client
- uses: taiki-e/install-action@cargo-hack
- run: cargo test -p tendermint-light-client
- run: cargo hack test --each-feature -p tendermint-light-client

# From https://rustwasm.github.io/docs/wasm-bindgen/wasm-bindgen-test/continuous-integration.html#github-actions
tendermint-light-client-js:
Expand Down
1 change: 1 addition & 0 deletions light-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ regex = { version = "1.7.3" }

[dev-dependencies]
tendermint-testgen = { path = "../testgen", default-features = false }
tendermint-light-client-verifier = { version = "0.39.0", path = "../light-client-verifier", features = ["rust-crypto"] }

serde_json = { version = "1.0.51", default-features = false }
gumdrop = { version = "0.8.0", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ description = """
default = []
std = []
grpc = ["grpc-server"]
grpc-server = ["dep:tonic"]
json-schema = ["dep:schemars"]
grpc-server = ["dep:tonic", "std"]
json-schema = ["dep:schemars", "std"]
borsh = ["dep:borsh"]
parity-scale-codec = ["dep:parity-scale-codec", "dep:scale-info"]

Expand Down
2 changes: 1 addition & 1 deletion proto/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! tendermint-proto library gives the developer access to the Tendermint proto-defined structs.

#![cfg_attr(not(any(feature = "grpc-server")), no_std)]
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(warnings, trivial_casts, trivial_numeric_casts, unused_import_braces)]
#![allow(clippy::large_enum_variant)]
#![forbid(unsafe_code)]
Expand Down
16 changes: 13 additions & 3 deletions rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ path = "src/client/bin/main.rs"
required-features = [ "cli" ]

[features]
default = ["flex-error/std", "flex-error/eyre_tracer"]
default = [
"flex-error/std",
"flex-error/eyre_tracer"
]
secp256k1 = [
"tendermint/secp256k1"
]
cli = [
"http-client",
"structopt",
Expand All @@ -42,17 +48,20 @@ http-client = [
"tokio/macros",
"tracing"
]
secp256k1 = [ "tendermint/secp256k1" ]
websocket-client = [
"async-tungstenite",
"futures",
"tokio/rt-multi-thread",
"tokio/fs",
"tokio/macros",
"tokio/sync",
"tokio/time",
"tracing"
]
mock-client = [
"futures",
"tracing",
"tokio/macros"
]

[dependencies]
tendermint = { version = "0.39.0", default-features = false, path = "../tendermint" }
Expand Down Expand Up @@ -92,3 +101,4 @@ tendermint = { version = "0.39.0", default-features = false, path = "../tendermi
http = { version = "1", default-features = false, features = ["std"] }
lazy_static = { version = "1.4.0", default-features = false }
tokio-test = { version = "0.4", default-features = false }
tokio = { version = "1.0", default-features = false, features = ["rt-multi-thread", "fs"] }
26 changes: 21 additions & 5 deletions rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,31 @@
mod compat;
pub use compat::CompatMode;

#[cfg(any(feature = "http-client", feature = "websocket-client"))]
#[cfg(any(
feature = "http-client",
feature = "websocket-client",
feature = "mock-client"
))]
mod subscription;
#[cfg(any(feature = "http-client", feature = "websocket-client"))]
#[cfg(any(
feature = "http-client",
feature = "websocket-client",
feature = "mock-client"
))]
pub use subscription::{Subscription, SubscriptionClient};

#[cfg(any(feature = "http-client", feature = "websocket-client"))]
#[cfg(any(
feature = "http-client",
feature = "websocket-client",
feature = "mock-client"
))]
pub mod sync;

#[cfg(any(feature = "http-client", feature = "websocket-client"))]
#[cfg(any(
feature = "http-client",
feature = "websocket-client",
feature = "mock-client"
))]
mod transport;

#[cfg(feature = "http-client")]
Expand All @@ -21,7 +37,7 @@ pub use transport::websocket::{
self, WebSocketClient, WebSocketClientDriver, WebSocketClientUrl, WebSocketConfig,
};

#[cfg(any(feature = "http-client", feature = "websocket-client"))]
#[cfg(feature = "mock-client")]
pub use transport::mock::{MockClient, MockRequestMatcher, MockRequestMethodMatcher};

use core::fmt;
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/client/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Stream for Subscription {
}

impl Subscription {
pub(crate) fn new(id: String, query: Query, rx: SubscriptionRx) -> Self {
pub fn new(id: String, query: Query, rx: SubscriptionRx) -> Self {
Self { id, query, rx }
}

Expand Down
3 changes: 2 additions & 1 deletion rpc/src/client/transport.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Tendermint RPC client implementations for different transports.

mod auth;
pub mod mock;
mod router;

macro_rules! perform_with_compat {
Expand All @@ -24,5 +23,7 @@ macro_rules! perform_with_compat {

#[cfg(feature = "http-client")]
pub mod http;
#[cfg(feature = "mock-client")]
pub mod mock;
#[cfg(feature = "websocket-client")]
pub mod websocket;
13 changes: 8 additions & 5 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ mod prelude;

pub mod client;

#[cfg(any(feature = "http-client", feature = "websocket-client"))]
pub use client::{
Client, MockClient, MockRequestMatcher, MockRequestMethodMatcher, Subscription,
SubscriptionClient,
};
#[cfg(any(
feature = "http-client",
feature = "websocket-client",
feature = "mock-client"
))]
pub use client::{Client, Subscription, SubscriptionClient};
#[cfg(feature = "http-client")]
pub use client::{HttpClient, HttpClientUrl};
#[cfg(feature = "mock-client")]
pub use client::{MockClient, MockRequestMatcher, MockRequestMethodMatcher};
#[cfg(feature = "websocket-client")]
pub use client::{WebSocketClient, WebSocketClientDriver, WebSocketClientUrl, WebSocketConfig};

Expand Down
4 changes: 2 additions & 2 deletions tendermint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ ripemd = { version = "0.1.3", optional = true, default-features = false }
default = ["std", "rust-crypto"]
std = ["flex-error/std", "clock"]
clock = ["time/std"]
secp256k1 = ["k256", "ripemd"]
rust-crypto = ["sha2", "ed25519-consensus"]
secp256k1 = ["rust-crypto", "dep:k256", "dep:ripemd"]
rust-crypto = ["dep:sha2", "dep:ed25519-consensus"]

[dev-dependencies]
k256 = { version = "0.13", default-features = false, features = ["ecdsa"] }
Expand Down

0 comments on commit 685d104

Please sign in to comment.