Jon-Becker / heimdall-rs

Heimdall is an advanced EVM smart contract toolkit specializing in bytecode analysis and extracting information from unverified contracts.
http://heimdall.rs
MIT License
1.19k stars 125 forks source link

: more coverage after i get core to compile lol #295

Closed github-actions[bot] closed 6 months ago

github-actions[bot] commented 10 months ago

New Codebase TODO

: more coverage after i get core to compile lol

Location

https://github.com/Jon-Becker/heimdall-rs/blob/bc0137ba559e98ba58ca3352ed5bc2aa753b7154/core/src/decompile/out/postprocessers/yul.rs#L267


        );

        // indent due to opening braces
        if line.split("//").collect::<Vec<&str>>().first().unwrap_or(&"").trim().ends_with('{') {
            indentation += 1;
        }
    }

    cleaned_lines
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_remove_double_negation() {
        let line = "iszero(iszero(add(0x00, 0x01)))";

        let cleaned = remove_double_negation(line);
        assert_eq!(cleaned, "add(0x00, 0x01)");
    }

    #[test]
    fn test_convert_bitmask_to_casting_address() {
        let line = "and(0xffffffffffffffffffffffffffffffffffffffff, calldataload(0x04))";

        let cleaned = convert_bitmask_to_casting(line);
        assert_eq!(cleaned, "castToAddress(calldataload(0x04))");
    }

    #[test]
    fn test_convert_bitmask_to_casting_bytes32() {
        let line = "and(0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff, calldataload(0x04))";

        let cleaned = convert_bitmask_to_casting(line);
        assert_eq!(cleaned, "bytes32(calldataload(0x04))");
    }

    #[test]
    fn test_remove_replace_casts() {
        let line = "bytes32(0x00)";

        let cleaned = remove_replace_casts(line).expect("failed to remove replace casts");
        assert_eq!(cleaned, "0x00");
    }

    // TODO : more coverage after i get core to compile lol
}
github-actions[bot] commented 6 months ago

Closed in 95c54604487c79d20a349bdc3df4632550cbbc32