mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-23 14:18:01 +00:00
fix: exclude EVM bytecode from production solc requests (#338)
This is to address issue #320 ## Introduced changes - Added new_required_for_tests() method that includes EVM bytecode flags - Modified new_required() to exclude evm.bytecode and evm.deployedBytecode - Updated test utilities to explicitly request EVM bytecode when needed Signed-off-by: 0xf333 <0x333@tuta.io>
This commit is contained in:
@@ -21,8 +21,20 @@ pub struct File {
|
||||
}
|
||||
|
||||
impl File {
|
||||
/// Creates the selection required by our compilation process.
|
||||
/// Creates the selection required for production compilation (excludes EVM bytecode).
|
||||
pub fn new_required() -> Self {
|
||||
Self {
|
||||
per_file: Some(HashSet::from_iter([SelectionFlag::AST])),
|
||||
per_contract: Some(HashSet::from_iter([
|
||||
SelectionFlag::MethodIdentifiers,
|
||||
SelectionFlag::Metadata,
|
||||
SelectionFlag::Yul,
|
||||
])),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates the selection required for test compilation (includes EVM bytecode).
|
||||
pub fn new_required_for_tests() -> Self {
|
||||
Self {
|
||||
per_file: Some(HashSet::from_iter([SelectionFlag::AST])),
|
||||
per_contract: Some(HashSet::from_iter([
|
||||
@@ -49,3 +61,38 @@ impl File {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn production_excludes_evm_bytecode() {
|
||||
let selection = File::new_required();
|
||||
let per_contract = selection.per_contract.unwrap();
|
||||
|
||||
// Production should NOT include EVM bytecode flags
|
||||
assert!(!per_contract.contains(&SelectionFlag::EVMBC));
|
||||
assert!(!per_contract.contains(&SelectionFlag::EVMDBC));
|
||||
|
||||
// But should include other required flags
|
||||
assert!(per_contract.contains(&SelectionFlag::MethodIdentifiers));
|
||||
assert!(per_contract.contains(&SelectionFlag::Metadata));
|
||||
assert!(per_contract.contains(&SelectionFlag::Yul));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tests_include_evm_bytecode() {
|
||||
let selection = File::new_required_for_tests();
|
||||
let per_contract = selection.per_contract.unwrap();
|
||||
|
||||
// Tests should include EVM bytecode flags
|
||||
assert!(per_contract.contains(&SelectionFlag::EVMBC));
|
||||
assert!(per_contract.contains(&SelectionFlag::EVMDBC));
|
||||
|
||||
// And should also include other required flags
|
||||
assert!(per_contract.contains(&SelectionFlag::MethodIdentifiers));
|
||||
assert!(per_contract.contains(&SelectionFlag::Metadata));
|
||||
assert!(per_contract.contains(&SelectionFlag::Yul));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,14 @@ impl Selection {
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates the selection required for test compilation (includes EVM bytecode).
|
||||
pub fn new_required_for_tests() -> Self {
|
||||
Self {
|
||||
all: Some(FileSelection::new_required_for_tests()),
|
||||
files: BTreeMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Extends the user's output selection with flag required by our compilation process.
|
||||
pub fn extend_with_required(&mut self) -> &mut Self {
|
||||
self.all
|
||||
|
||||
Reference in New Issue
Block a user