Skip to content

Commit 7c7da5a

Browse files
committed
Adapt client, client-cli and end-to-end to the ChainPoint beacon
1 parent ba6f7c9 commit 7c7da5a

File tree

6 files changed

+30
-17
lines changed

6 files changed

+30
-17
lines changed

mithril-client-cli/src/commands/cardano_transaction/snapshot_list.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ impl CardanoTransactionSnapshotListCommand {
3131
.into_iter()
3232
.map(|item| {
3333
vec![
34-
format!("{}", item.beacon.epoch).cell(),
35-
format!("{}", item.beacon.immutable_file_number).cell(),
36-
item.beacon.network.cell(),
34+
format!("{}", item.epoch).cell(),
35+
format!("{}", item.chain_point.block_number).cell(),
36+
format!("{}", item.chain_point.slot_number).cell(),
37+
item.chain_point.block_hash.cell(),
3738
item.hash.cell(),
3839
item.certificate_hash.cell(),
3940
item.created_at.to_string().cell(),
@@ -43,8 +44,9 @@ impl CardanoTransactionSnapshotListCommand {
4344
.table()
4445
.title(vec![
4546
"Epoch".cell(),
46-
"Immutable".cell(),
47-
"Network".cell(),
47+
"Block Number".cell(),
48+
"Slot Number".cell(),
49+
"Block Hash".cell(),
4850
"Hash".cell(),
4951
"Certificate Hash".cell(),
5052
"Created".cell().justify(Justify::Right),

mithril-client-cli/src/commands/cardano_transaction/snapshot_show.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,16 @@ impl CardanoTransactionsSnapshotShowCommand {
6060
println!("{}", serde_json::to_string(&tx_sets)?);
6161
} else {
6262
let transaction_sets_table = vec![
63-
vec!["Epoch".cell(), format!("{}", &tx_sets.beacon.epoch).cell()],
63+
vec!["Epoch".cell(), format!("{}", &tx_sets.epoch).cell()],
6464
vec![
65-
"Immutable File Number".cell(),
66-
format!("{}", &tx_sets.beacon.immutable_file_number).cell(),
65+
"Block Number".cell(),
66+
format!("{}", &tx_sets.chain_point.block_number).cell(),
6767
],
68-
vec!["Network".cell(), tx_sets.beacon.network.cell()],
68+
vec![
69+
"Slot Number".cell(),
70+
format!("{}", &tx_sets.chain_point.slot_number).cell(),
71+
],
72+
vec!["Block Hash".cell(), tx_sets.chain_point.block_hash.cell()],
6973
vec!["Merkle Root".cell(), tx_sets.merkle_root.to_string().cell()],
7074
vec![
7175
"Certificate Hash".cell(),

mithril-client/src/cardano_transaction_client.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,14 @@ impl CardanoTransactionClient {
159159
#[cfg(test)]
160160
mod tests {
161161
use crate::aggregator_client::{AggregatorClientError, MockAggregatorHTTPClient};
162-
use crate::common::CardanoDbBeacon;
162+
use crate::common::{ChainPoint, Epoch};
163163
use crate::{
164164
CardanoTransactionSnapshot, CardanoTransactionSnapshotListItem, CardanoTransactionsProofs,
165165
CardanoTransactionsSetProof,
166166
};
167167
use anyhow::anyhow;
168168
use chrono::{DateTime, Utc};
169+
use mockall::predicate::eq;
169170
use std::sync::Arc;
170171

171172
use super::*;
@@ -174,7 +175,8 @@ mod tests {
174175
vec![
175176
CardanoTransactionSnapshotListItem {
176177
merkle_root: "mk-123".to_string(),
177-
beacon: CardanoDbBeacon::new("network".to_string(), 1, 1),
178+
epoch: Epoch(1),
179+
chain_point: ChainPoint::new(100, 24, "block_hash-24"),
178180
hash: "hash-123".to_string(),
179181
certificate_hash: "cert-hash-123".to_string(),
180182
created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
@@ -183,7 +185,8 @@ mod tests {
183185
},
184186
CardanoTransactionSnapshotListItem {
185187
merkle_root: "mk-456".to_string(),
186-
beacon: CardanoDbBeacon::new("network".to_string(), 1, 2),
188+
epoch: Epoch(1),
189+
chain_point: ChainPoint::new(100, 24, "block_hash-24"),
187190
hash: "hash-456".to_string(),
188191
certificate_hash: "cert-hash-456".to_string(),
189192
created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
@@ -213,7 +216,8 @@ mod tests {
213216
let mut http_client = MockAggregatorHTTPClient::new();
214217
let message = CardanoTransactionSnapshot {
215218
merkle_root: "mk-123".to_string(),
216-
beacon: CardanoDbBeacon::new("network".to_string(), 1, 1),
219+
epoch: Epoch(1),
220+
chain_point: ChainPoint::new(100, 24, "block_hash-24"),
217221
hash: "hash-123".to_string(),
218222
certificate_hash: "cert-hash-123".to_string(),
219223
created_at: DateTime::parse_from_rfc3339("2023-01-19T13:43:05.618857482Z")
@@ -223,10 +227,13 @@ mod tests {
223227
let expected = message.clone();
224228
http_client
225229
.expect_get_content()
230+
.with(eq(AggregatorRequest::GetCardanoTransactionSnapshot {
231+
hash: "hash-123".to_string(),
232+
}))
226233
.return_once(move |_| Ok(serde_json::to_string(&message).unwrap()));
227234
let client = CardanoTransactionClient::new(Arc::new(http_client));
228235
let cardano_transaction_snapshot = client
229-
.get_snapshot("hash")
236+
.get_snapshot("hash-123")
230237
.await
231238
.unwrap()
232239
.expect("This test returns a cardano transaction snapshot");

mithril-client/src/type_alias.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ pub mod common {
6161
ProtocolParameters,
6262
};
6363
cfg_unstable! {
64-
pub use mithril_common::entities::TransactionHash;
64+
pub use mithril_common::entities::{ChainPoint, TransactionHash};
6565
}
6666
}

mithril-client/tests/extensions/fake.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ mod proof {
165165
.unwrap(),
166166
}],
167167
non_certified_transactions: vec![],
168-
latest_immutable_file_number: 9999,
168+
latest_block_number: 9999,
169169
})
170170
.unwrap();
171171

mithril-test-lab/mithril-end-to-end/src/assertions/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ pub async fn assert_signer_is_signing_cardano_transactions(
212212
match reqwest::get(url.clone()).await {
213213
Ok(response) => match response.status() {
214214
StatusCode::OK => match response.json::<CardanoTransactionSnapshotMessage>().await {
215-
Ok(artifact) => match artifact.beacon.epoch {
215+
Ok(artifact) => match artifact.epoch {
216216
epoch if epoch >= expected_epoch_min => Ok(Some(artifact)),
217217
epoch => Err(anyhow!(
218218
"Minimum expected artifact epoch not reached : {epoch} < {expected_epoch_min}"

0 commit comments

Comments
 (0)