refactor(serverless): remove dead code introduced on branch

- Delete orphaned HarnessRelay::connect() wrapper (callers use
  connect_with_mode); fold its doc into connect_with_mode.
- Gate BgState::new() behind #[cfg(test)] (test-only now that the
  runtime path uses with_serverless) instead of #[allow(dead_code)].
- Move KIND_GIFT_WRAP into the encrypted test module (test-only).

No #[allow(dead_code)] / cfg_attr dead-code suppressions remain on
branch-new code. Verified with RUSTFLAGS='-D dead_code -D unused'.
This commit is contained in:
Michael Neale
2026-06-02 11:32:39 +10:00
parent 191de54143
commit ba335aed2a
2 changed files with 8 additions and 21 deletions

View File

@@ -656,24 +656,12 @@ impl RelayEventPublisher {
impl HarnessRelay {
// ── Public API ────────────────────────────────────────────────────────────
/// Connect to relay and authenticate via NIP-42.
/// Connect to the relay, optionally in serverless mode (generic relay, AUTH
/// optional, plain-WS reads/writes). In server mode (`serverless = false`)
/// the NIP-42 AUTH handshake is performed; in serverless mode it is skipped.
///
/// `auth_tag` is an optional NIP-OA owner attestation included in the AUTH
/// event for relay membership delegation.
/// Server-mode convenience wrapper around [`HarnessRelay::connect_with_mode`].
/// Kept as part of the public API; the binary uses `connect_with_mode`.
#[allow(dead_code)]
pub async fn connect(
relay_url: &str,
keys: &Keys,
agent_pubkey_hex: &str,
auth_tag: Option<nostr::Tag>,
) -> Result<Self, RelayError> {
Self::connect_with_mode(relay_url, keys, agent_pubkey_hex, auth_tag, false).await
}
/// Connect, optionally in serverless mode (generic relay, AUTH optional,
/// plain-WS reads/writes). See [`HarnessRelay::connect`].
pub async fn connect_with_mode(
relay_url: &str,
keys: &Keys,
@@ -1133,9 +1121,9 @@ struct BgState {
}
impl BgState {
/// Server-mode constructor. Used by unit tests; the runtime path uses
/// Server-mode constructor. Test-only; the runtime path uses
/// [`BgState::with_serverless`].
#[allow(dead_code)]
#[cfg(test)]
fn new() -> Self {
Self::with_serverless(false)
}

View File

@@ -26,10 +26,6 @@
use nostr::nips::nip59::UnwrappedGift;
use nostr::{Event, EventBuilder, Keys, PublicKey, UnsignedEvent};
/// Kind 1059 — NIP-59 gift wrap.
#[cfg_attr(not(test), allow(dead_code))]
pub const KIND_GIFT_WRAP: u16 = 1059;
/// Build the gift-wrapped events for `rumor`, one per recipient pubkey.
///
/// `rumor` is the unsigned inner event (a normal kind-9 message with the `h`
@@ -99,6 +95,9 @@ impl UnwrappedRumor {
#[cfg(test)]
mod tests {
use super::*;
/// Kind 1059 — NIP-59 gift wrap (test-only constant).
const KIND_GIFT_WRAP: u16 = 1059;
use nostr::Kind;
fn rumor(sender: &Keys, channel_id: &str, content: &str) -> UnsignedEvent {