Skip to content

Commit

Permalink
small template fixes (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexroan authored Apr 11, 2024
1 parent 88d5826 commit 58782d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions aderyn_core/src/detect/high/_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ impl IssueDetector for TemplateDetector {
}

#[cfg(test)]
mod arbitrary_transfer_from_tests {
mod template_detector_tests {
use crate::detect::{
detector::{detector_test_helpers::load_contract, IssueDetector},
high::arbitrary_transfer_from::ArbitraryTransferFromDetector,
high::template_detector::TemplateDetector,
};

#[test]
fn test_arbitrary_transfer_from_detector() {
fn test_template_detector() {
let context = load_contract(
"../tests/contract-playground/out/ArbitraryTransferFrom.sol/ArbitraryTransferFrom.json",
);

let mut detector = ArbitraryTransferFromDetector::default();
let mut detector = TemplateDetector::default();
let found = detector.detect(&context).unwrap();
// assert that the detector found an issue
assert!(found);
Expand Down
16 changes: 8 additions & 8 deletions aderyn_core/src/detect/low/_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,38 @@ impl IssueDetector for TemplateDetector {
}

fn description(&self) -> String {
String::from("Description of the Low issue.")
String::from("Description of the low issue.")
}

fn instances(&self) -> BTreeMap<(String, usize, String), NodeID> {
self.found_instances.clone()
}

fn name(&self) -> String {
format!("Low-issue-template")
format!("low-issue-template")
}
}

#[cfg(test)]
mod arbitrary_transfer_from_tests {
mod template_detector_tests {
use crate::detect::{
detector::{detector_test_helpers::load_contract, IssueDetector},
Low::arbitrary_transfer_from::ArbitraryTransferFromDetector,
low::template_detector::TemplateDetector,
};

#[test]
fn test_arbitrary_transfer_from_detector() {
fn test_template_detector() {
let context = load_contract(
"../tests/contract-playground/out/ArbitraryTransferFrom.sol/ArbitraryTransferFrom.json",
);

let mut detector = ArbitraryTransferFromDetector::default();
let mut detector = TemplateDetector::default();
let found = detector.detect(&context).unwrap();
// assert that the detector found an issue
assert!(found);
// assert that the detector found the correct number of instances
assert_eq!(detector.instances().len(), 1);
// assert the severity is Low
// assert the severity is low
assert_eq!(
detector.severity(),
crate::detect::detector::IssueSeverity::Low
Expand All @@ -80,7 +80,7 @@ mod arbitrary_transfer_from_tests {
// assert the description is correct
assert_eq!(
detector.description(),
String::from("Description of the Low issue.")
String::from("Description of the low issue.")
);
}
}

0 comments on commit 58782d0

Please sign in to comment.