Skip to content

Commit 25d3c9c

Browse files
authored
Merge pull request #1341 from input-output-hk/djo/simplify_common_deps
Simplify common deps
2 parents c74d134 + d8d97cc commit 25d3c9c

File tree

17 files changed

+88
-33
lines changed

17 files changed

+88
-33
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-aggregator/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.4.7"
3+
version = "0.4.8"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }
@@ -48,6 +48,7 @@ zstd = { version = "0.13.0", features = ["zstdmt"] }
4848
httpmock = "0.6.8"
4949
mithril-common = { path = "../mithril-common", features = [
5050
"allow_skip_signer_certification",
51+
"test_tools"
5152
] }
5253
mockall = "0.11.4"
5354
slog-term = "2.9.0"

mithril-aggregator/src/dependency_injection/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ impl DependenciesBuilder {
534534
&self.configuration.data_stores_directory,
535535
&format!("immutables_digests_{}.json", self.configuration.network),
536536
)
537+
.with_logger(self.get_logger().await?)
537538
.should_reset_digests_cache(self.configuration.reset_digests_cache)
538539
.build()
539540
.await?;

mithril-aggregator/src/services/stake_distribution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl StakeDistributionService for MithrilStakeDistributionService {
228228
#[cfg(test)]
229229
mod tests {
230230
use crate::dependency_injection::DependenciesBuilder;
231-
use mithril_common::chain_observer::MockChainObserver;
231+
use crate::tools::mocks::MockChainObserver;
232232

233233
use super::*;
234234

mithril-aggregator/src/services/ticker.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ impl TickerService for MithrilTickerService {
9191

9292
#[cfg(test)]
9393
mod tests {
94-
use mithril_common::{chain_observer::MockChainObserver, digesters::DumbImmutableFileObserver};
94+
use crate::tools::mocks::MockChainObserver;
95+
use mithril_common::digesters::DumbImmutableFileObserver;
9596

9697
use super::*;
9798

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use async_trait::async_trait;
2+
use mithril_common::chain_observer::{ChainAddress, ChainObserver, ChainObserverError, TxDatum};
3+
use mithril_common::crypto_helper::{KESPeriod, OpCert};
4+
use mithril_common::entities::{Epoch, StakeDistribution};
5+
use mockall::mock;
6+
7+
mock! {
8+
pub ChainObserver {}
9+
10+
#[async_trait]
11+
impl ChainObserver for ChainObserver {
12+
async fn get_current_datums(
13+
&self,
14+
address: &ChainAddress,
15+
) -> Result<Vec<TxDatum>, ChainObserverError>;
16+
17+
async fn get_current_epoch(&self) -> Result<Option<Epoch>, ChainObserverError>;
18+
19+
async fn get_current_stake_distribution(
20+
&self,
21+
) -> Result<Option<StakeDistribution>, ChainObserverError>;
22+
23+
async fn get_current_kes_period(
24+
&self,
25+
opcert: &OpCert,
26+
) -> Result<Option<KESPeriod>, ChainObserverError>;
27+
}
28+
}

mithril-aggregator/src/tools/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ mod certificates_hash_migrator;
22
mod digest_helpers;
33
mod era;
44
mod genesis;
5+
#[cfg(test)]
6+
pub mod mocks;
57
mod remote_file_uploader;
68
mod signer_importer;
79

mithril-client-cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-client-cli"
3-
version = "0.5.3"
3+
version = "0.5.4"
44
description = "A Mithril Client"
55
authors = { workspace = true }
66
edition = { workspace = true }
@@ -58,7 +58,7 @@ zstd = "0.13.0"
5858

5959
[dev-dependencies]
6060
httpmock = "0.6.8"
61-
mithril-common = { path = "../mithril-common" }
61+
mithril-common = { path = "../mithril-common", features = ["test_http_server"] }
6262
mockall = "0.11.4"
6363
warp = "0.3"
6464

mithril-client/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-client"
3-
version = "0.5.3"
3+
version = "0.5.4"
44
description = "Mithril Client library"
55
authors = { workspace = true }
66
edition = { workspace = true }
@@ -35,6 +35,7 @@ zstd = "0.13.0"
3535
[dev-dependencies]
3636
httpmock = "0.6.8"
3737
indicatif = { version = "0.17.7", features = ["tokio"] }
38+
mithril-common = { path = "../mithril-common", features = ["test_http_server"] }
3839
mockall = "0.11.4"
3940
slog-async = "2.8.0"
4041
slog-scope = "4.4.0"

mithril-common/Cargo.toml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-common"
3-
version = "0.2.132"
3+
version = "0.2.133"
44
authors = { workspace = true }
55
edition = { workspace = true }
66
documentation = { workspace = true }
@@ -24,18 +24,17 @@ chrono = { version = "0.4.31", features = ["serde"] }
2424
digest = "0.10.7"
2525
ed25519-dalek = { version = "2.0.0", features = ["rand_core", "serde"] }
2626
fixed = "1.24.0"
27-
glob = "0.3.1"
27+
glob = { version = "0.3.1", optional = true }
2828
hex = "0.4.3"
29-
http = "0.2.9"
30-
jsonschema = "0.17.1"
29+
http = { version = "0.2.9", optional = true }
30+
jsonschema = { version = "0.17.1", optional = true }
3131
kes-summed-ed25519 = { version = "0.2.1", features = [
3232
"serde_enabled",
3333
"sk_clone_enabled",
3434
] }
35-
mockall = "0.11.4"
3635
nom = "7.1.3"
3736
rand_chacha = "0.3.1"
38-
rand_core = "0.6.4"
37+
rand_core = { version = "0.6.4", features = ["getrandom"] }
3938
rayon = "1.8.0"
4039
semver = "1.0.19"
4140
serde = { version = "1.0.188", features = ["derive"] }
@@ -45,18 +44,14 @@ serde_json = "1.0.107"
4544
serde_with = "3.3.0"
4645
serde_yaml = "0.9.25"
4746
sha2 = "0.10.8"
48-
slog = { version = "2.7.0", features = [
49-
"max_level_trace",
50-
"release_max_level_debug",
51-
] }
52-
slog-scope = "4.4.0"
47+
slog = "2.7.0"
5348
sqlite = { version = "0.31.1", features = ["bundled"] }
5449
strum = { version = "0.25.0", features = ["derive"] }
5550
thiserror = "1.0.49"
56-
tokio = { version = "1.32.0", features = ["full"] }
51+
tokio = { version = "1.32.0", features = ["fs", "io-util", "process", "rt", "sync"] }
5752
typetag = "0.2.13"
5853
walkdir = "2.4.0"
59-
warp = "0.3.6"
54+
warp = { version = "0.3.6", optional = true }
6055

6156
[target.'cfg(not(windows))'.dependencies]
6257
# non-windows: use default rug backend
@@ -70,10 +65,12 @@ mithril-stm = { path = "../mithril-stm", default-features = false, features = [
7065

7166
[dev-dependencies]
7267
criterion = { version = "0.5.1", features = ["html_reports", "async_tokio"] }
68+
mockall = "0.11.4"
7369
reqwest = { version = "0.11.22", features = ["json"] }
7470
slog-async = "2.8.0"
7571
slog-scope = "4.4.0"
7672
slog-term = "2.9.0"
73+
tokio = { version = "1.32.0", features = ["macros", "time"] }
7774

7875
[build-dependencies]
7976
glob = "0.3.1"
@@ -83,7 +80,15 @@ serde_yaml = "0.9.25"
8380

8481
[features]
8582
default = []
83+
84+
allow_skip_signer_certification = []
85+
# portable feature avoids SIGILL crashes on CPUs not supporting Intel ADX instruction set when built on CPUs that support it
8686
portable = [
8787
"mithril-stm/portable",
88-
] # portable feature avoids SIGILL crashes on CPUs not supporting Intel ADX instruction set when built on CPUs that support it
89-
allow_skip_signer_certification = []
88+
]
89+
90+
# Enable all tests tools
91+
test_tools = ["apispec", "test_http_server"]
92+
# Enable tools to helps validate conformity to an OpenAPI specification
93+
apispec = ["glob", "http", "jsonschema", "warp"]
94+
test_http_server = ["warp"]

0 commit comments

Comments
 (0)