mirror of
https://github.com/block/buzz.git
synced 2026-12-01 13:42:45 +00:00
fix(relay-mt): clear clippy -D warnings introduced by tenant threading
CI Rust Lint + Windows Rust run `cargo clippy --workspace --all-targets -- -D warnings`; the community_id/tenant args pushed six fns to 8/7 and the new NIP-98 replay code tripped clamp/const-assert lints. Resolve at the bar, matching existing repo conventions: - 6x #[allow(clippy::too_many_arguments)] on the fns that gained a tenant/community arg (same convention already used across buzz-db/relay). - buzz-pubsub replay TTL: .max().min() -> .clamp() (floor 120 < ceiling 3600, cannot panic; behavior identical, incl. the u64::MAX clamp test). - buzz-auth replay const-drift tripwires: scoped #[allow(clippy::assertions_on_constants)] — the assert-on-constant IS the design (fails if someone drifts the TTL constants). Co-authored-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co> Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com>
This commit is contained in:
@@ -192,7 +192,11 @@ mod tests {
|
||||
#[test]
|
||||
fn default_ttl_meets_gate_floor() {
|
||||
// §5 gate: TTL ≥ 120s. Drift this constant down and the gate breaks.
|
||||
assert!(DEFAULT_REPLAY_TTL_SECS >= 120);
|
||||
// Const-drift tripwire: the assertion is intentionally over a constant.
|
||||
#[allow(clippy::assertions_on_constants)]
|
||||
{
|
||||
assert!(DEFAULT_REPLAY_TTL_SECS >= 120);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -200,7 +204,11 @@ mod tests {
|
||||
// Sanity: any caller's clamped TTL must end up in [DEFAULT, MAX].
|
||||
// If these ever cross, the impl can't satisfy both bounds and the
|
||||
// contract is broken.
|
||||
assert!(DEFAULT_REPLAY_TTL_SECS < MAX_REPLAY_TTL_SECS);
|
||||
// Const-drift tripwire: the assertion is intentionally over a constant.
|
||||
#[allow(clippy::assertions_on_constants)]
|
||||
{
|
||||
assert!(DEFAULT_REPLAY_TTL_SECS < MAX_REPLAY_TTL_SECS);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -46,6 +46,7 @@ pub async fn is_archived(pool: &PgPool, community_id: CommunityId, pubkey: &str)
|
||||
/// Returns `true` if the row was inserted, `false` if the identity was already
|
||||
/// archived in that community. Re-archiving is idempotent and does not mutate
|
||||
/// the existing row.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn archive(
|
||||
pool: &PgPool,
|
||||
community_id: CommunityId,
|
||||
|
||||
@@ -83,6 +83,7 @@ pub struct MemberRecord {
|
||||
}
|
||||
|
||||
/// Creates a new channel, bootstraps the creator as owner, and returns the record.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn create_channel(
|
||||
pool: &PgPool,
|
||||
community_id: CommunityId,
|
||||
@@ -1388,6 +1389,7 @@ mod tests {
|
||||
id
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn create_test_channel(
|
||||
pool: &PgPool,
|
||||
community_id: Uuid,
|
||||
|
||||
@@ -463,6 +463,7 @@ impl Db {
|
||||
}
|
||||
|
||||
/// Creates a new channel, bootstraps the creator as owner, and returns the record.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn create_channel(
|
||||
&self,
|
||||
community_id: CommunityId,
|
||||
@@ -1754,6 +1755,7 @@ impl Db {
|
||||
}
|
||||
|
||||
/// Archives an identity in `community_id`. Returns `true` if inserted, `false` if already archived.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn archive(
|
||||
&self,
|
||||
community_id: CommunityId,
|
||||
|
||||
@@ -44,9 +44,7 @@ impl Nip98ReplayGuard for RedisNip98ReplayGuard {
|
||||
// down to MAX_REPLAY_TTL_SECS (contract REQUIRES clamping) so a buggy
|
||||
// caller cannot send a Redis-incompatible `EX` arg or pin a slot for
|
||||
// implausibly long.
|
||||
let ttl = ttl_secs
|
||||
.max(DEFAULT_REPLAY_TTL_SECS)
|
||||
.min(MAX_REPLAY_TTL_SECS);
|
||||
let ttl = ttl_secs.clamp(DEFAULT_REPLAY_TTL_SECS, MAX_REPLAY_TTL_SECS);
|
||||
|
||||
let mut conn = self.pool.get().await.map_err(|e| {
|
||||
// Structured field for ops; the user-facing AuthError stays a
|
||||
|
||||
@@ -2718,6 +2718,7 @@ pub async fn publish_nipia_archived(
|
||||
}
|
||||
|
||||
/// Publish a kind:8003 unarchived-identity delta event (NIP-IA).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn publish_nipia_unarchived(
|
||||
tenant: &TenantContext,
|
||||
state: &Arc<AppState>,
|
||||
|
||||
Reference in New Issue
Block a user