#[cfg(test)]
mod tests {
use forge_guard::security::checks;
#[test]
fn test_all_checks_registered() {
assert!(!checks::ALL_CHECKS.is_empty());
assert!(checks::check_count() >= 35);
}
#[test]
fn test_check_ids_are_unique() {
use std::collections::HashSet;
let mut ids = HashSet::new();
for check in checks::ALL_CHECKS {
assert!(ids.insert(check.id), "Duplicate check ID: {}", check.id);
}
}
#[test]
fn test_high_severity_checks_block_deployment() {
let high_checks: Vec<_> = checks::ALL_CHECKS
.iter()
.filter(|c| c.severity == "high" || c.severity == "critical")
.collect();
assert!(!high_checks.is_empty());
for check in &high_checks {
assert!(
check.blocks_deployment,
"Check {} should block deployment",
check.id
);
}
}
#[test]
fn test_check_categories_are_valid() {
let valid_categories = [
"Access Control",
"Logic",
"Security",
"DeFi",
"Upgradeability",
"Deployment",
"Gas",
"Best Practices",
"Style",
"Architecture",
"Documentation",
"Cryptography",
"Cross-Chain",
"Dependencies",
"Standards",
];
for check in checks::ALL_CHECKS {
assert!(
valid_categories.contains(&check.category),
"Check {} has invalid category: {}",
check.id,
check.category
);
}
}
#[test]
fn test_reentrancy_check_meta() {
let check = &checks::REENTRANCY;
assert_eq!(check.id, "FA-H-001");
assert_eq!(check.severity, "high");
assert!(check.blocks_deployment);
}
#[test]
fn test_access_control_check_meta() {
let check = &checks::ACCESS_CONTROL;
assert_eq!(check.id, "FA-H-002");
assert!(check.blocks_deployment);
}
}