[isoltest] Enforcing compileViaYul to be set if test can pass via yul

This commit is contained in:
Djordje Mijovic 2020-04-17 22:24:33 +02:00 committed by chriseth
parent cb32530b6b
commit 8b7f87eed5
127 changed files with 412 additions and 145 deletions

View File

@ -617,6 +617,23 @@ jobs:
t_ubu_soltest: &t_ubu_soltest
<<: *test_ubuntu1904
t_ubu_soltest_enforce_yul: &t_ubu_soltest_enforce_yul
docker:
- image: ethereum/solidity-buildpack-deps:ubuntu1904-<< pipeline.parameters.ubuntu-1904-docker-image-rev >>
environment:
EVM: constantinople
SOLTEST_FLAGS: --enforce-via-yul
OPTIMIZE: 0
TERM: xterm
steps:
- checkout
- attach_workspace:
at: build
- run: *run_soltest
- store_test_results: *store_test_results
- store_artifacts: *artifacts_test_results
t_ubu_clang_soltest: &t_ubu_clang_soltest
<<: *test_ubuntu1904_clang
environment:
@ -818,6 +835,7 @@ workflows:
- b_ubu18: *workflow_trigger_on_tags
- t_ubu_cli: *workflow_ubuntu1904
- t_ubu_soltest: *workflow_ubuntu1904
- t_ubu_soltest_enforce_yul: *workflow_ubuntu1904
- b_ubu_clang: *workflow_trigger_on_tags
- t_ubu_clang_soltest: *workflow_ubuntu1904_clang

View File

@ -95,6 +95,7 @@ CommonOptions::CommonOptions(std::string _caption):
("no-smt", po::bool_switch(&disableSMT), "disable SMT checker")
("optimize", po::bool_switch(&optimize), "enables optimization")
("optimize-yul", po::bool_switch(&optimizeYul), "enables Yul optimization")
("enforce-via-yul", po::bool_switch(&enforceViaYul), "Enforce compiling all tests via yul to see if additional tests can be activated.")
("abiencoderv2", po::bool_switch(&useABIEncoderV2), "enables abi encoder v2")
("show-messages", po::bool_switch(&showMessages), "enables message output")
("show-metadata", po::bool_switch(&showMetadata), "enables metadata output");

View File

@ -47,6 +47,7 @@ struct CommonOptions: boost::noncopyable
boost::filesystem::path testPath;
bool optimize = false;
bool optimizeYul = false;
bool enforceViaYul = false;
bool disableSMT = false;
bool useABIEncoderV2 = false;
bool showMessages = false;

View File

@ -40,6 +40,11 @@ void TestCase::printSettings(ostream& _stream, const string& _linePrefix, const
_stream << _linePrefix << "// " << setting.first << ": " << setting.second << endl;
}
void TestCase::printUpdatedSettings(std::ostream& _stream, std::string const& _linePrefix)
{
printSettings(_stream, _linePrefix);
}
bool TestCase::isTestFilename(boost::filesystem::path const& _filename)
{
string extension = _filename.extension().string();

View File

@ -38,6 +38,7 @@ public:
{
std::string filename;
langutil::EVMVersion evmVersion;
bool enforceCompileViaYul;
};
enum class TestResult { Success, Failure, FatalError };
@ -59,6 +60,8 @@ public:
virtual void printSource(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false) const = 0;
/// Outputs settings.
virtual void printSettings(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false);
/// Outputs updated settings
virtual void printUpdatedSettings(std::ostream& _stream, std::string const& _linePrefix = "");
/// Outputs test expectations to @arg _stream that match the actual results of the test.
/// Each line of output is prefixed with @arg _linePrefix.
virtual void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const = 0;

View File

@ -64,12 +64,13 @@ int registerTests(
boost::unit_test::test_suite& _suite,
boost::filesystem::path const& _basepath,
boost::filesystem::path const& _path,
bool _enforceViaYul,
TestCase::TestCaseCreator _testCaseCreator
)
{
int numTestsAdded = 0;
fs::path fullpath = _basepath / _path;
TestCase::Config config{fullpath.string(), solidity::test::CommonOptions::get().evmVersion()};
TestCase::Config config{fullpath.string(), solidity::test::CommonOptions::get().evmVersion(), _enforceViaYul};
if (fs::is_directory(fullpath))
{
test_suite* sub_suite = BOOST_TEST_SUITE(_path.filename().string());
@ -78,7 +79,12 @@ int registerTests(
fs::directory_iterator()
))
if (fs::is_directory(entry.path()) || TestCase::isTestFilename(entry.path().filename()))
numTestsAdded += registerTests(*sub_suite, _basepath, _path / entry.path().filename(), _testCaseCreator);
numTestsAdded += registerTests(
*sub_suite,
_basepath, _path / entry.path().filename(),
_enforceViaYul,
_testCaseCreator
);
_suite.add(sub_suite);
}
else
@ -164,6 +170,7 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
master,
options.testPath / ts.path,
ts.subpath,
options.enforceViaYul,
ts.testCaseCreator
) > 0, std::string("no ") + ts.title + " tests found");
}

View File

@ -36,9 +36,10 @@ using namespace boost::unit_test;
namespace fs = boost::filesystem;
SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVersion):
SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVersion, bool enforceViaYul):
SolidityExecutionFramework(_evmVersion),
EVMVersionRestrictedTestCase(_filename)
EVMVersionRestrictedTestCase(_filename),
m_enforceViaYul(enforceViaYul)
{
m_source = m_reader.source();
m_lineOffset = m_reader.lineNumber();
@ -78,112 +79,145 @@ SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVer
TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePrefix, bool _formatted)
{
for(bool compileViaYul: set<bool>{!m_runWithoutYul, m_runWithYul})
for (bool compileViaYul: set<bool>{!m_runWithoutYul, m_runWithYul || m_enforceViaYul})
{
reset();
bool success = true;
m_compileViaYul = compileViaYul;
if (compileViaYul)
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Running via Yul:" << endl;
for (auto& test: m_tests)
test.reset();
map<string, solidity::test::Address> libraries;
bool constructed = false;
for (auto& test: m_tests)
try
{
if (constructed)
{
soltestAssert(!test.call().isLibrary, "Libraries have to be deployed before any other call.");
soltestAssert(!test.call().isConstructor, "Constructor has to be the first function call expect for library deployments.");
}
else if (test.call().isLibrary)
{
soltestAssert(
deploy(test.call().signature, 0, {}, libraries) && m_transactionSuccessful,
"Failed to deploy library " + test.call().signature
);
libraries[test.call().signature] = m_contractAddress;
continue;
}
else
{
if (test.call().isConstructor)
deploy("", test.call().value.value, test.call().arguments.rawBytes(), libraries);
else
soltestAssert(deploy("", 0, bytes(), libraries), "Failed to deploy contract.");
constructed = true;
}
reset();
bool success = true;
if (test.call().isConstructor)
{
if (m_transactionSuccessful == test.call().expectations.failure)
success = false;
m_compileViaYul = compileViaYul;
m_compileViaYulCanBeSet = false;
test.setFailure(!m_transactionSuccessful);
test.setRawBytes(bytes());
}
else
if (compileViaYul)
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Running via Yul:" << endl;
for (auto& test: m_tests)
test.reset();
map<string, solidity::test::Address> libraries;
bool constructed = false;
for (auto& test: m_tests)
{
bytes output;
if (test.call().useCallWithoutSignature)
output = callLowLevel(test.call().arguments.rawBytes(), test.call().value.value);
else
if (constructed)
{
soltestAssert(!test.call().isLibrary, "Libraries have to be deployed before any other call.");
soltestAssert(!test.call().isConstructor, "Constructor has to be the first function call expect for library deployments.");
}
else if (test.call().isLibrary)
{
soltestAssert(
m_allowNonExistingFunctions || m_compiler.methodIdentifiers(m_compiler.lastContractName()).isMember(test.call().signature),
"The function " + test.call().signature + " is not known to the compiler"
);
output = callContractFunctionWithValueNoEncoding(
test.call().signature,
test.call().value.value,
test.call().arguments.rawBytes()
deploy(test.call().signature, 0, {}, libraries) && m_transactionSuccessful,
"Failed to deploy library " + test.call().signature
);
libraries[test.call().signature] = m_contractAddress;
continue;
}
else
{
if (test.call().isConstructor)
deploy("", test.call().value.value, test.call().arguments.rawBytes(), libraries);
else
soltestAssert(deploy("", 0, bytes(), libraries), "Failed to deploy contract.");
constructed = true;
}
if ((m_transactionSuccessful == test.call().expectations.failure) || (output != test.call().expectations.rawBytes()))
success = false;
if (test.call().isConstructor)
{
if (m_transactionSuccessful == test.call().expectations.failure)
success = false;
test.setFailure(!m_transactionSuccessful);
test.setRawBytes(std::move(output));
test.setContractABI(m_compiler.contractABI(m_compiler.lastContractName()));
test.setFailure(!m_transactionSuccessful);
test.setRawBytes(bytes());
}
else
{
bytes output;
if (test.call().useCallWithoutSignature)
output = callLowLevel(test.call().arguments.rawBytes(), test.call().value.value);
else
{
soltestAssert(
m_allowNonExistingFunctions || m_compiler.methodIdentifiers(m_compiler.lastContractName()).isMember(test.call().signature),
"The function " + test.call().signature + " is not known to the compiler"
);
output = callContractFunctionWithValueNoEncoding(
test.call().signature,
test.call().value.value,
test.call().arguments.rawBytes()
);
}
if ((m_transactionSuccessful == test.call().expectations.failure) || (output != test.call().expectations.rawBytes()))
success = false;
test.setFailure(!m_transactionSuccessful);
test.setRawBytes(std::move(output));
test.setContractABI(m_compiler.contractABI(m_compiler.lastContractName()));
}
}
if (success && !m_runWithYul && compileViaYul)
{
m_compileViaYulCanBeSet = true;
AnsiColorized(_stream, _formatted, {BOLD, YELLOW}) << _linePrefix << endl << _linePrefix
<< "Test can pass via Yul and marked with compileViaYul: false." << endl;
return TestResult::Failure;
}
if (!success && (m_runWithYul || !compileViaYul))
{
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
for (auto const& test: m_tests)
{
ErrorReporter errorReporter;
_stream << test.format(errorReporter, _linePrefix, false, _formatted) << endl;
_stream << errorReporter.format(_linePrefix, _formatted);
}
_stream << endl;
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
for (auto const& test: m_tests)
{
ErrorReporter errorReporter;
_stream << test.format(errorReporter, _linePrefix, true, _formatted) << endl;
_stream << errorReporter.format(_linePrefix, _formatted);
}
AnsiColorized(_stream, _formatted, {BOLD, RED}) << _linePrefix << endl << _linePrefix
<< "Attention: Updates on the test will apply the detected format displayed." << endl;
if (compileViaYul && m_runWithoutYul)
{
_stream << _linePrefix << endl << _linePrefix;
AnsiColorized(_stream, _formatted, {RED_BACKGROUND})
<< "Note that the test passed without Yul.";
_stream << endl;
}
else if (!compileViaYul && m_runWithYul)
AnsiColorized(_stream, _formatted, {BOLD, YELLOW}) << _linePrefix << endl << _linePrefix
<< "Note that the test also has to pass via Yul." << endl;
return TestResult::Failure;
}
}
if (!success)
catch (boost::exception const&)
{
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Expected result:" << endl;
for (auto const& test: m_tests)
{
ErrorReporter errorReporter;
_stream << test.format(errorReporter, _linePrefix, false, _formatted) << endl;
_stream << errorReporter.format(_linePrefix, _formatted);
}
_stream << endl;
AnsiColorized(_stream, _formatted, {BOLD, CYAN}) << _linePrefix << "Obtained result:" << endl;
for (auto const& test: m_tests)
{
ErrorReporter errorReporter;
_stream << test.format(errorReporter, _linePrefix, true, _formatted) << endl;
_stream << errorReporter.format(_linePrefix, _formatted);
}
AnsiColorized(_stream, _formatted, {BOLD, RED}) << _linePrefix << endl << _linePrefix
<< "Attention: Updates on the test will apply the detected format displayed." << endl;
if (compileViaYul && m_runWithoutYul)
{
_stream << _linePrefix << endl << _linePrefix;
AnsiColorized(_stream, _formatted, {RED_BACKGROUND}) << "Note that the test passed without Yul.";
_stream << endl;
}
else if (!compileViaYul && m_runWithYul)
AnsiColorized(_stream, _formatted, {BOLD, YELLOW}) << _linePrefix << endl << _linePrefix
<< "Note that the test also has to pass via Yul." << endl;
return TestResult::Failure;
if (compileViaYul && !m_runWithYul)
continue;
throw;
}
catch (std::exception const&)
{
if (compileViaYul && !m_runWithYul)
continue;
throw;
}
catch (...)
{
if (compileViaYul && !m_runWithYul)
continue;
throw;
}
}
@ -204,6 +238,20 @@ void SemanticTest::printUpdatedExpectations(ostream& _stream, string const&) con
_stream << test.format("", true, false) << endl;
}
void SemanticTest::printUpdatedSettings(ostream& _stream, string const& _linePrefix)
{
auto& settings = m_reader.settings();
if (settings.empty() && !m_compileViaYulCanBeSet)
return;
_stream << _linePrefix << "// ====" << endl;
if (m_compileViaYulCanBeSet)
_stream << _linePrefix << "// compileViaYul: also\n";
for (auto const& setting: settings)
if (!m_compileViaYulCanBeSet || setting.first != "compileViaYul")
_stream << _linePrefix << "// " << setting.first << ": " << setting.second << endl;
}
void SemanticTest::parseExpectations(istream& _stream)
{
TestFileParser parser{_stream};

View File

@ -40,13 +40,14 @@ class SemanticTest: public SolidityExecutionFramework, public EVMVersionRestrict
{
public:
static std::unique_ptr<TestCase> create(Config const& _options)
{ return std::make_unique<SemanticTest>(_options.filename, _options.evmVersion); }
{ return std::make_unique<SemanticTest>(_options.filename, _options.evmVersion, _options.enforceCompileViaYul); }
explicit SemanticTest(std::string const& _filename, langutil::EVMVersion _evmVersion);
explicit SemanticTest(std::string const& _filename, langutil::EVMVersion _evmVersion, bool _enforceViaYul = false);
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool _formatted = false) override;
void printSource(std::ostream &_stream, std::string const& _linePrefix = "", bool _formatted = false) const override;
void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix = "") const override;
void printUpdatedSettings(std::ostream& _stream, std::string const& _linePrefix = "") override;
/// Instantiates a test file parser that parses the additional comment section at the end of
/// the input stream \param _stream. Each function call is represented using a `FunctionCallTest`
@ -64,8 +65,10 @@ private:
std::vector<TestFunctionCall> m_tests;
bool m_runWithYul = false;
bool m_runWithoutYul = true;
bool m_enforceViaYul = false;
bool m_runWithABIEncoderV1Only = false;
bool m_allowNonExistingFunctions = false;
bool m_compileViaYulCanBeSet = false;
};
}

View File

@ -5,6 +5,8 @@ contract C {
return 23;
}
}
// ====
// compileViaYul: also
// ----
// f(uint256[][2][]): 0x20, 0x01, 0x20, 0x40, 0x60, 0x00, 0x00 -> 23 # this is the common encoding for x.length == 1 && x[0][0].length == 0 && x[0][1].length == 0 #
// f(uint256[][2][]): 0x20, 0x01, 0x20, 0x00, 0x00 -> 23 # exotic, but still valid encoding #

View File

@ -10,6 +10,8 @@ contract C {
return this.g(x);
}
}
// ====
// compileViaYul: also
// ----
// f(uint256): 0 -> 0
// g(address): 0 -> 0 # test validation as well as sanity check #

View File

@ -10,6 +10,8 @@ contract C {
return this.gggg(x);
}
}
// ====
// compileViaYul: also
// ----
// f(uint256): 0 -> false
// gggg(bool): 0 -> false # test validation as well as sanity check #

View File

@ -42,6 +42,8 @@ contract C {
return this.g16(x);
}
}
// ====
// compileViaYul: also
// ----
// f1(bytes32): left(0) -> left(0)
// gg1(bytes1): left(0) -> left(0) # test validation as well as sanity check #

View File

@ -42,6 +42,8 @@ contract C {
return this.g128(x);
}
}
// ====
// compileViaYul: also
// ----
// f8(int256): 0 -> 0
// ggg8(int8): 0 -> 0 # test validation as well as sanity check #

View File

@ -42,6 +42,8 @@ contract C {
return this.g128(x);
}
}
// ====
// compileViaYul: also
// ----
// f8(uint256): 0 -> 0
// ggg8(uint8): 0 -> 0 # test validation as well as sanity check #

View File

@ -7,7 +7,8 @@ contract C {
return a % b;
}
}
// ====
// compileViaYul: also
// ----
// div(uint256,uint256): 7, 2 -> 3
// div(uint256,uint256): 7, 0 -> FAILURE # throws #

View File

@ -11,6 +11,7 @@ contract c {
l = data.length;
}
}
// ====
// compileViaYul: also
// ----
// test() -> 1, 0

View File

@ -6,6 +6,7 @@ contract c {
return true;
}
}
// ====
// compileViaYul: also
// ----
// test() -> FAILURE

View File

@ -8,6 +8,7 @@ contract c {
x = 3;
}
}
// ====
// compileViaYul: also
// ----
// test() -> 3

View File

@ -14,6 +14,7 @@ contract c {
z = data[2];
}
}
// ====
// compileViaYul: also
// ----
// test() -> 5, 4, 3, 3

View File

@ -9,6 +9,5 @@ contract c {
return true;
}
}
// ----
// test() -> FAILURE

View File

@ -8,6 +8,7 @@ contract c {
x = 3;
}
}
// ====
// compileViaYul: also
// ----
// test() -> 3

View File

@ -11,6 +11,7 @@ contract C {
b = s[1];
}
}
// ====
// compileViaYul: also
// ----
// f(uint256[2]): 42, 23 -> 42, 23

View File

@ -11,7 +11,8 @@ contract C {
return 42;
}
}
// ====
// compileViaYul: also
// ----
// f(uint256[][]): 0x20, 0x0 -> 42 # valid access stub #
// f(uint256[][]): 0x20, 0x1 -> FAILURE # invalid on argument decoding #

View File

@ -16,7 +16,8 @@ contract C {
return 42;
}
}
// ====
// compileViaYul: also
// ----
// f(uint256[][1][]): 0x20, 0x0 -> 42 # valid access stub #
// f(uint256[][1][]): 0x20, 0x1 -> FAILURE # invalid on argument decoding #

View File

@ -4,6 +4,7 @@ contract C {
return 7;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 7

View File

@ -29,6 +29,7 @@ contract C {
return 0;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 7

View File

@ -12,7 +12,8 @@ contract A {
return true;
}
}
// ====
// compileViaYul: also
// ----
// test() -> false
// testIt() -> FAILURE

View File

@ -7,7 +7,8 @@ contract Creator {
ch = s[2];
}
}
// ====
// compileViaYul: also
// ----
// constructor(): 1, 2, 3, 4 ->
// r() -> 4

View File

@ -5,6 +5,7 @@ contract C {
return (x.length, bytes16(uint128(2)).length, a.length + 7);
}
}
// ====
// compileViaYul: also
// ----
// f(bytes32): "789" -> 32, 16, 8

View File

@ -10,5 +10,7 @@ contract Test {
return data;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07

View File

@ -11,7 +11,8 @@ contract C {
return rows[n][k - 1];
}
}
// ====
// compileViaYul: also
// ----
// f(uint256,uint256): 3, 1 -> 1
// f(uint256,uint256): 9, 5 -> 70

View File

@ -19,6 +19,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// l() -> 0
// lv(uint256): 42 ->

View File

@ -11,6 +11,8 @@ contract C {
_out = _in;
}
}
// ====
// compileViaYul: also
// ----
// f(bool): 0x0 -> 0x0
// f(bool): 0x1 -> 0x1

View File

@ -13,6 +13,8 @@ contract C {
return 0;
}
}
// ====
// compileViaYul: also
// ----
// f(address): 0xffff1234567890123456789012345678901234567890 -> FAILURE # We input longer data on purpose.#
// g(address): 0xffff1234567890123456789012345678901234567890 -> FAILURE

View File

@ -10,5 +10,7 @@ contract C {
return 0;
}
}
// ====
// compileViaYul: also
// ----
// f(bytes2,uint16): "abc", 0x40102 -> FAILURE # We input longer data on purpose. #

View File

@ -8,6 +8,7 @@ contract C {
return (x, y);
}
}
// ====
// compileViaYul: also
// ----
// test() -> 0xff, 0xff

View File

@ -20,5 +20,7 @@ contract Derived is Base {
}
}
// ====
// compileViaYul: also
// ----
// getA() -> 49

View File

@ -15,7 +15,8 @@ contract Main {
return flag;
}
}
// ====
// compileViaYul: also
// ----
// constructor(): "abc", true
// getFlag() -> true

View File

@ -20,5 +20,7 @@ contract Derived is Base {
}
}
// ====
// compileViaYul: also
// ----
// getA() -> 2

View File

@ -14,7 +14,8 @@ contract Derived is Base {
return m_derived;
}
}
// ====
// compileViaYul: also
// ----
// getBMember() -> 5
// getDMember() -> 6

View File

@ -5,6 +5,8 @@ contract test {
return cond ? x : y;
}
}
// ====
// compileViaYul: also
// ----
// f(bool): true -> 0xcd
// f(bool): false -> 0xabab

View File

@ -3,5 +3,7 @@ contract test {
return false ? 5 : 10;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 10

View File

@ -7,6 +7,8 @@ contract test {
return z();
}
}
// ====
// compileViaYul: also
// ----
// f(bool): true -> 1
// f(bool): false -> 2

View File

@ -6,6 +6,8 @@ contract test {
x > 50 ? 50 : 10;
}
}
// ====
// compileViaYul: also
// ----
// f(uint256): 1001 -> 1000
// f(uint256): 500 -> 100

View File

@ -3,5 +3,7 @@ contract test {
return true ? 5 : 10;
}
}
// ====
// compileViaYul: also
// ----
// f() -> 5

View File

@ -3,6 +3,8 @@ contract test {
return cond ? (1, 2) : (3, 4);
}
}
// ====
// compileViaYul: also
// ----
// f(bool): true -> 1, 2
// f(bool): false -> 3, 4

View File

@ -3,6 +3,8 @@ contract test {
cond ? a = v : b = v;
}
}
// ====
// compileViaYul: also
// ----
// f(bool,uint256): true, 20 -> 20, 0
// f(bool,uint256): false, 20 -> 0, 20

View File

@ -5,6 +5,8 @@ contract C {
receive () payable external { ++y; }
function f() external returns (uint, uint) { return (x, y); }
}
// ====
// compileViaYul: also
// ----
// f() -> 0, 0
// () ->

View File

@ -4,6 +4,8 @@ contract A {
function getData() public returns (uint r) { return data; }
}
contract B is A {}
// ====
// compileViaYul: also
// ----
// getData() -> 0
// (): 42 ->

View File

@ -4,6 +4,8 @@ contract A {
function fow() public { x = 3; }
fallback () external { x = 2; }
}
// ====
// compileViaYul: also
// ----
// (): hex"d88e0b"
// x() -> 2

View File

@ -22,6 +22,8 @@ contract test {
return sum;
}
}
// ====
// compileViaYul: also
// ----
// f(uint256[]): 32, 3, 1000, 1, 2 -> 3
// f(uint256[]): 32, 3, 100, 500, 300 -> 600

View File

@ -10,5 +10,7 @@ contract C is V
{
function a() internal view override returns (uint256) { return 42;}
}
// ====
// compileViaYul: also
// ----
// b() -> 42

View File

@ -11,7 +11,8 @@ contract C {
return 7;
}
}
// ====
// compileViaYul: also
// ----
// intern() -> FAILURE # This should throw exceptions #
// extern() -> FAILURE

View File

@ -15,6 +15,7 @@ contract C {
return 2;
}
}
// ====
// compileViaYul: also
// ----
// t() -> FAILURE

View File

@ -16,6 +16,8 @@ contract test {
return (a[0][key], a[1][key], b[0][key], b[1][key]);
}
}
// ====
// compileViaYul: also
// ----
// set(uint8,uint8,uint8,uint8,uint8): 1, 21, 22, 42, 43 -> 0, 0, 0, 0
// get(uint8): 1 -> 21, 22, 42, 43

View File

@ -14,6 +14,8 @@ contract test {
return (a[key], b[key]);
}
}
// ====
// compileViaYul: also
// ----
// set(uint8,uint8,uint8): 1, 21, 42 -> 0, 0
// get(uint8): 1 -> 21, 42

View File

@ -6,6 +6,7 @@ contract test {
}
// ====
// allowNonExistingFunctions: true
// compileViaYul: also
// ----
// a() -> 0
// b() -> 1

View File

@ -2,5 +2,7 @@ contract test {
function a(uint a, uint b, uint c) public returns (uint r) { r = a * 100 + b * 10 + c * 1; }
function b() public returns (uint r) { r = a({a: 1, b: 2, c: 3}); }
}
// ====
// compileViaYul: also
// ----
// b() -> 123

View File

@ -14,6 +14,8 @@ contract Main {
}
}
// ====
// compileViaYul: also
// ----
// constructor(), 20 wei ->
// s() -> true

View File

@ -3,6 +3,8 @@ contract test {
function g() public { revert(); }
function h() public { assert(false); }
}
// ====
// compileViaYul: also
// ----
// f() ->
// g() -> FAILURE

View File

@ -3,6 +3,8 @@ contract C {
return msg.value;
}
}
// ====
// compileViaYul: also
// ----
// f(), 1 ether -> 1000000000000000000
// f(), 1 wei -> 1

View File

@ -7,10 +7,9 @@ contract C {
return x(a);
}
function g(uint256 x) public returns (uint256) {
function g(uint256 x) public pure returns (uint256) {
return x + 1;
}
}
// ----
// f(uint256): 7 -> 8

View File

@ -13,7 +13,8 @@ contract C {
return double(_arg);
}
}
// ====
// compileViaYul: also
// ----
// runtime(uint256): 3 -> 6
// initial() -> 4

View File

@ -25,6 +25,8 @@ contract C {
return (a, (new A()).f(), (new B()).f());
}
}
// ====
// compileViaYul: also
// ----
// f() -> 3, 7, 5
// x() -> 7

View File

@ -16,7 +16,8 @@ contract C {
return true;
}
}
// ====
// compileViaYul: also
// ----
// f() -> true
// z() -> 7

View File

@ -17,7 +17,8 @@ contract C {
return true;
}
}
// ====
// compileViaYul: also
// ----
// f() -> true
// z() -> 7

View File

@ -10,5 +10,7 @@ contract C {
}
}
}
// ====
// compileViaYul: also
// ----
// f() -> 2

View File

@ -29,6 +29,8 @@ contract Homer is ERC165, Simpson {
}
}
// ====
// compileViaYul: also
// ----
// supportsInterface(bytes4): left(0x01ffc9a0) -> false
// supportsInterface(bytes4): left(0x01ffc9a7) -> true

View File

@ -40,6 +40,8 @@ contract Lisa is ERC165MappingImplementation, Simpson {
}
}
// ====
// compileViaYul: also
// ----
// supportsInterface(bytes4): left(0x01ffc9a0) -> false
// supportsInterface(bytes4): left(0x01ffc9a7) -> true

View File

@ -17,6 +17,7 @@ contract B is A {
return A(this).f(m);
}
}
// ====
// compileViaYul: also
// ----
// g() -> 23

View File

@ -14,5 +14,7 @@ contract Derived is Base {
contract Final is Derived(4) {}
// ====
// compileViaYul: also
// ----
// m_i() -> 4

View File

@ -19,5 +19,7 @@ contract Derived is Base, Base1 {
contract Final is Derived(4) {}
// ====
// compileViaYul: also
// ----
// m_i() -> 4

View File

@ -19,5 +19,7 @@ contract Derived is Base, Base1 {
contract Final is Derived(4) {}
// ====
// compileViaYul: also
// ----
// m_i() -> 4

View File

@ -10,5 +10,7 @@ contract Tsra {
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1

View File

@ -13,5 +13,7 @@ contract Tsra {
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1

View File

@ -3,5 +3,7 @@ contract C {
return hex"12_34_5678_9A";
}
}
// ====
// compileViaYul: also
// ----
// f() -> 32, 5, left(0x123456789A)

View File

@ -13,7 +13,8 @@ contract C {
x = t;
}
}
// ====
// compileViaYul: also
// ----
// x() -> 0
// f() ->

View File

@ -13,7 +13,8 @@ contract C {
x = t;
}
}
// ====
// compileViaYul: also
// ----
// x() -> 0
// f() ->

View File

@ -2,6 +2,8 @@ contract A {
uint public x;
receive () external payable { ++x; }
}
// ====
// compileViaYul: also
// ----
// x() -> 0
// ()

View File

@ -1,6 +1,8 @@
contract C {
receive () payable external { }
}
// ====
// compileViaYul: also
// ----
// (), 1 ether
// (), 1 ether: 1 -> FAILURE

View File

@ -4,6 +4,8 @@ contract A {
function getData() public returns (uint r) { return data; }
}
contract B is A {}
// ====
// compileViaYul: also
// ----
// getData() -> 0
// () ->

View File

@ -6,6 +6,7 @@ contract C {
// ====
// EVMVersion: >=byzantium
// revertStrings: debug
// compileViaYul: also
// ----
// f(uint256,uint256,uint256[]): 2, 1, 0x80, 3, 1, 2, 3 -> FAILURE, hex"08c379a0", 0x20, 22, "Slice starts after end"
// f(uint256,uint256,uint256[]): 1, 5, 0x80, 3, 1, 2, 3 -> FAILURE, hex"08c379a0", 0x20, 28, "Slice is greater than length"

View File

@ -7,5 +7,6 @@ contract C {
// ====
// EVMVersion: >=byzantium
// revertStrings: debug
// compileViaYul: also
// ----
// f(uint256[][]): 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride"

View File

@ -8,5 +8,6 @@ contract C {
// ====
// EVMVersion: >=byzantium
// revertStrings: debug
// compileViaYul: also
// ----
// f(uint256[][2][]): 0x20, 0x01, 0x20, 0x00 -> FAILURE, hex"08c379a0", 0x20, 28, "Invalid calldata tail offset"

View File

@ -10,5 +10,6 @@ contract C {
// ====
// EVMVersion: >=byzantium
// revertStrings: debug
// compileViaYul: also
// ----
// g(uint256[][2][]): 0x20, 0x01, 0x20, 0x00 -> FAILURE, hex"08c379a0", 0x20, 30, "Invalid calldata access offset"

View File

@ -7,5 +7,6 @@ contract C {
// ====
// EVMVersion: >=byzantium
// revertStrings: debug
// compileViaYul: also
// ----
// f(uint256[][]): 0x20, 1, 0x20, 0x0100000000000000000000 -> FAILURE, hex"08c379a0", 0x20, 28, "Invalid calldata tail length"

View File

@ -7,5 +7,6 @@ contract C {
// ====
// EVMVersion: >=byzantium
// revertStrings: debug
// compileViaYul: also
// ----
// f(uint256,uint256[],uint256): 6, 0x60, 9, 0x1000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray length"

View File

@ -5,5 +5,6 @@ contract C {
// ====
// EVMVersion: >=byzantium
// revertStrings: debug
// compileViaYul: also
// ----
// f(uint256[][]): 0x20, 1, 0x20, 2, 0x42 -> FAILURE, hex"08c379a0", 0x20, 23, "Calldata tail too short"

View File

@ -5,5 +5,6 @@ contract C {
// ====
// EVMVersion: >=byzantium
// revertStrings: debug
// compileViaYul: also
// ----
// f(uint256[]): 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride"

View File

@ -5,5 +5,6 @@ contract C {
// ====
// EVMVersion: >=byzantium
// revertStrings: debug
// compileViaYul: also
// ----
// e(bytes): 0x20, 7 -> FAILURE, hex"08c379a0", 0x20, 39, "ABI decoding: invalid byte array", " length"

View File

@ -15,6 +15,7 @@ contract C {
return this.tested(garbled);
}
}
// ====
// compileViaYul: also
// ----
// test() -> FAILURE # should throw #

View File

@ -14,6 +14,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f() -> FAILURE
// a() -> 42

View File

@ -6,6 +6,8 @@ contract Test {
}
}
// ====
// compileViaYul: also
// ----
// f(uint256): 11 -> 21
// f(uint256): 1 -> FAILURE

View File

@ -18,6 +18,7 @@ contract A {
}
}
// ====
// compileViaYul: also
// EVMVersion: >=constantinople
// ----
// f(), 10 ether -> 3007, 3008, 3009

View File

@ -1,6 +1,7 @@
contract C {
uint256 public a = 0x42 << 8;
}
// ====
// compileViaYul: also
// ----
// a() -> 0x4200

View File

@ -1,6 +1,7 @@
contract C {
uint256 public a = 0x4200 >> 8;
}
// ====
// compileViaYul: also
// ----
// a() -> 0x42

View File

@ -1,6 +1,7 @@
contract C {
int256 public a = -0x42 << 8;
}
// ====
// compileViaYul: also
// ----
// a() -> -16896

View File

@ -1,6 +1,7 @@
contract C {
int256 public a = -0x4200 >> 8;
}
// ====
// compileViaYul: also
// ----
// a() -> -66

View File

@ -12,6 +12,8 @@ contract C {
return "any";
}
}
// ====
// compileViaYul: also
// ----
// e(bytes): 32, 3, hex"AB33BB" -> 32, 3, left(0xAB33BB)
// e(bytes): 32, 32, 0x20 -> 32, 32, 0x20

View File

@ -10,6 +10,8 @@ contract C {
state = _state;
}
}
// ====
// compileViaYul: also
// ----
// constructor(), 2 wei: 3 ->
// state() -> 3

Some files were not shown because too many files have changed in this diff Show More