diff --git a/src/control/firehose.rs b/src/control/firehose.rs index f1378f1..cc44c05 100644 --- a/src/control/firehose.rs +++ b/src/control/firehose.rs @@ -897,6 +897,27 @@ mod tests { Ok(()) } + #[tokio::test] + async fn pds_info_reads_a_stored_big_endian_cursor() -> Result<()> { + let dir = tempfile::tempdir().into_diagnostic()?; + let hydrant = Hydrant::new(test_config(&dir)).await?; + let url = Url::parse("wss://stored.example/").into_diagnostic()?; + hydrant + .state + .db + .cursors + .insert( + keys::firehose_cursor_key_from_url(&url), + [0, 0, 0, 0, 0, 0, 1, 2], + ) + .into_diagnostic()?; + + let meta = hydrant.state.pds_meta.load(); + let info = hydrant.firehose.pds_info(&url, &meta); + assert_eq!(info.map(|info| info.seq), Some(258)); + Ok(()) + } + #[tokio::test] async fn admin_override_clears_public_provenance_in_memory_and_db() -> Result<()> { let dir = tempfile::tempdir().into_diagnostic()?; diff --git a/src/control/hosts.rs b/src/control/hosts.rs index 9fb8a56..fa757e8 100644 --- a/src/control/hosts.rs +++ b/src/control/hosts.rs @@ -584,6 +584,9 @@ mod host_listing_tests { assert_eq!(active.account_count, 42); assert_eq!(active.status, HostStatus::Active); + let status = hydrant.get_host_status("active.example").await?; + assert_eq!(status.map(|host| host.seq), Some(123)); + Ok(()) } diff --git a/src/control/stream/relay.rs b/src/control/stream/relay.rs index 450ac3e..76d43d4 100644 --- a/src/control/stream/relay.rs +++ b/src/control/stream/relay.rs @@ -78,3 +78,27 @@ fn read_relay_replay_chunk( |_, frame| Some(bytes::Bytes::copy_from_slice(frame)), ) } + +#[cfg(test)] +mod tests { + use super::*; + use crate::config::Config; + + #[test] + fn replay_reads_big_endian_relay_seqs() { + let tmp = tempfile::tempdir().unwrap(); + let db = crate::db::Db::open(&Config { + database_path: tmp.path().to_path_buf(), + ..Default::default() + }) + .unwrap(); + db.relay + .events + .insert([0, 0, 0, 0, 0, 0, 1, 2], b"frame") + .unwrap(); + + let chunk = read_relay_replay_chunk(&db.relay.events, Some(257), None, 8).unwrap(); + assert_eq!(chunk.last_seen, Some(258)); + assert_eq!(chunk.events, [bytes::Bytes::from_static(b"frame")]); + } +}