Skip to content

Commit 074ac76

Browse files
committed
Fix CertificateStoreAdapter sorting
1 parent f77d887 commit 074ac76

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,7 @@ impl<'client> Provider<'client> for CertificateRecordProvider<'client> {
314314
fn get_definition(&self, condition: &str) -> String {
315315
let aliases = SourceAlias::new(&[("{:certificate:}", "c")]);
316316
let projection = Self::Entity::get_projection().expand(aliases);
317-
format!(
318-
"select {projection} from certificate as c where {condition} order by sealed_at asc"
319-
)
317+
format!("select {projection} from certificate as c where {condition} order by ROWID desc")
320318
}
321319
}
322320

@@ -665,6 +663,7 @@ mod tests {
665663
let expected_certificate_records: Vec<CertificateRecord> = certificates
666664
.iter()
667665
.filter_map(|c| (c.beacon.epoch == Epoch(1)).then_some(c.to_owned().into()))
666+
.rev()
668667
.collect();
669668
assert_eq!(expected_certificate_records, certificate_records);
670669

@@ -673,15 +672,19 @@ mod tests {
673672
let expected_certificate_records: Vec<CertificateRecord> = certificates
674673
.iter()
675674
.filter_map(|c| (c.beacon.epoch == Epoch(3)).then_some(c.to_owned().into()))
675+
.rev()
676676
.collect();
677677
assert_eq!(expected_certificate_records, certificate_records);
678678

679679
let cursor = provider.get_by_epoch(&Epoch(5)).unwrap();
680680
assert_eq!(0, cursor.count());
681681

682682
let certificate_records: Vec<CertificateRecord> = provider.get_all().unwrap().collect();
683-
let expected_certificate_records: Vec<CertificateRecord> =
684-
certificates.iter().map(|c| c.to_owned().into()).collect();
683+
let expected_certificate_records: Vec<CertificateRecord> = certificates
684+
.iter()
685+
.map(|c| c.to_owned().into())
686+
.rev()
687+
.collect();
685688
assert_eq!(expected_certificate_records, certificate_records);
686689
}
687690

@@ -740,6 +743,7 @@ mod tests {
740743
.unwrap()
741744
.into_iter()
742745
.map(|(_k, v)| v)
746+
.rev()
743747
.collect::<Vec<Certificate>>()
744748
)
745749
}

0 commit comments

Comments
 (0)