commit cc2b3b030ed2aaf4e370f3b5a7b60cdf012b9770
parent 3f2d24e1274a4dfc17c433ea1f8e6dd4afaef892
Author: triesap <tyson@radroots.org>
Date: Sun, 19 Jul 2026 20:39:51 +0000
tests: isolate protocol wire fixtures
Add a test-only direct Nostr dependency for constructing already-signed relay fixtures at the explicit low-level boundary.
Remove Studio tests from the retired generic radroots_nostr authoring helper while preserving tag parsing and self-tag behavior.
Diffstat:
4 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
@@ -5124,6 +5124,7 @@ dependencies = [
"mediatype",
"serde",
"sha2",
+ "unicode-general-category",
"url",
]
@@ -5148,6 +5149,7 @@ dependencies = [
"serde",
"serde_json",
"sha2",
+ "unicode-general-category",
"url",
]
@@ -5156,6 +5158,7 @@ name = "radroots_event_codec"
version = "1.0.0-alpha.1"
dependencies = [
"nostr",
+ "radroots_blossom",
"radroots_core",
"radroots_event",
"serde",
@@ -5418,6 +5421,7 @@ dependencies = [
"gpui",
"gpui-component",
"gpui-component-assets",
+ "nostr",
"radroots_core",
"radroots_event",
"radroots_event_codec",
@@ -7869,6 +7873,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce61d488bcdc9bc8b5d1772c404828b17fc481c0a582b5581e95fb233aef503e"
[[package]]
+name = "unicode-general-category"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b993bddc193ae5bd0d623b49ec06ac3e9312875fdae725a975c51db1cc1677f"
+
+[[package]]
name = "unicode-id"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
@@ -32,6 +32,7 @@ gpui = "0.2.2"
gpui-component = "0.5.1"
gpui-component-assets = "0.5.1"
mf2_i18n = { version = "=0.1.0", git = "https://github.com/triesap/mf2_i18n.git", rev = "e95f0fe090764dc62f5f67f4ff9e207d7e1cd901", default-features = false }
+nostr = "0.44.2"
radroots_core = { version = "=1.0.0-alpha.1", path = "../lib/crates/core", default-features = false, features = ["std"] }
radroots_authority = { version = "=1.0.0-alpha.1", path = "../lib/crates/authority" }
radroots_event = { version = "=1.0.0-alpha.1", path = "../lib/crates/event", default-features = false, features = ["serde", "std"] }
diff --git a/crates/desktop/Cargo.toml b/crates/desktop/Cargo.toml
@@ -42,6 +42,7 @@ tracing.workspace = true
uuid.workspace = true
[dev-dependencies]
+nostr.workspace = true
radroots_studio_app_sqlite = { workspace = true, features = ["test-support"] }
tracing-subscriber.workspace = true
diff --git a/crates/desktop/src/runtime.rs b/crates/desktop/src/runtime.rs
@@ -8855,6 +8855,7 @@ mod tests {
use chrono::{Duration, Utc};
use futures_util::{SinkExt, StreamExt};
+ use nostr::{EventBuilder, Kind, Tag};
use radroots_event::ids::{
RadrootsAddressableCoordinate, RadrootsDTag, RadrootsEventId, RadrootsInventoryBinId,
RadrootsPublicKey, RadrootsTradeId,
@@ -8874,7 +8875,7 @@ mod tests {
use radroots_identity::{RadrootsIdentity, RadrootsIdentityId};
use radroots_nostr::prelude::{
RadrootsNostrClient, RadrootsNostrEvent, RadrootsNostrKeys, RadrootsNostrSecretKey,
- RadrootsNostrTimestamp, radroots_event_from_nostr, radroots_nostr_build_event,
+ RadrootsNostrTimestamp, radroots_event_from_nostr,
};
use radroots_nostr_accounts::prelude::{
RadrootsNostrAccountsManager, RadrootsNostrFileAccountStore,
@@ -9331,14 +9332,26 @@ mod tests {
) -> RadrootsEventEnvelope {
let secret_key = RadrootsNostrSecretKey::from_hex(secret_key_hex).expect("secret key");
let keys = RadrootsNostrKeys::new(secret_key);
- let event = radroots_nostr_build_event(parts.kind, parts.content, parts.tags)
- .expect("test event builder")
+ let event = wire_fixture_builder(parts)
.custom_created_at(RadrootsNostrTimestamp::from_secs(u64::from(created_at)))
.sign_with_keys(&keys)
.expect("test event should sign");
radroots_event_from_nostr(&event)
}
+ fn wire_fixture_builder(parts: WireEventParts) -> EventBuilder {
+ let kind = u16::try_from(parts.kind).expect("fixture kind must fit NIP-01");
+ let tags = parts
+ .tags
+ .into_iter()
+ .filter(|tag| !tag.is_empty())
+ .map(|tag| Tag::parse(tag).expect("fixture tag must parse"))
+ .collect::<Vec<_>>();
+ EventBuilder::new(Kind::Custom(kind), parts.content)
+ .tags(tags)
+ .allow_self_tagging()
+ }
+
fn signed_test_event_for_pubkey(
pubkey: &str,
created_at: u32,
@@ -9887,8 +9900,7 @@ mod tests {
.expect("listing payload should convert to SDK listing");
let parts = radroots_event_codec::listing::encode::to_wire_parts(&listing)
.expect("listing draft should build");
- let event = radroots_nostr_build_event(parts.kind, parts.content, parts.tags)
- .expect("listing event builder should build")
+ let event = wire_fixture_builder(parts)
.sign_with_keys(identity.keys())
.expect("listing event should sign");
publish_signed_test_event_to_relay(relay, &event);
@@ -18874,8 +18886,7 @@ mod tests {
.expect("trade decision envelope should build");
let parts = trade_mutation_event_build(envelope)
.expect("trade decision event builder should build");
- let event = radroots_nostr_build_event(parts.kind, parts.content, parts.tags)
- .expect("trade decision event builder should build")
+ let event = wire_fixture_builder(parts)
.sign_with_keys(identity.keys())
.expect("trade decision event should sign");
publish_signed_test_event_to_relay(relay, &event);
@@ -19108,8 +19119,7 @@ mod tests {
let secret_key = RadrootsNostrSecretKey::from_hex(SDK_TEST_BUYER_SECRET_KEY_HEX)
.expect("SDK test buyer secret key should parse");
let keys = RadrootsNostrKeys::new(secret_key);
- let signed_event = radroots_nostr_build_event(parts.kind, parts.content, parts.tags)
- .expect("trade proposal event should build")
+ let signed_event = wire_fixture_builder(parts)
.custom_created_at(RadrootsNostrTimestamp::from_secs(1_774_000_010))
.sign_with_keys(&keys)
.expect("trade proposal event should sign");