Skip to content

Commit

Permalink
feat(docs): more doctests, docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-Becker committed Nov 15, 2023
1 parent 62247cf commit 0d691f6
Show file tree
Hide file tree
Showing 12 changed files with 1,131 additions and 1,009 deletions.
82 changes: 82 additions & 0 deletions common/src/ether/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,85 @@ pub fn detect_compiler(bytecode: &str) -> (&'static str, String) {

(compiler, version.trim_end_matches('.').to_string())
}

#[cfg(test)]
mod test_compiler {
use crate::ether::compiler::detect_compiler;

#[test]
fn test_detect_compiler_proxy_minimal() {
let bytecode = "363d3d373d3d3d363d73";
let expected_result = ("proxy", "minimal".to_string());
assert_eq!(detect_compiler(bytecode), expected_result);
}

#[test]
fn test_detect_compiler_proxy_vyper() {
let bytecode = "366000600037611000600036600073";
let expected_result = ("proxy", "vyper".to_string());
assert_eq!(detect_compiler(bytecode), expected_result);
}

#[test]
fn test_detect_compiler_vyper_range_1() {
let bytecode = "6004361015";
let expected_result = ("vyper", "0.2.0-0.2.4,0.2.11-0.3.3".to_string());
assert_eq!(detect_compiler(bytecode), expected_result);
}

#[test]
fn test_detect_compiler_vyper_range_2() {
let bytecode = "341561000a";
let expected_result = ("vyper", "0.2.5-0.2.8".to_string());
assert_eq!(detect_compiler(bytecode), expected_result);
}

#[test]
fn test_detect_compiler_solc_range_1() {
let bytecode = "731bf797";
let expected_result = ("solc", "0.4.10-0.4.24".to_string());
assert_eq!(detect_compiler(bytecode), expected_result);
}

#[test]
fn test_detect_compiler_solc_range_2() {
let bytecode = "6080604052";
let expected_result = ("solc", "0.4.22+".to_string());
assert_eq!(detect_compiler(bytecode), expected_result);
}

#[test]
fn test_detect_compiler_solc_range_3() {
let bytecode = "6060604052";
let expected_result = ("solc", "0.4.11-0.4.21".to_string());
assert_eq!(detect_compiler(bytecode), expected_result);
}

#[test]
fn test_detect_compiler_vyper() {
let bytecode = r#"7679706572"#;
let expected_result = ("vyper", "unknown".to_string());
assert_eq!(detect_compiler(bytecode), expected_result);
}

#[test]
fn test_detect_compiler_solc() {
let bytecode = "736f6c63";
let expected_result = ("solc", "unknown".to_string());
assert_eq!(detect_compiler(bytecode), expected_result);
}

#[test]
fn test_detect_compiler_solc_metadata() {
let bytecode = "736f6c63434d4e";
let expected_result = ("solc", "unknown".to_string());
assert_eq!(detect_compiler(bytecode), expected_result);
}

#[test]
fn test_detect_compiler_vyper_metadata() {
let bytecode = "7679706572833135353030";
let expected_result = ("vyper", "49.53.53".to_string());
assert_eq!(detect_compiler(bytecode), expected_result);
}
}
1 change: 0 additions & 1 deletion common/src/ether/evm/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ pub mod memory;
pub mod opcodes;
pub mod stack;
pub mod storage;
mod tests;
pub mod types;
pub mod vm;
208 changes: 0 additions & 208 deletions common/src/ether/evm/core/tests.rs

This file was deleted.

Loading

0 comments on commit 0d691f6

Please sign in to comment.