lib

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

commit cc8fde0343779e72dba4fde685cb5758edf73a57
parent 278fbb64c1d84d4acede84a60a2afa40af82f6e9
Author: triesap <tyson@radroots.org>
Date:   Fri,  3 Jul 2026 22:39:22 +0000

tests: assert root-aware trade projection schema

- inspect SDK-created event stores for the trade_projection composite key
- prove order id, root event id, and projection version remain the durable primary key
- keep the check on the runtime foundation path that materializes SQLite storage
- verify focused SDK storage and ambiguity lanes through extbuild

Diffstat:
Mcrates/sdk/tests/runtime_foundation.rs | 37+++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+), 0 deletions(-)

diff --git a/crates/sdk/tests/runtime_foundation.rs b/crates/sdk/tests/runtime_foundation.rs @@ -12,6 +12,7 @@ use radroots_sdk::{ StorageStatusRequest, }; use radroots_trade::identity::RadrootsTradeLocator; +use sqlx::Row; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use std::path::{Path, PathBuf}; @@ -167,6 +168,10 @@ async fn sdk_directory_storage_creates_deterministic_sqlite_files() { assert!(event_tables.iter().any(|name| name == "listing_search_fts")); assert!(!event_tables.iter().any(|name| name == "nostr_event")); assert!(!event_tables.iter().any(|name| name == "nostr_event_tag")); + assert_eq!( + sqlite_trade_projection_primary_key(&paths.event_store_path).await, + vec!["order_id", "root_event_id", "projection_version"] + ); 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")); @@ -864,6 +869,38 @@ async fn sqlite_table_names(path: &Path) -> Vec<String> { names } +async fn sqlite_trade_projection_primary_key(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 trade projection inspection"); + let rows = sqlx::query("PRAGMA table_info(trade_projection)") + .fetch_all(&pool) + .await + .expect("trade projection table info"); + let mut primary_key = rows + .iter() + .filter_map(|row| { + let pk = row.try_get::<i64, _>("pk").expect("pk"); + (pk > 0).then(|| { + ( + pk, + row.try_get::<String, _>("name") + .expect("primary key column"), + ) + }) + }) + .collect::<Vec<_>>(); + primary_key.sort_by_key(|(pk, _)| *pk); + pool.close().await; + primary_key + .into_iter() + .map(|(_, name)| name) + .collect::<Vec<_>>() +} + #[test] fn sdk_examples_stay_on_product_api_boundary() { let examples = [