Skip to content

Commit 90f1f3b

Browse files
committed
Use real avks instead of mock strings in tests
1 parent 4b47cf9 commit 90f1f3b

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

mithril-aggregator/src/database/provider/certificate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl CertificateRecord {
8282
parent_certificate_id: Some(parent_id.to_string()),
8383
message: "message".to_string(),
8484
signature: fake_keys::multi_signature()[0].to_owned(),
85-
aggregate_verification_key: "avk".to_string(),
85+
aggregate_verification_key: fake_keys::aggregate_verification_key()[0].to_owned(),
8686
epoch: beacon.epoch,
8787
beacon,
8888
protocol_version: "protocol_version".to_string(),

mithril-aggregator/src/tools/certificates_hash_migrator.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,41 +342,41 @@ mod test {
342342
let expected = vec![
343343
(
344344
dummy_genesis(
345-
"b9263d7c2e94f6a62802b6521b30967e7e7a7fdccf02026dc70a0ffbc46da393",
345+
"98b44c52ac3c82adcbc5aea27a0c99cbba716048dddaf401b27acded80f1abcd",
346346
1,
347347
1,
348348
),
349349
None,
350350
),
351351
(
352352
dummy_certificate(
353-
"5d73905d314abc86451a399d4f1820201d4c20076d8fb0e4b277ffe5f5e4dc07",
354-
"b9263d7c2e94f6a62802b6521b30967e7e7a7fdccf02026dc70a0ffbc46da393",
353+
"0b7c12daffe63ca93a9cded424e300361a5234ab8c52b3e7029ff9dfbd8a16bd",
354+
"98b44c52ac3c82adcbc5aea27a0c99cbba716048dddaf401b27acded80f1abcd",
355355
1,
356356
2,
357357
),
358358
Some(SignedEntityRecord {
359359
signed_entity_id: "signed_entity_id".to_string(),
360360
signed_entity_type: MithrilStakeDistribution(Epoch(1)),
361361
certificate_id:
362-
"5d73905d314abc86451a399d4f1820201d4c20076d8fb0e4b277ffe5f5e4dc07"
362+
"0b7c12daffe63ca93a9cded424e300361a5234ab8c52b3e7029ff9dfbd8a16bd"
363363
.to_string(),
364364
artifact: "".to_string(),
365365
created_at: Default::default(),
366366
}),
367367
),
368368
(
369369
dummy_certificate(
370-
"583803ea5050f781de38c25d8773628ccf5c6fd737b4d984db2d41444bfdbf39",
371-
"5d73905d314abc86451a399d4f1820201d4c20076d8fb0e4b277ffe5f5e4dc07",
370+
"0aa74b928d3eade6548b22349435a12e9591f0c34c9ca2b0abfbeeefbb1acb37",
371+
"0b7c12daffe63ca93a9cded424e300361a5234ab8c52b3e7029ff9dfbd8a16bd",
372372
2,
373373
3,
374374
),
375375
Some(SignedEntityRecord {
376376
signed_entity_id: "signed_entity_id".to_string(),
377377
signed_entity_type: MithrilStakeDistribution(Epoch(2)),
378378
certificate_id:
379-
"583803ea5050f781de38c25d8773628ccf5c6fd737b4d984db2d41444bfdbf39"
379+
"0aa74b928d3eade6548b22349435a12e9591f0c34c9ca2b0abfbeeefbb1acb37"
380380
.to_string(),
381381
artifact: "".to_string(),
382382
created_at: Default::default(),

mithril-common/src/entities/certificate.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ mod tests {
200200
);
201201
protocol_message.set_message_part(
202202
ProtocolMessagePartKey::NextAggregateVerificationKey,
203-
"next-avk-123".to_string(),
203+
fake_keys::aggregate_verification_key()[1].to_owned(),
204204
);
205205

206206
protocol_message
@@ -209,7 +209,7 @@ mod tests {
209209
#[test]
210210
fn test_certificate_compute_hash() {
211211
const HASH_EXPECTED: &str =
212-
"255d59cef74aae5bc2e83e87612dea41309551dde0c770d46bf6607971bb9765";
212+
"af0965134ef5b2c2a33005cf401c58ca882dead8efda358540dac0575098b54e";
213213

214214
let initiated_at = DateTime::parse_from_rfc3339("2024-02-12T13:11:47.0123043Z")
215215
.unwrap()
@@ -227,7 +227,7 @@ mod tests {
227227
get_signers_with_stake(),
228228
),
229229
get_protocol_message(),
230-
"aggregate_verification_key".to_string(),
230+
fake_keys::aggregate_verification_key()[0].to_owned(),
231231
CertificateSignature::MultiSignature(
232232
fake_keys::multi_signature()[0].try_into().unwrap(),
233233
),
@@ -272,7 +272,9 @@ mod tests {
272272
let mut protocol_message_modified = certificate.protocol_message.clone();
273273
protocol_message_modified.set_message_part(
274274
ProtocolMessagePartKey::NextAggregateVerificationKey,
275-
"next-avk-456".to_string(),
275+
fake_keys::aggregate_verification_key()[2]
276+
.try_into()
277+
.unwrap(),
276278
);
277279

278280
protocol_message_modified
@@ -285,7 +287,9 @@ mod tests {
285287
assert_ne!(
286288
HASH_EXPECTED,
287289
Certificate {
288-
aggregate_verification_key: "aggregate_verification_key-modified".to_string(),
290+
aggregate_verification_key: fake_keys::aggregate_verification_key()[2]
291+
.try_into()
292+
.unwrap(),
289293
..certificate.clone()
290294
}
291295
.compute_hash(),
@@ -306,7 +310,7 @@ mod tests {
306310
#[test]
307311
fn test_genesis_certificate_compute_hash() {
308312
const HASH_EXPECTED: &str =
309-
"bbb265e74082896873d3fbe568e4b0118ddcf9a63b4f4b369b92773439e80159";
313+
"e8cc8885ef7a76f35216a6ef603ab0387dcacb892e0a33df9de9f5bf98cf203b";
310314

311315
let initiated_at = DateTime::parse_from_rfc3339("2024-02-12T13:11:47.0123043Z")
312316
.unwrap()
@@ -324,7 +328,7 @@ mod tests {
324328
get_signers_with_stake(),
325329
),
326330
get_protocol_message(),
327-
"aggregate_verification_key".to_string(),
331+
fake_keys::aggregate_verification_key()[1].to_owned(),
328332
CertificateSignature::GenesisSignature(
329333
fake_keys::genesis_signature()[0].try_into().unwrap(),
330334
),

mithril-common/src/messages/certificate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl CertificateMessage {
5959
);
6060
protocol_message.set_message_part(
6161
ProtocolMessagePartKey::NextAggregateVerificationKey,
62-
"next-avk-123".to_string(),
62+
fake_keys::aggregate_verification_key()[1].to_owned(),
6363
);
6464
Self {
6565
hash: "hash".to_string(),
@@ -68,7 +68,7 @@ impl CertificateMessage {
6868
metadata: CertificateMetadataMessagePart::dummy(),
6969
protocol_message: protocol_message.clone(),
7070
signed_message: "signed_message".to_string(),
71-
aggregate_verification_key: "aggregate_verification_key".to_string(),
71+
aggregate_verification_key: fake_keys::aggregate_verification_key()[0].to_owned(),
7272
multi_signature: fake_keys::multi_signature()[0].to_owned(),
7373
genesis_signature: String::new(),
7474
}

mithril-common/src/test_utils/fake_data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub fn certificate(certificate_hash: String) -> entities::Certificate {
123123
);
124124

125125
// Protocol message
126-
let next_aggregate_verification_key = "next-avk-123".to_string();
126+
let next_aggregate_verification_key = fake_keys::aggregate_verification_key()[2].to_owned();
127127
let mut protocol_message = ProtocolMessage::new();
128128
let snapshot_digest = format!("1{}", beacon.immutable_file_number).repeat(20);
129129
protocol_message.set_message_part(ProtocolMessagePartKey::SnapshotDigest, snapshot_digest);
@@ -134,7 +134,7 @@ pub fn certificate(certificate_hash: String) -> entities::Certificate {
134134

135135
// Certificate
136136
let previous_hash = format!("{certificate_hash}0");
137-
let aggregate_verification_key = format!("AVK{}", beacon.immutable_file_number).repeat(5);
137+
let aggregate_verification_key = fake_keys::aggregate_verification_key()[1].to_owned();
138138
let multi_signature = fake_keys::multi_signature()[0].try_into().unwrap();
139139

140140
entities::Certificate {

0 commit comments

Comments
 (0)