Skip to content

Commit 645dbc5

Browse files
Damien LACHAUME / PALO-ITsfauvel
authored andcommitted
Add latest_immutable_file_number in CardanoTransactionsProofsMessage
1 parent f2654c9 commit 645dbc5

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

mithril-aggregator/src/message_adapters/to_cardano_transactions_proof_message.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ impl ToCardanoTransactionsProofsMessageAdapter {
1414
certificate_hash: &str,
1515
transactions_set_proofs: Vec<CardanoTransactionsSetProof>,
1616
transaction_hashes_to_certify: Vec<TransactionHash>,
17+
latest_immutable_file_number: u64,
1718
) -> StdResult<CardanoTransactionsProofsMessage> {
1819
let transactions_hashes_not_certified = compute_not_certified_transactions(
1920
&transactions_set_proofs,
@@ -24,6 +25,7 @@ impl ToCardanoTransactionsProofsMessageAdapter {
2425
certificate_hash,
2526
try_adapt_set_proof_message(transactions_set_proofs)?,
2627
transactions_hashes_not_certified,
28+
latest_immutable_file_number,
2729
))
2830
}
2931
}
@@ -86,10 +88,12 @@ mod tests {
8688
}
8789

8890
let certificate_hash = "certificate_hash";
91+
let latest_immutable_file_number = 1234;
8992
let message = ToCardanoTransactionsProofsMessageAdapter::try_adapt(
9093
certificate_hash,
9194
transactions_set_proofs.clone(),
9295
transaction_hashes.to_vec(),
96+
latest_immutable_file_number,
9397
)
9498
.unwrap();
9599
let transactions_set_proofs = transactions_set_proofs
@@ -100,6 +104,7 @@ mod tests {
100104
certificate_hash,
101105
transactions_set_proofs,
102106
transactions_hashes_non_certified.to_vec(),
107+
latest_immutable_file_number,
103108
);
104109
assert_eq!(expected_message, message);
105110
}

mithril-client/src/cardano_transaction_client.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,12 @@ mod tests {
239239
let mut aggregator_client = MockAggregatorHTTPClient::new();
240240
let certificate_hash = "cert-hash-123".to_string();
241241
let set_proof = CardanoTransactionsSetProof::dummy();
242-
let transactions_proofs =
243-
CardanoTransactionsProofs::new(&certificate_hash, vec![set_proof.clone()], vec![]);
242+
let transactions_proofs = CardanoTransactionsProofs::new(
243+
&certificate_hash,
244+
vec![set_proof.clone()],
245+
vec![],
246+
99999,
247+
);
244248
let expected_transactions_proofs = transactions_proofs.clone();
245249
aggregator_client
246250
.expect_get_content()

mithril-client/tests/extensions/fake.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ mod proof {
163163
proof: ProtocolMkProof::new(proof.clone()).to_json_hex().unwrap(),
164164
}],
165165
non_certified_transactions: vec![],
166+
latest_immutable_file_number: 9999,
166167
})
167168
.unwrap();
168169

mithril-common/src/messages/cardano_transactions_proof.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ pub struct CardanoTransactionsProofsMessage {
2424

2525
/// Transactions that could not be certified
2626
pub non_certified_transactions: Vec<TransactionHash>,
27+
28+
/// Latest immutable file number associated to the Cardano Transactions
29+
pub latest_immutable_file_number: u64,
2730
}
2831

2932
#[cfg_attr(
@@ -108,11 +111,13 @@ impl CardanoTransactionsProofsMessage {
108111
certificate_hash: &str,
109112
certified_transactions: Vec<CardanoTransactionsSetProofMessagePart>,
110113
non_certified_transactions: Vec<TransactionHash>,
114+
latest_immutable_file_number: u64,
111115
) -> Self {
112116
Self {
113117
certificate_hash: certificate_hash.to_string(),
114118
certified_transactions,
115119
non_certified_transactions,
120+
latest_immutable_file_number,
116121
}
117122
}
118123

@@ -180,6 +185,7 @@ mod tests {
180185
proof: "invalid".to_string(),
181186
}],
182187
vec![],
188+
99999,
183189
);
184190

185191
let error = txs_proofs
@@ -197,7 +203,7 @@ mod tests {
197203

198204
#[test]
199205
fn verify_no_certified_transaction_fail() {
200-
let txs_proofs = CardanoTransactionsProofsMessage::new("whatever", vec![], vec![]);
206+
let txs_proofs = CardanoTransactionsProofsMessage::new("whatever", vec![], vec![], 99999);
201207

202208
let error = txs_proofs
203209
.verify()
@@ -224,6 +230,7 @@ mod tests {
224230
"whatever",
225231
vec![set_proof.try_into().unwrap()],
226232
vec![],
233+
99999,
227234
);
228235

229236
let verified_txs = txs_proofs
@@ -243,6 +250,7 @@ mod tests {
243250
"whatever",
244251
vec![set_proof.try_into().unwrap()],
245252
vec![],
253+
99999,
246254
);
247255

248256
let error = txs_proofs
@@ -278,6 +286,7 @@ mod tests {
278286
.map(|p| p.try_into().unwrap())
279287
.collect(),
280288
vec![],
289+
99999,
281290
);
282291

283292
let error = txs_proofs

0 commit comments

Comments
 (0)