Skip to content

Commit 685d104

Browse files
Ensure each and every feature flags can be used independently (#1455)
1 parent 439abf5 commit 685d104

File tree

11 files changed

+65
-28
lines changed

11 files changed

+65
-28
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Fix newly introduced `std` and `json-schema` features, and ensure all feature flag can be used independently and in isolation.
2+
([\#1454](https://github.com/informalsystems/tendermint-rs/issues/1454))

.github/workflows/test.yml

+12-8
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,36 @@ jobs:
3434
steps:
3535
- uses: actions/checkout@v4
3636
- uses: dtolnay/rust-toolchain@stable
37-
- run: cargo test-all-features -p tendermint
37+
- uses: taiki-e/install-action@cargo-hack
38+
- run: cargo test -p tendermint
39+
- run: cargo hack test --each-feature -p tendermint
3840

3941
tendermint-rpc:
4042
runs-on: ubuntu-latest
4143
steps:
4244
- uses: actions/checkout@v4
4345
- uses: dtolnay/rust-toolchain@stable
44-
- run: cargo test-all-features -p tendermint-rpc
46+
- uses: taiki-e/install-action@cargo-hack
47+
- run: cargo test -p tendermint-rpc
48+
- run: cargo hack test --each-feature -p tendermint-rpc
4549

4650
tendermint-proto:
4751
runs-on: ubuntu-latest
4852
steps:
4953
- uses: actions/checkout@v4
5054
- uses: dtolnay/rust-toolchain@stable
51-
- run: cargo test-all-features -p tendermint-proto
55+
- uses: taiki-e/install-action@cargo-hack
56+
- run: cargo test -p tendermint-proto
57+
- run: cargo hack test --each-feature -p tendermint-proto
5258

5359
tendermint-light-client:
5460
runs-on: ubuntu-latest
5561
steps:
5662
- uses: actions/checkout@v4
5763
- uses: dtolnay/rust-toolchain@stable
58-
# NOTE: We test with default features to make sure things work without "unstable".
59-
- name: Test with default features
60-
run: cargo test -p tendermint-light-client
61-
- name: Test with all features
62-
run: cargo test-all-features -p tendermint-light-client
64+
- uses: taiki-e/install-action@cargo-hack
65+
- run: cargo test -p tendermint-light-client
66+
- run: cargo hack test --each-feature -p tendermint-light-client
6367

6468
# From https://rustwasm.github.io/docs/wasm-bindgen/wasm-bindgen-test/continuous-integration.html#github-actions
6569
tendermint-light-client-js:

light-client/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ regex = { version = "1.7.3" }
5757

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

6162
serde_json = { version = "1.0.51", default-features = false }
6263
gumdrop = { version = "0.8.0", default-features = false }

proto/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ description = """
1717
default = []
1818
std = []
1919
grpc = ["grpc-server"]
20-
grpc-server = ["dep:tonic"]
21-
json-schema = ["dep:schemars"]
20+
grpc-server = ["dep:tonic", "std"]
21+
json-schema = ["dep:schemars", "std"]
2222
borsh = ["dep:borsh"]
2323
parity-scale-codec = ["dep:parity-scale-codec", "dep:scale-info"]
2424

proto/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! tendermint-proto library gives the developer access to the Tendermint proto-defined structs.
22
3-
#![cfg_attr(not(any(feature = "grpc-server")), no_std)]
3+
#![cfg_attr(not(feature = "std"), no_std)]
44
#![deny(warnings, trivial_casts, trivial_numeric_casts, unused_import_braces)]
55
#![allow(clippy::large_enum_variant)]
66
#![forbid(unsafe_code)]

rpc/Cargo.toml

+13-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ path = "src/client/bin/main.rs"
2929
required-features = [ "cli" ]
3030

3131
[features]
32-
default = ["flex-error/std", "flex-error/eyre_tracer"]
32+
default = [
33+
"flex-error/std",
34+
"flex-error/eyre_tracer"
35+
]
36+
secp256k1 = [
37+
"tendermint/secp256k1"
38+
]
3339
cli = [
3440
"http-client",
3541
"structopt",
@@ -42,17 +48,20 @@ http-client = [
4248
"tokio/macros",
4349
"tracing"
4450
]
45-
secp256k1 = [ "tendermint/secp256k1" ]
4651
websocket-client = [
4752
"async-tungstenite",
4853
"futures",
4954
"tokio/rt-multi-thread",
50-
"tokio/fs",
5155
"tokio/macros",
5256
"tokio/sync",
5357
"tokio/time",
5458
"tracing"
5559
]
60+
mock-client = [
61+
"futures",
62+
"tracing",
63+
"tokio/macros"
64+
]
5665

5766
[dependencies]
5867
tendermint = { version = "0.39.0", default-features = false, path = "../tendermint" }
@@ -92,3 +101,4 @@ tendermint = { version = "0.39.0", default-features = false, path = "../tendermi
92101
http = { version = "1", default-features = false, features = ["std"] }
93102
lazy_static = { version = "1.4.0", default-features = false }
94103
tokio-test = { version = "0.4", default-features = false }
104+
tokio = { version = "1.0", default-features = false, features = ["rt-multi-thread", "fs"] }

rpc/src/client.rs

+21-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,31 @@
33
mod compat;
44
pub use compat::CompatMode;
55

6-
#[cfg(any(feature = "http-client", feature = "websocket-client"))]
6+
#[cfg(any(
7+
feature = "http-client",
8+
feature = "websocket-client",
9+
feature = "mock-client"
10+
))]
711
mod subscription;
8-
#[cfg(any(feature = "http-client", feature = "websocket-client"))]
12+
#[cfg(any(
13+
feature = "http-client",
14+
feature = "websocket-client",
15+
feature = "mock-client"
16+
))]
917
pub use subscription::{Subscription, SubscriptionClient};
1018

11-
#[cfg(any(feature = "http-client", feature = "websocket-client"))]
19+
#[cfg(any(
20+
feature = "http-client",
21+
feature = "websocket-client",
22+
feature = "mock-client"
23+
))]
1224
pub mod sync;
1325

14-
#[cfg(any(feature = "http-client", feature = "websocket-client"))]
26+
#[cfg(any(
27+
feature = "http-client",
28+
feature = "websocket-client",
29+
feature = "mock-client"
30+
))]
1531
mod transport;
1632

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

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

2743
use core::fmt;

rpc/src/client/subscription.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Stream for Subscription {
9090
}
9191

9292
impl Subscription {
93-
pub(crate) fn new(id: String, query: Query, rx: SubscriptionRx) -> Self {
93+
pub fn new(id: String, query: Query, rx: SubscriptionRx) -> Self {
9494
Self { id, query, rx }
9595
}
9696

rpc/src/client/transport.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Tendermint RPC client implementations for different transports.
22
33
mod auth;
4-
pub mod mock;
54
mod router;
65

76
macro_rules! perform_with_compat {
@@ -24,5 +23,7 @@ macro_rules! perform_with_compat {
2423

2524
#[cfg(feature = "http-client")]
2625
pub mod http;
26+
#[cfg(feature = "mock-client")]
27+
pub mod mock;
2728
#[cfg(feature = "websocket-client")]
2829
pub mod websocket;

rpc/src/lib.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,16 @@ mod prelude;
3434

3535
pub mod client;
3636

37-
#[cfg(any(feature = "http-client", feature = "websocket-client"))]
38-
pub use client::{
39-
Client, MockClient, MockRequestMatcher, MockRequestMethodMatcher, Subscription,
40-
SubscriptionClient,
41-
};
37+
#[cfg(any(
38+
feature = "http-client",
39+
feature = "websocket-client",
40+
feature = "mock-client"
41+
))]
42+
pub use client::{Client, Subscription, SubscriptionClient};
4243
#[cfg(feature = "http-client")]
4344
pub use client::{HttpClient, HttpClientUrl};
45+
#[cfg(feature = "mock-client")]
46+
pub use client::{MockClient, MockRequestMatcher, MockRequestMethodMatcher};
4447
#[cfg(feature = "websocket-client")]
4548
pub use client::{WebSocketClient, WebSocketClientDriver, WebSocketClientUrl, WebSocketConfig};
4649

tendermint/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ ripemd = { version = "0.1.3", optional = true, default-features = false }
5757
default = ["std", "rust-crypto"]
5858
std = ["flex-error/std", "clock"]
5959
clock = ["time/std"]
60-
secp256k1 = ["k256", "ripemd"]
61-
rust-crypto = ["sha2", "ed25519-consensus"]
60+
secp256k1 = ["rust-crypto", "dep:k256", "dep:ripemd"]
61+
rust-crypto = ["dep:sha2", "dep:ed25519-consensus"]
6262

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

0 commit comments

Comments
 (0)