Skip to content

Commit a6c50a0

Browse files
authored
Merge pull request #1264 from input-output-hk/djo/798/anyhow-in-tests
Use anyhow in integration & e2e tests
2 parents 2d4017b + 164d951 commit a6c50a0

File tree

22 files changed

+273
-298
lines changed

22 files changed

+273
-298
lines changed

Cargo.lock

Lines changed: 3 additions & 3 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-aggregator"
3-
version = "0.3.103"
3+
version = "0.3.104"
44
description = "A Mithril Aggregator server"
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-aggregator/tests/certificate_chain.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,8 @@ async fn certificate_chain() {
160160
"Checking that no signers are registered for the next epoch since they did not register"
161161
);
162162
let next_epoch_verification_keys = tester
163-
.deps_builder
164-
.get_verification_key_store()
165-
.await
166-
.unwrap()
163+
.dependencies
164+
.verification_key_store
167165
.get_verification_keys(new_epoch + 1)
168166
.await
169167
.expect("get_verification_keys should not fail");

mithril-aggregator/tests/test_extensions/aggregator_observer.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
use anyhow::{anyhow, Context};
12
use mithril_aggregator::{
23
dependency_injection::DependenciesBuilder,
34
entities::OpenMessage,
45
services::{CertifierService, TickerService},
56
};
67
use mithril_common::{
78
entities::{Beacon, Epoch, SignedEntityType, SignedEntityTypeDiscriminants},
8-
BeaconProvider,
9+
BeaconProvider, StdResult,
910
};
1011
use std::sync::Arc;
1112

@@ -43,39 +44,37 @@ impl AggregatorObserver {
4344
pub async fn get_current_open_message(
4445
&self,
4546
discriminant: SignedEntityTypeDiscriminants,
46-
) -> Result<Option<OpenMessage>, String> {
47+
) -> StdResult<Option<OpenMessage>> {
4748
let signed_entity_type = self.build_current_signed_entity_type(discriminant).await?;
4849

4950
self.certifier_service
5051
.get_open_message(&signed_entity_type)
5152
.await
52-
.map_err(|e| {
53-
format!(
54-
"Requesting current open message of type CardanoImmutableFilesFull should be not fail: {e:?}"
55-
)
56-
})
53+
.with_context(|| "Requesting current open message of type CardanoImmutableFilesFull should be not fail")
5754
}
5855

5956
// Get the [entity type][SignedEntityType::CardanoImmutableFilesFull] of the current current open message
6057
pub async fn get_current_signed_entity_type(
6158
&self,
6259
discriminant: SignedEntityTypeDiscriminants,
63-
) -> Result<SignedEntityType, String> {
60+
) -> StdResult<SignedEntityType> {
6461
match self.get_current_open_message(discriminant).await? {
65-
None => Err("An open message should be available for cardano immutables".to_string()),
62+
None => Err(anyhow!(
63+
"An open message should be available for cardano immutables"
64+
)),
6665
Some(message) => Ok(message.signed_entity_type),
6766
}
6867
}
6968

7069
async fn build_current_signed_entity_type(
7170
&self,
7271
discriminant: SignedEntityTypeDiscriminants,
73-
) -> Result<SignedEntityType, String> {
72+
) -> StdResult<SignedEntityType> {
7473
let beacon = self
7574
.beacon_provider
7675
.get_current_beacon()
7776
.await
78-
.map_err(|e| format!("Querying the current beacon should not fail: {e:?}"))?;
77+
.with_context(|| "Querying the current beacon should not fail")?;
7978

8079
match discriminant {
8180
SignedEntityTypeDiscriminants::MithrilStakeDistribution => {

0 commit comments

Comments
 (0)