lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

commit 0ce314697a6e87c6434d44e785ab7fac352348af
parent fa6802ef6800a3e6cddda266b71fa48598ca3e16
Author: triesap <tyson@radroots.org>
Date:   Fri, 26 Jun 2026 08:41:40 +0000

sdk: assert canonical storage tables

- Update direct SDK storage test SQL to use nostr_events.
- Assert directory storage creates canonical event and outbox table names.
- Guard against retired singular storage table names in SDK tests.
- Keep the table-name break covered by runtime foundation validation.

Diffstat:
Mcrates/sdk/tests/orders_runtime.rs | 2+-
Mcrates/sdk/tests/runtime_foundation.rs | 28+++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/crates/sdk/tests/orders_runtime.rs b/crates/sdk/tests/orders_runtime.rs @@ -3570,7 +3570,7 @@ async fn order_status_maps_malformed_local_data_to_sanitized_error() { .ingest_event(RadrootsEventIngest::new(request_event.clone(), 3_000)) .await .expect("ingest"); - sqlx::query("UPDATE nostr_event SET tags_json = '[' WHERE event_id = ?") + sqlx::query("UPDATE nostr_events SET tags_json = '[' WHERE event_id = ?") .bind(request_event.id.as_str()) .execute(store.pool()) .await diff --git a/crates/sdk/tests/runtime_foundation.rs b/crates/sdk/tests/runtime_foundation.rs @@ -9,7 +9,8 @@ use radroots_sdk::{ SdkRelayTargetSet, SdkRelayUrlPolicy, SdkRestoreState, SdkSqliteStoreStatus, SdkStorageKind, StorageStatusReceipt, StorageStatusRequest, }; -use std::path::PathBuf; +use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; +use std::path::{Path, PathBuf}; #[tokio::test] async fn sdk_builder_defaults_to_memory_storage_and_no_relays() { @@ -150,6 +151,14 @@ async fn sdk_directory_storage_creates_deterministic_sqlite_files() { ); assert!(paths.event_store_path.exists()); assert!(paths.outbox_path.exists()); + let event_tables = sqlite_table_names(&paths.event_store_path).await; + assert!(event_tables.iter().any(|name| name == "nostr_events")); + assert!(event_tables.iter().any(|name| name == "nostr_event_tags")); + assert!(!event_tables.iter().any(|name| name == "nostr_event")); + assert!(!event_tables.iter().any(|name| name == "nostr_event_tag")); + let outbox_tables = sqlite_table_names(&paths.outbox_path).await; + assert!(outbox_tables.iter().any(|name| name == "outbox_operations")); + assert!(!outbox_tables.iter().any(|name| name == "outbox_operation")); } #[tokio::test] @@ -777,6 +786,23 @@ fn outbox_idempotency_conflict_maps_to_structured_sdk_error() { assert!(!message.contains(&"c".repeat(64))); } +async fn sqlite_table_names(path: &Path) -> Vec<String> { + let options = SqliteConnectOptions::new().filename(path).read_only(true); + let pool = SqlitePoolOptions::new() + .max_connections(1) + .connect_with(options) + .await + .expect("open sqlite for table inspection"); + let names = sqlx::query_scalar::<_, String>( + "SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name", + ) + .fetch_all(&pool) + .await + .expect("table names"); + pool.close().await; + names +} + #[test] fn sdk_examples_stay_on_product_api_boundary() { let examples = [