mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Unit test.
This commit is contained in:
parent
e0c837b33b
commit
e7a3814977
@ -84,6 +84,34 @@ struct SolidityEndToEndTestExecutionFramework: public SolidityExecutionFramework
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(SolidityEndToEndTest, SolidityEndToEndTestExecutionFramework)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(creation_code_optimizer)
|
||||
{
|
||||
string codeC = R"(
|
||||
contract C {
|
||||
constructor(uint x) {
|
||||
if (x == 0xFFFFFFFFFFFFFFFF42)
|
||||
revert();
|
||||
}
|
||||
}
|
||||
)";
|
||||
string codeD = R"(
|
||||
contract D {
|
||||
function f() public pure returns (bytes memory) {
|
||||
return type(C).creationCode;
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
m_metadataHash = CompilerStack::MetadataHash::None;
|
||||
ALSO_VIA_YUL({
|
||||
bytes bytecodeC = compileContract(codeC);
|
||||
reset();
|
||||
compileAndRun(codeC + codeD);
|
||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(0x20, bytecodeC.size()) + encode(bytecodeC, false));
|
||||
m_doEwasmTestrun = false;
|
||||
})
|
||||
}
|
||||
|
||||
unsigned constexpr roundTo32(unsigned _num)
|
||||
{
|
||||
return (_num + 31) / 32 * 32;
|
||||
|
@ -62,6 +62,7 @@ bytes SolidityExecutionFramework::multiSourceCompileContract(
|
||||
m_compiler.enableEvmBytecodeGeneration(!m_compileViaYul);
|
||||
m_compiler.enableIRGeneration(m_compileViaYul);
|
||||
m_compiler.setRevertStringBehaviour(m_revertStrings);
|
||||
m_compiler.setMetadataHash(m_metadataHash);
|
||||
if (!m_compiler.compile())
|
||||
{
|
||||
// The testing framework expects an exception for
|
||||
|
@ -75,11 +75,12 @@ public:
|
||||
/// the latter only if it is forced.
|
||||
static std::string addPreamble(std::string const& _sourceCode);
|
||||
protected:
|
||||
|
||||
solidity::frontend::CompilerStack m_compiler;
|
||||
using CompilerStack = solidity::frontend::CompilerStack;
|
||||
CompilerStack m_compiler;
|
||||
bool m_compileViaYul = false;
|
||||
bool m_compileToEwasm = false;
|
||||
bool m_showMetadata = false;
|
||||
CompilerStack::MetadataHash m_metadataHash = CompilerStack::MetadataHash::IPFS;
|
||||
RevertStrings m_revertStrings = RevertStrings::Default;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user