Skip to content

Commit

Permalink
test: remove getBytecode
Browse files Browse the repository at this point in the history
  • Loading branch information
obatirou committed Jul 10, 2023
1 parent 5ad73ef commit 8cb4323
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/test/HuffDeployer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -249,40 +249,28 @@ contract HuffDeployerTest is Test {
runTestConstructorCaller(address(uint160(0x1000)));
}


function getBytecode(address contractAddress) view internal returns (bytes memory bytecode) {
uint256 codeSize;
assembly {
codeSize := extcodesize(contractAddress)
}
bytecode = new bytes(codeSize);
assembly {
extcodecopy(contractAddress, add(bytecode, 0x20), 0, codeSize)
}
}

/// @dev test that compilation is different with new evm versions
function testSettingEVMVersion() public {
/// expected bytecode for EVM version "paris"
bytes memory expectedParis = hex"6000";
HuffConfig config = HuffDeployer.config().with_evm_version("paris");
address withParis = config.deploy("test/contracts/EVMVersionCheck");

bytes memory parisBytecode = getBytecode(withParis);
bytes memory parisBytecode = withParis.code;
assertEq(parisBytecode, expectedParis);

/// expected bytecode for EVM version "shanghai" | default
bytes memory expectedShanghai = hex"5f";
HuffConfig shanghaiConfig = HuffDeployer.config().with_evm_version("shanghai");
address withShanghai = shanghaiConfig.deploy("test/contracts/EVMVersionCheck");
bytes memory shanghaiBytecode = getBytecode(withShanghai);
bytes memory shanghaiBytecode = withShanghai.code;
assertEq(shanghaiBytecode, expectedShanghai);

/// Default should be shanghai (latest)
HuffConfig defaultConfig = HuffDeployer.config().with_evm_version("");
address withDefault = defaultConfig.deploy("test/contracts/EVMVersionCheck");

bytes memory defaultBytecode = getBytecode(withDefault);
bytes memory defaultBytecode = withDefault.code;
assertEq(defaultBytecode, expectedShanghai);
}
}

0 comments on commit 8cb4323

Please sign in to comment.