Skip to content

Commit 54e4899

Browse files
committed
style: apply cargo fmt formatting
1 parent c3832d1 commit 54e4899

4 files changed

Lines changed: 21 additions & 45 deletions

File tree

trustchain-core/src/protocol.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,7 @@ impl<S: BlockStore> TrustChainProtocol<S> {
393393
if let Some(schema_id) = SchemaId::from_str_loose(schema_name) {
394394
for (i, entry) in entries.iter().enumerate() {
395395
validate_transaction(&schema_id, entry).map_err(|e| {
396-
TrustChainError::validation(format!(
397-
"batch entry {i}: {e}"
398-
))
396+
TrustChainError::validation(format!("batch entry {i}: {e}"))
399397
})?;
400398
}
401399
}
@@ -1767,7 +1765,10 @@ mod tests {
17671765
assert!(result.is_err());
17681766

17691767
// No blocks should have been created (atomic).
1770-
assert_eq!(proto.store().get_latest_seq(&alice.pubkey_hex()).unwrap(), 0);
1768+
assert_eq!(
1769+
proto.store().get_latest_seq(&alice.pubkey_hex()).unwrap(),
1770+
0
1771+
);
17711772
}
17721773

17731774
#[test]

trustchain-core/src/schema.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,7 @@ pub fn validate_transaction(schema: &SchemaId, transaction: &serde_json::Value)
5454
}
5555
SchemaId::AiAct => {
5656
// Base fields + AI Act Article 12 traceability fields
57-
let required = [
58-
"action",
59-
"outcome",
60-
"model",
61-
"input_hash",
62-
"output_hash",
63-
];
57+
let required = ["action", "outcome", "model", "input_hash", "output_hash"];
6458
required
6559
.iter()
6660
.filter(|&&f| !obj.contains_key(f))
@@ -83,7 +77,9 @@ pub fn validate_transaction(schema: &SchemaId, transaction: &serde_json::Value)
8377
} else {
8478
Err(TrustChainError::validation(format!(
8579
"schema '{}' requires missing fields: {}",
86-
serde_json::to_string(schema).unwrap_or_default().trim_matches('"'),
80+
serde_json::to_string(schema)
81+
.unwrap_or_default()
82+
.trim_matches('"'),
8783
missing.join(", ")
8884
)))
8985
}

trustchain-core/src/trust.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,9 +2172,7 @@ mod tests {
21722172
let store = MemoryBlockStore::new();
21732173
let engine = TrustEngine::new(&store, None, None, None);
21742174
let alice = Identity::from_bytes(&[1u8; 32]);
2175-
let report = engine
2176-
.compute_audit_report(&alice.pubkey_hex())
2177-
.unwrap();
2175+
let report = engine.compute_audit_report(&alice.pubkey_hex()).unwrap();
21782176
assert_eq!(report.total_blocks, 0);
21792177
assert_eq!(report.audit_blocks, 0);
21802178
assert_eq!(report.bilateral_blocks, 0);
@@ -2217,9 +2215,7 @@ mod tests {
22172215
store.add_block(&b3).unwrap();
22182216

22192217
let engine = TrustEngine::new(&store, None, None, None);
2220-
let report = engine
2221-
.compute_audit_report(&alice.pubkey_hex())
2222-
.unwrap();
2218+
let report = engine.compute_audit_report(&alice.pubkey_hex()).unwrap();
22232219

22242220
assert_eq!(report.total_blocks, 3);
22252221
assert_eq!(report.audit_blocks, 3);
@@ -2246,9 +2242,7 @@ mod tests {
22462242
store.add_block(&b1).unwrap();
22472243

22482244
let engine = TrustEngine::new(&store, None, None, None);
2249-
let report = engine
2250-
.compute_audit_report(&alice.pubkey_hex())
2251-
.unwrap();
2245+
let report = engine.compute_audit_report(&alice.pubkey_hex()).unwrap();
22522246

22532247
assert_eq!(report.audit_blocks, 1);
22542248
assert_eq!(report.event_type_breakdown.get("untyped"), Some(&1));
@@ -2287,9 +2281,7 @@ mod tests {
22872281
store.add_block(&proposal).unwrap();
22882282

22892283
let engine = TrustEngine::new(&store, None, None, None);
2290-
let report = engine
2291-
.compute_audit_report(&alice.pubkey_hex())
2292-
.unwrap();
2284+
let report = engine.compute_audit_report(&alice.pubkey_hex()).unwrap();
22932285

22942286
assert_eq!(report.total_blocks, 2);
22952287
assert_eq!(report.audit_blocks, 1);

trustchain-transport/src/proxy.rs

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ async fn proxy_handler<S: BlockStore + 'static, D: DelegationStore + 'static>(
218218
// Check if this event type should be recorded under the current audit config.
219219
if let Some(et) = trustchain_core::EventType::from_str_loose(&event_type) {
220220
if !proto.should_record_event(&et) {
221-
log::debug!("skipping audit block for {auth} (event_type '{event_type}' disabled)");
221+
log::debug!(
222+
"skipping audit block for {auth} (event_type '{event_type}' disabled)"
223+
);
222224
} else {
223225
let tx = serde_json::json!({
224226
"event_type": event_type,
@@ -737,10 +739,7 @@ fn classify_event(authority: &str, path: &str) -> String {
737739

738740
// Check against known tool/action path patterns.
739741
let path_lower = path.to_lowercase();
740-
if TOOL_PATH_PATTERNS
741-
.iter()
742-
.any(|&p| path_lower.contains(p))
743-
{
742+
if TOOL_PATH_PATTERNS.iter().any(|&p| path_lower.contains(p)) {
744743
return "tool_call".to_string();
745744
}
746745

@@ -884,18 +883,9 @@ mod tests {
884883
classify_event("my-service:8080", "/api/tool/run"),
885884
"tool_call"
886885
);
887-
assert_eq!(
888-
classify_event("localhost:9000", "/execute"),
889-
"tool_call"
890-
);
891-
assert_eq!(
892-
classify_event("agent-b:8202", "/v1/invoke"),
893-
"tool_call"
894-
);
895-
assert_eq!(
896-
classify_event("example.com", "/call_tool"),
897-
"tool_call"
898-
);
886+
assert_eq!(classify_event("localhost:9000", "/execute"), "tool_call");
887+
assert_eq!(classify_event("agent-b:8202", "/v1/invoke"), "tool_call");
888+
assert_eq!(classify_event("example.com", "/call_tool"), "tool_call");
899889
}
900890

901891
#[test]
@@ -904,9 +894,6 @@ mod tests {
904894
classify_event("api.stripe.com", "/v1/charges"),
905895
"external_api"
906896
);
907-
assert_eq!(
908-
classify_event("example.com", "/api/data"),
909-
"external_api"
910-
);
897+
assert_eq!(classify_event("example.com", "/api/data"), "external_api");
911898
}
912899
}

0 commit comments

Comments
 (0)