Skip to content

Commit 5464339

Browse files
committed
fix: add missing test for transaction proof route
1 parent 04291de commit 5464339

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

mithril-aggregator/src/http_server/routes/proof_routes.rs

+36-1
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ mod tests {
8585

8686
use mithril_common::test_utils::apispec::APISpec;
8787

88+
use anyhow::anyhow;
8889
use serde_json::Value::Null;
8990
use warp::{http::Method, test::request};
9091

9192
use crate::{
92-
dependency_injection::DependenciesBuilder, http_server::SERVER_BASE_PATH, Configuration,
93+
dependency_injection::DependenciesBuilder, http_server::SERVER_BASE_PATH,
94+
services::MockProverService, Configuration,
9395
};
9496

9597
fn setup_router(
@@ -131,4 +133,37 @@ mod tests {
131133
&response,
132134
);
133135
}
136+
137+
#[tokio::test]
138+
async fn proof_cardano_transaction_ko() {
139+
let config = Configuration::new_sample();
140+
let mut builder = DependenciesBuilder::new(config);
141+
let mut dependency_manager = builder.build_dependency_container().await.unwrap();
142+
let mut mock_prover_service = MockProverService::new();
143+
mock_prover_service
144+
.expect_compute_transactions_proofs()
145+
.returning(|_| Err(anyhow!("Error")))
146+
.times(1);
147+
dependency_manager.prover_service = Arc::new(mock_prover_service);
148+
149+
let method = Method::GET.as_str();
150+
let path = "/proof/cardano-transaction";
151+
152+
let response = request()
153+
.method(method)
154+
.path(&format!(
155+
"/{SERVER_BASE_PATH}{path}?transaction_hashes=tx-123,tx-456"
156+
))
157+
.reply(&setup_router(Arc::new(dependency_manager)))
158+
.await;
159+
160+
APISpec::verify_conformity(
161+
APISpec::get_all_spec_files(),
162+
method,
163+
path,
164+
"application/json",
165+
&Null,
166+
&response,
167+
);
168+
}
134169
}

mithril-aggregator/src/services/prover.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use mithril_common::{
1313
use mockall::automock;
1414

1515
/// Prover service is the cryptographic engine in charge of producing cryptographic proofs for transactions
16-
#[async_trait]
1716
#[cfg_attr(test, automock)]
17+
#[async_trait]
1818
pub trait ProverService: Sync + Send {
1919
/// Compute the cryptographic proofs for the given transactions
2020
async fn compute_transactions_proofs(

0 commit comments

Comments
 (0)