chore: pre-migration snapshot
Fleet monitoring/control plane: UI, node agent, ops wiring
This commit is contained in:
41
command-center/tests/receipt_adapter.rs
Normal file
41
command-center/tests/receipt_adapter.rs
Normal file
@@ -0,0 +1,41 @@
|
||||
use time::OffsetDateTime;
|
||||
use uuid::Uuid;
|
||||
use vaultmesh_command_center::contracts::map_event_envelope_to_receipt::map_event_envelope_to_receipt;
|
||||
use vaultmesh_command_center::contracts::receipt_v1::{genesis_prev_blake3, ReceiptV1};
|
||||
use vaultmesh_command_center::state::EventEnvelope;
|
||||
|
||||
#[test]
|
||||
fn maps_envelope_to_receipt_and_verifies_hashes() {
|
||||
let id = Uuid::parse_str("00000000-0000-0000-0000-0000000000aa").unwrap();
|
||||
let ts = OffsetDateTime::parse(
|
||||
"2025-12-17T23:07:10Z",
|
||||
&time::format_description::well_known::Rfc3339,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let payload = serde_json::json!({
|
||||
"note": "hello",
|
||||
"details": {"x": 2, "a": 1},
|
||||
});
|
||||
|
||||
let env = EventEnvelope::new(
|
||||
id,
|
||||
ts,
|
||||
"note".to_string(),
|
||||
None,
|
||||
"operator".to_string(),
|
||||
payload,
|
||||
);
|
||||
|
||||
let receipt: ReceiptV1 = map_event_envelope_to_receipt(&env);
|
||||
|
||||
assert_eq!(receipt.receipt_version, "1");
|
||||
assert_eq!(receipt.source, "command-center");
|
||||
assert_eq!(receipt.action, "note");
|
||||
assert_eq!(receipt.prev_blake3, genesis_prev_blake3());
|
||||
assert!(!receipt.blake3.is_empty());
|
||||
assert!(!receipt.sha256.is_empty());
|
||||
|
||||
// Hashes must verify against canonical recomputation.
|
||||
receipt.verify_hashes().expect("hashes should verify");
|
||||
}
|
||||
Reference in New Issue
Block a user