mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-10-18 19:10:30 +08:00
protocol: Do not panic on trivially empty duration
Any connected peer can send a `Subscribe` with `since` after `until`. The service passes the range to `Store::filtered`, which asserts `from <= to`. The panic stops the service thread. Remove the assertion. The query already returns no rows when `from > to`, so the peer gets no history.
This commit is contained in:
committed by
Lorenz Leutgeb
parent
a4aae610f4
commit
81d79077d0
@@ -601,6 +601,27 @@ fn announcement_rebroadcast_timestamp_filtered() {
|
|||||||
assert_eq!(relayed, second);
|
assert_eq!(relayed, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn announcement_rebroadcast_inverted_range() {
|
||||||
|
let mut amy = Peer::amy();
|
||||||
|
let bob = Peer::bob();
|
||||||
|
let cid = Peer::cid();
|
||||||
|
|
||||||
|
amy.connect_to(&bob);
|
||||||
|
amy.connect_from(&cid);
|
||||||
|
amy.outbox().for_each(drop);
|
||||||
|
|
||||||
|
amy.receive(
|
||||||
|
*cid.nid(),
|
||||||
|
Message::Subscribe(Subscribe {
|
||||||
|
filter: Filter::default(),
|
||||||
|
since: Timestamp::MAX,
|
||||||
|
until: Timestamp::MIN,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
assert_eq!(amy.relayed(*cid.nid()).count(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn announcement_relay() {
|
fn announcement_relay() {
|
||||||
let mut amy = Peer::amy();
|
let mut amy = Peer::amy();
|
||||||
|
|||||||
@@ -54,11 +54,6 @@ pub trait Store {
|
|||||||
|
|
||||||
/// Get all the latest gossip messages of all nodes, filtered by inventory filter and
|
/// Get all the latest gossip messages of all nodes, filtered by inventory filter and
|
||||||
/// announcement timestamps.
|
/// announcement timestamps.
|
||||||
///
|
|
||||||
/// # Panics
|
|
||||||
///
|
|
||||||
/// Panics if `from` > `to`.
|
|
||||||
///
|
|
||||||
fn filtered<'a>(
|
fn filtered<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
filter: &'a Filter,
|
filter: &'a Filter,
|
||||||
@@ -188,8 +183,6 @@ impl Store for Database {
|
|||||||
WHERE timestamp >= ?1 and timestamp < ?2
|
WHERE timestamp >= ?1 and timestamp < ?2
|
||||||
ORDER BY timestamp, node, type",
|
ORDER BY timestamp, node, type",
|
||||||
)?;
|
)?;
|
||||||
assert!(*from <= *to);
|
|
||||||
|
|
||||||
stmt.bind((1, &from))?;
|
stmt.bind((1, &from))?;
|
||||||
stmt.bind((2, &to))?;
|
stmt.bind((2, &to))?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user