From edd16089db6554f00a1f6d1e5b6d53e8f600c9c2 Mon Sep 17 00:00:00 2001 From: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 Date: Sat, 11 Jul 2026 17:52:45 -0400 Subject: [PATCH] =?UTF-8?q?test(relay):=20fix=20test=5Fdraft=5Frejected=5F?= =?UTF-8?q?p=5Ftag=20=E2=80=94=20use=20third-party=20pubkey=20in=20p=20tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EventBuilder silently drops p tags whose value equals the signer's own pubkey (NIP self-tagging suppression, enabled by default). The test was using owner.public_key().to_hex() as the p tag value, so the tag was stripped before signing and the event arrived at the relay with no p tag at all — the validator always saw a clean envelope and the rejection was never exercised. Fix: generate a separate Keys pair for the p tag value so it survives EventBuilder's self-tag filter and reaches the relay's validator. Co-authored-by: Will Pfleger Signed-off-by: Will Pfleger --- crates/buzz-test-client/tests/e2e_nip37_draft.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/buzz-test-client/tests/e2e_nip37_draft.rs b/crates/buzz-test-client/tests/e2e_nip37_draft.rs index 19f1e2e3a..f10afe2ca 100644 --- a/crates/buzz-test-client/tests/e2e_nip37_draft.rs +++ b/crates/buzz-test-client/tests/e2e_nip37_draft.rs @@ -733,6 +733,11 @@ async fn test_draft_rejected_k_tag_out_of_range() { async fn test_draft_rejected_p_tag() { let client = http_client(); let owner = Keys::generate(); + // Use a different pubkey for the `p` tag — EventBuilder silently strips + // `p` tags that match the signer's own key (NIP self-tagging rule), so + // testing with owner.public_key() would produce an event with NO `p` tag + // and the rejection would never be exercised. + let other = Keys::generate(); let ch_id = create_open_channel(&owner).await; let d = uuid::Uuid::new_v4().to_string(); let event = EventBuilder::new(Kind::Custom(KIND_DRAFT), fake_nip44_v2()) @@ -740,7 +745,7 @@ async fn test_draft_rejected_p_tag() { Tag::parse(["d", &d]).unwrap(), Tag::parse(["k", "9"]).unwrap(), Tag::parse(["h", &ch_id]).unwrap(), - Tag::parse(["p", &owner.public_key().to_hex()]).unwrap(), + Tag::parse(["p", &other.public_key().to_hex()]).unwrap(), ]) .sign_with_keys(&owner) .unwrap();