From 9d45d481f8c5e096b61f2b7abecf7eb31150af93 Mon Sep 17 00:00:00 2001 From: chappie-daemon Date: Sun, 1 Nov 2026 18:10:31 -0500 Subject: [PATCH 1/2] test(relay): say what the refusal pin test holds --- .changeset/refusal-pin-message.md | 11 +++++++++++ crates/nostream-relay/src/sink.rs | 8 +++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .changeset/refusal-pin-message.md diff --git a/.changeset/refusal-pin-message.md b/.changeset/refusal-pin-message.md new file mode 100644 index 00000000..dd0d17e9 --- /dev/null +++ b/.changeset/refusal-pin-message.md @@ -0,0 +1,11 @@ +--- +--- + +test(relay): say what the refusal pin test holds + +`every_refusal_word_is_pinned_to_its_byte`'s failure message no longer says the refusal bytes +travel. They do not: the word is a process-local `AtomicU8` (`Refusal::from_word`'s doc, +`crates/nostream-relay/src/sink.rs:92-98`), and a refused client receives a `1013` close with +a reason string. The message now names the pin it holds — the three bytes, `word()`'s arms and +the enum's discriminants are the same numbers — and is declared once, as +`PINNED_BYTES_MESSAGE`. Test-only: no production code path, no behaviour change. diff --git a/crates/nostream-relay/src/sink.rs b/crates/nostream-relay/src/sink.rs index 7ef90848..3bd80598 100644 --- a/crates/nostream-relay/src/sink.rs +++ b/crates/nostream-relay/src/sink.rs @@ -420,6 +420,11 @@ mod tests { use super::*; use nostream_core::messages::NoticeMessage; + /// The failure message of the pin test below, so the wording has one definition; it states + /// what the pin holds and makes no claim about where the word lives (`from_word`'s doc). + const PINNED_BYTES_MESSAGE: &str = + "the refusal bytes are pinned to 0, 1, 2 — the numbers word() returns and the enum stores"; + fn notice(message: &str) -> RelayMessage { RelayMessage::Notice(NoticeMessage { message: message.to_owned(), @@ -698,7 +703,8 @@ mod tests { assert_eq!( (NO_REFUSAL, QUEUE_FULL, BUDGET_EXHAUSTED), (0, 1, 2), - "the bytes are the wire contract" + "{}", + PINNED_BYTES_MESSAGE ); for refusal in [Refusal::None, Refusal::QueueFull, Refusal::BudgetExhausted] { From 712cce58d3c3291e0fed715d2d02785d84c6e1f5 Mon Sep 17 00:00:00 2001 From: chappie-daemon Date: Sun, 1 Nov 2026 18:28:45 -0500 Subject: [PATCH 2/2] test(relay): inline the pin test's failure message --- .changeset/refusal-pin-message.md | 4 ++-- crates/nostream-relay/src/sink.rs | 8 +------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.changeset/refusal-pin-message.md b/.changeset/refusal-pin-message.md index dd0d17e9..2f015151 100644 --- a/.changeset/refusal-pin-message.md +++ b/.changeset/refusal-pin-message.md @@ -7,5 +7,5 @@ test(relay): say what the refusal pin test holds travel. They do not: the word is a process-local `AtomicU8` (`Refusal::from_word`'s doc, `crates/nostream-relay/src/sink.rs:92-98`), and a refused client receives a `1013` close with a reason string. The message now names the pin it holds — the three bytes, `word()`'s arms and -the enum's discriminants are the same numbers — and is declared once, as -`PINNED_BYTES_MESSAGE`. Test-only: no production code path, no behaviour change. +the enum's discriminants are the same numbers — and stays the inline literal it was. +Test-only: no production code path, no behaviour change. diff --git a/crates/nostream-relay/src/sink.rs b/crates/nostream-relay/src/sink.rs index 3bd80598..579ea779 100644 --- a/crates/nostream-relay/src/sink.rs +++ b/crates/nostream-relay/src/sink.rs @@ -420,11 +420,6 @@ mod tests { use super::*; use nostream_core::messages::NoticeMessage; - /// The failure message of the pin test below, so the wording has one definition; it states - /// what the pin holds and makes no claim about where the word lives (`from_word`'s doc). - const PINNED_BYTES_MESSAGE: &str = - "the refusal bytes are pinned to 0, 1, 2 — the numbers word() returns and the enum stores"; - fn notice(message: &str) -> RelayMessage { RelayMessage::Notice(NoticeMessage { message: message.to_owned(), @@ -703,8 +698,7 @@ mod tests { assert_eq!( (NO_REFUSAL, QUEUE_FULL, BUDGET_EXHAUSTED), (0, 1, 2), - "{}", - PINNED_BYTES_MESSAGE + "the refusal bytes are pinned to 0, 1, 2 — the numbers word() returns and the enum stores" ); for refusal in [Refusal::None, Refusal::QueueFull, Refusal::BudgetExhausted] {