Skip to content

Commit 6c503dc

Browse files
author
Damien LACHAUME / PALO-IT
committed
Fix missings format! and typo after review
1 parent 6bef6d0 commit 6c503dc

File tree

6 files changed

+47
-21
lines changed

6 files changed

+47
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl VerificationKeyStorer for SignerRegistrationStore {
426426
.get_by_signer_id_and_epoch(signer.party_id.clone(), &epoch)
427427
.with_context(|| {
428428
format!(
429-
"get signer registration record failure, signer_id: '{}', epoch: '{}'",
429+
"Get signer registration record failure with signer_id: '{}', epoch: '{}'",
430430
signer.party_id, epoch
431431
)
432432
})

mithril-aggregator/src/services/certifier.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl MithrilCertifierService {
189189
.open_message_repository
190190
.get_open_message_with_single_signatures(signed_entity_type)
191191
.await
192-
.with_context(|| "Certifier can not get open message with single signatures for signed entity type: '{signed_entity_type}'")?;
192+
.with_context(|| format!("Certifier can not get open message with single signatures for signed entity type: '{signed_entity_type}'"))?;
193193

194194
Ok(open_message_with_single_signatures)
195195
}
@@ -203,7 +203,9 @@ impl CertifierService for MithrilCertifierService {
203203
.open_message_repository
204204
.clean_epoch(epoch)
205205
.await
206-
.with_context(|| "Certifier can not clean open messages from epoch '{epoch}'")?;
206+
.with_context(|| {
207+
format!("Certifier can not clean open messages from epoch '{epoch}'")
208+
})?;
207209
info!("MithrilCertifierService: Informed of a new Epoch: {epoch:?}. Cleaned {nb} open messages along with their single signatures.");
208210

209211
Ok(())
@@ -286,7 +288,7 @@ impl CertifierService for MithrilCertifierService {
286288
.open_message_repository
287289
.get_open_message_with_single_signatures(signed_entity_type)
288290
.await
289-
.with_context(|| "Certifier can not get open message with single signatures for signed entity type: '{signed_entity_type}'")?
291+
.with_context(|| format!("Certifier can not get open message with single signatures for signed entity type: '{signed_entity_type}'"))?
290292
.map(|record| record.into());
291293

292294
Ok(open_message)
@@ -384,16 +386,16 @@ impl CertifierService for MithrilCertifierService {
384386
.certificate_repository
385387
.create_certificate(certificate)
386388
.await
387-
.with_context(|| {
388-
"Certifier can not create certificate for signed entity type: '{signed_entity_type}'"
389+
.with_context(|| {format!(
390+
"Certifier can not create certificate for signed entity type: '{signed_entity_type}'")
389391
})?;
390392

391393
let mut open_message_certified: OpenMessageRecord = open_message_record.into();
392394
open_message_certified.is_certified = true;
393395
self.open_message_repository
394396
.update_open_message(&open_message_certified)
395397
.await
396-
.with_context(|| "Certifier can not update open message for signed entity type: '{signed_entity_type}'")
398+
.with_context(|| format!("Certifier can not update open message for signed entity type: '{signed_entity_type}'"))
397399
?;
398400

399401
Ok(Some(certificate))
@@ -407,7 +409,7 @@ impl CertifierService for MithrilCertifierService {
407409
self.certificate_repository
408410
.get_latest_certificates(last_n)
409411
.await
410-
.with_context(|| "Certifier can not get last '{last_n}' certificates")
412+
.with_context(|| format!("Certifier can not get last '{last_n}' certificates"))
411413
}
412414

413415
async fn verify_certificate_chain(&self, epoch: Epoch) -> StdResult<()> {

mithril-aggregator/src/services/signed_entity.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,20 @@ impl SignedEntityService for MithrilSignedEntityService {
137137

138138
let signed_entity = SignedEntityRecord {
139139
signed_entity_id: artifact.get_id(),
140-
signed_entity_type,
140+
signed_entity_type: signed_entity_type.clone(),
141141
certificate_id: certificate.hash.clone(),
142142
artifact: serde_json::to_string(&artifact)?,
143143
created_at: Utc::now(),
144144
};
145145

146146
self.signed_entity_storer
147147
.store_signed_entity(&signed_entity)
148-
.await.with_context(|| "Signed Entity Service can not store signed entity with type: '{signed_entity_type}'")?;
148+
.await
149+
.with_context(|| {
150+
format!(
151+
"Signed Entity Service can not store signed entity with type: '{signed_entity_type}'"
152+
)
153+
})?;
149154

150155
Ok(())
151156
}
@@ -211,7 +216,9 @@ impl SignedEntityService for MithrilSignedEntityService {
211216
.get_signed_entity(signed_entity_id)
212217
.await
213218
.with_context(|| {
214-
"Signed Entity Service can not get signed entity with id: '{signed_entity_id}'"
219+
format!(
220+
"Signed Entity Service can not get signed entity with id: '{signed_entity_id}'"
221+
)
215222
})? {
216223
Some(entity) => Some(entity.try_into()?),
217224
None => None,
@@ -229,7 +236,9 @@ impl SignedEntityService for MithrilSignedEntityService {
229236
.get_signed_entity(signed_entity_id)
230237
.await
231238
.with_context(|| {
232-
"Signed Entity Service can not get signed entity with id: '{signed_entity_id}'"
239+
format!(
240+
"Signed Entity Service can not get signed entity with id: '{signed_entity_id}'"
241+
)
233242
})? {
234243
Some(entity) => Some(entity.try_into()?),
235244
None => None,

mithril-aggregator/src/tools/certificates_hash_migrator.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ impl CertificatesHashMigrator {
113113
self.certificate_repository
114114
.create_many_certificates(migrated_certificates)
115115
.await
116-
.with_context(|| "Certificates Hash Migrator can not create many certificates")?;
116+
.with_context(|| {
117+
"Certificates Hash Migrator can not insert migrated certificates in the database"
118+
})?;
117119

118120
Ok((old_certificates, old_and_new_hashes))
119121
}
@@ -131,9 +133,11 @@ impl CertificatesHashMigrator {
131133
.signed_entity_storer
132134
.get_signed_entities_by_certificates_ids(&old_hashes)
133135
.await
134-
.with_context(|| {
135-
"Certificates Hash Migrator can not get signed entities by certificates ids with hashes: '{old_hashes}'"
136-
})?;
136+
.with_context(||
137+
format!(
138+
"Certificates Hash Migrator can not get signed entities by certificates ids with hashes: '{:?}'", old_hashes
139+
)
140+
)?;
137141

138142
debug!("🔧 Certificate Hash Migrator: updating signed entities certificate_ids to new computed hash");
139143
for signed_entity_record in records_to_migrate.iter_mut() {
@@ -170,7 +174,7 @@ impl CertificatesHashMigrator {
170174
.delete_certificates(&old_certificates.iter().collect::<Vec<_>>())
171175
.await
172176
.with_context(|| {
173-
"Certificates Hash Migrator can not delete certificates with hashes: '{old_hashes}'"
177+
"Certificates Hash Migrator can not delete old certificates in the database"
174178
})?;
175179

176180
Ok(())
@@ -254,7 +258,12 @@ mod test {
254258
certificate_repository
255259
.create_certificate(certificate.clone())
256260
.await
257-
.with_context(|| "Certificates Hash Migrator can not create certificate")?;
261+
.with_context(|| {
262+
format!(
263+
"Certificates Hash Migrator can not create certificate with hash: '{}'",
264+
certificate.hash
265+
)
266+
})?;
258267

259268
let signed_entity_maybe = match discriminant_maybe {
260269
None => None,
@@ -418,7 +427,7 @@ mod test {
418427
let record = signed_entity_store
419428
.get_signed_entity_by_certificate_id(&certificate.hash)
420429
.await
421-
.with_context(|| "Certificates Hash Migrator can not get signed entity type by certificate id with hash: '{&certificate.hash}'")?;
430+
.with_context(|| format!("Certificates Hash Migrator can not get signed entity type by certificate id with hash: '{}'", certificate.hash))?;
422431
result.push((certificate, record));
423432
}
424433
}

mithril-aggregator/src/tools/genesis.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ impl GenesisTools {
173173
.create_certificate(genesis_certificate.clone())
174174
.await
175175
.with_context(|| {
176-
"Genesis tool can not create certificate with genesis signature: '{genesis_signature}'"
176+
format!(
177+
"Genesis tool can not create certificate with genesis signature: '{:?}'",
178+
genesis_signature
179+
)
177180
})?;
178181
Ok(())
179182
}

mithril-aggregator/tests/test_extensions/runtime_tester.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ impl RuntimeTester {
191191
.create_certificate(genesis_certificate)
192192
.await
193193
.with_context(|| {
194-
"Runtime Tester can not create certificate with fixture: '{fixture}'"
194+
format!(
195+
"Runtime Tester can not create certificate with fixture: '{:?}'",
196+
fixture
197+
)
195198
})?;
196199

197200
Ok(())

0 commit comments

Comments
 (0)