Skip to content

Commit

Permalink
Merge pull request #123 from ethereum/develop
Browse files Browse the repository at this point in the history
version 0.1.1 development
  • Loading branch information
winsvega authored Jun 12, 2021
2 parents 156b5ba + 0fa01cc commit ab6c70d
Show file tree
Hide file tree
Showing 152 changed files with 4,207 additions and 1,486 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ HunterGate(
LOCAL
)

project(retesteth VERSION 0.1.0)
set(VERSION_SUFFIX "accesslist")
project(retesteth VERSION 0.1.1)
set(VERSION_SUFFIX "eip1559")

set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RUN mkdir /build && cd /build \
# && cmake /solidity -DCMAKE_BUILD_TYPE=Release && make solc \
# && cp /build/solc/solc /bin/solc \
# && rm -rf /build /solidity /var/cache/* /root/.hunter/*
RUN apt-get install wget && wget https://github.com/ethereum/solidity/releases/download/v0.7.0/solc-static-linux \
RUN apt-get install wget && wget https://github.com/ethereum/solidity/releases/download/v0.8.5/solc-static-linux \
&& cp solc-static-linux /bin/solc \
&& chmod +x /bin/solc

Expand Down
9 changes: 4 additions & 5 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,23 @@ jobs:
- image: ethereum/cpp-build-env:7
steps: *linux-steps

macOS-XCode10:
macOS-XCode11:
environment:
- CXX: clang++
- GCOV: gcov
- GENERATOR: Ninja
- BUILD_PARALLEL_JOBS: 8
- TEST_PARALLEL_JOBS: 8
macos:
xcode: "10.0"
xcode: "11.3.1"
steps:
- checkout
- *environment-info
- run:
name: "Install macOS dependencies"
# Python3 and requests are needed for Hunter upload.
command: |
HOMEBREW_NO_AUTO_UPDATE=1 brew install -q cmake ninja python3
pip3 install -q requests gitpython
HOMEBREW_NO_AUTO_UPDATE=1 brew install -q cmake ninja
- *configureMac
# - *upload-hunter-cache
# - *install-solidity-mac
Expand All @@ -182,6 +181,6 @@ workflows:
version: 2
cpp-ethereum:
jobs:
- macOS-XCode10
- macOS-XCode11
- Linux-Clang6
- Linux-GCC6-Debug
5 changes: 4 additions & 1 deletion cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ hunter_config(
HTTP_CLIENT=NO
)

hunter_config(Boost VERSION 1.65.1)
hunter_config(Boost VERSION 1.65.2
URL http://retesteth.ethdevops.io/dependencies/boost_1_65_1.tar.bz2
SHA1 4a5b0c3c1b1b9a4d6cb6a6cc395e903e76f76720
)

hunter_config(ethash VERSION 0.4.0
URL https://github.com/chfast/ethash/archive/v0.4.0.tar.gz
Expand Down
18 changes: 18 additions & 0 deletions retesteth/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,24 @@ Options::Options(int argc, const char** argv)
else if (arg == "--fillchain")
{
fillchain = true;

bool noFilltests = !filltests;
if (noFilltests)
{
// Look ahead if this option ever provided
for (auto i = 0; i < argc; ++i)
{
auto arg = std::string{argv[i]};
if (arg == "--filltests")
{
noFilltests = false;
break;
}
}
}

if (noFilltests)
ETH_STDOUT_MESSAGEC("WARNING: `--fillchain` option provided without `--filltests`, activating `--filltests` (did you mean `--filltests`?)", cYellow);
filltests = true;
}
else if (arg == "--showhash")
Expand Down
1 change: 1 addition & 0 deletions retesteth/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class Options
/// The first time used, options are parsed with argc, argv
static Options const& get(int argc = 0, const char** argv = 0);
static DynamicOptions& getDynamicOptions() { return m_dynamicOptions; }
static ClientConfig const& getCurrentConfig() { return m_dynamicOptions.getCurrentConfig(); }
string getGStateTransactionFilter() const;

private:
Expand Down
2 changes: 1 addition & 1 deletion retesteth/TestOutputHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ bool TestOutputHelper::markError(std::string const& _message)
m_errors.push_back(_message + testDebugInfo);
if (testDebugInfo.empty())
ETH_WARNING(TestOutputHelper::get().testName() + ", Message: " + _message +
", has empty debugInfo! Missing debug Tesinfo for test step.");
", has empty debugInfo! Missing debug Testinfo for test step.");
std::lock_guard<std::mutex> lock(g_failedTestsMap);
if (!s_failedTestsMap.count(TestOutputHelper::get().testName()))
s_failedTestsMap[TestOutputHelper::get().testName()] = testDebugInfo;
Expand Down
107 changes: 68 additions & 39 deletions retesteth/TestSuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,51 +213,78 @@ string const c_copierPostf = "Copier";

void TestSuite::runTestWithoutFiller(boost::filesystem::path const& _file) const
{
for (auto const& config : Options::getDynamicOptions().getClientConfigs())
try
{
Options::getDynamicOptions().setCurrentConfig(config);

std::cout << "Running tests for config '" << config.cfgFile().name() << "' "
<< config.getId().id() << std::endl;
ETH_LOG("Running " + _file.filename().string() + ": ", 3);

// Allow to execute a custom test .json file on any test suite
auto& testOutput = test::TestOutputHelper::get();
testOutput.initTest(1);

if (Options::get().filltests)
for (auto const& config : Options::getDynamicOptions().getClientConfigs())
{
TestFileData testData = readTestFile(_file);
removeComments(testData.data);
Options::getDynamicOptions().setCurrentConfig(config);

string fileName = _file.stem().c_str();
if (fileName.find("Filler") == string::npos)
ETH_ERROR_MESSAGE("Trying to fill `" + string(_file.c_str()) + "`, but file does not have Filler suffix!");
std::cout << "Running tests for config '" << config.cfgFile().name() << "' " << config.getId().id() << std::endl;
ETH_LOG("Running " + _file.filename().string() + ": ", 3);

// output filename. substract Filler suffix
fileName = fileName.substr(0, fileName.length() - 6) + ".json";
// Allow to execute a custom test .json file on any test suite
auto& testOutput = test::TestOutputHelper::get();
testOutput.initTest(1);

fs::path outPath;
if (Options::get().singleTestOutFile.is_initialized())
outPath = fs::path(Options::get().singleTestOutFile.get());
else
outPath = _file.parent_path() / fileName;

TestSuiteOptions opt;
opt.doFilling = true;
opt.allowInvalidBlocks = true;
DataObject output = doTests(testData.data, opt);
addClientInfo(output, _file, testData.hash);
writeFile(outPath, asBytes(output.asJson()));
}
else
executeFile(_file);

testOutput.finishTest();
try
{
if (Options::get().filltests)
{
TestFileData testData = readTestFile(_file);
removeComments(testData.data);

string fileName = _file.stem().c_str();
if (fileName.find("Filler") == string::npos)
ETH_ERROR_MESSAGE(
"Trying to fill `" + string(_file.c_str()) + "`, but file does not have Filler suffix!");

// output filename. substract Filler suffix
fileName = fileName.substr(0, fileName.length() - 6) + ".json";

fs::path outPath;
if (Options::get().singleTestOutFile.is_initialized())
outPath = fs::path(Options::get().singleTestOutFile.get());
else
outPath = _file.parent_path() / fileName;

TestSuiteOptions opt;
opt.doFilling = true;
opt.allowInvalidBlocks = true;
DataObject output = doTests(testData.data, opt);
addClientInfo(output, _file, testData.hash);
writeFile(outPath, asBytes(output.asJson()));
}
else
executeFile(_file);
}
catch (test::EthError const& _ex)
{
// Something went wrong inside the test. skip the test.
// (error message is stored at TestOutputHelper. EthError is via ETH_ERROR_())
}
catch (test::UpwardsException const& _ex)
{
// UpwardsException is thrown upwards in tests for debug info
// And it should be catched on upper level for report till this point
ETH_ERROR_MESSAGE(string("Unhandled UpwardsException: ") + _ex.what());
}
catch (std::exception const& _ex)
{
if (!ExitHandler::receivedExitSignal())
ETH_ERROR_MESSAGE("ERROR OCCURED TESTFILE RUN: " + string(_ex.what()));
RPCSession::sessionEnd(TestOutputHelper::getThreadID(), RPCSession::SessionStatus::HasFinished);
}

// Disconnect threads from the client
if (Options::getDynamicOptions().getClientConfigs().size() > 1)
RPCSession::clear();
testOutput.finishTest();
// Disconnect threads from the client
if (Options::getDynamicOptions().getClientConfigs().size() > 1)
RPCSession::clear();
}
}
catch (std::exception const&)
{
test::TestOutputHelper::get().finishTest();
test::TestOutputHelper::printTestExecStats();
}
}

Expand Down Expand Up @@ -479,6 +506,8 @@ void TestSuite::runFunctionForAllClients(std::function<void()> _func)
Options::getDynamicOptions().setCurrentConfig(config);
std::cout << "Running tests for config '" << config.cfgFile().name() << "' "
<< config.getId().id() << std::endl;

// Run tests
_func();

// Disconnect threads from the client
Expand Down
8 changes: 8 additions & 0 deletions retesteth/compiler/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ string replaceCode(string const& _code, solContracts const& _preSolidity)
string const c_rawPrefix = ":raw";
string const c_abiPrefix = ":abi";
string const c_solidityPrefix = ":solidity";
string const c_yulPrefix = ":yul";

if (_code.find("pragma solidity") != string::npos)
{
Expand Down Expand Up @@ -99,6 +100,13 @@ string replaceCode(string const& _code, solContracts const& _preSolidity)
compiledCode = utiles::encodeAbi(abiCode);
utiles::checkHexHasEvenLength(compiledCode);
}
else if (_code.find(c_yulPrefix) != string::npos)
{
size_t const pos = _code.find(c_yulPrefix);
string const yulCode = _code.substr(pos + c_yulPrefix.length() + 1);
compiledCode = compileYul(yulCode);
utiles::checkHexHasEvenLength(compiledCode);
}
else if (_code.find('{') != string::npos || _code.find("(asm") != string::npos )
compiledCode = compileLLL(_code);
else
Expand Down
3 changes: 3 additions & 0 deletions retesteth/compiler/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ solContracts compileSolidity(string const& _code);
/// compile LLL / wasm or other src code into bytecode
std::string replaceCode(std::string const& _code, solContracts const& _preSolidity = solContracts());

/// compile clean YUL
std::string compileYul(string const& _code);

} // namespace compiler
} // namespace test
42 changes: 42 additions & 0 deletions retesteth/compiler/Yul.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "Compiler.h"
#include "TestHelper.h"
#include <libdevcore/CommonIO.h>
using namespace dev;
using namespace test;
using namespace dataobject;


namespace test
{
namespace compiler
{
string compileYul(string const& _code)
{
#if defined(_WIN32)
BOOST_ERROR("Yul compilation only supported on posix systems.");
return "";
#else
fs::path const path(fs::temp_directory_path() / fs::unique_path());

string const cmd = string("solc --assemble ") + path.string();
writeFile(path.string(), _code);
string result = executeCmd(cmd);
string c_findString = "Binary representation:";
size_t codePos = result.find(c_findString);
if (codePos != string::npos)
{
size_t codeStartPos = codePos + c_findString.size() + 1;
size_t codeEndPos = result.find('\n', codeStartPos + 1);
if (codeEndPos == string::npos)
ETH_FAIL_MESSAGE("YUL compile error!");

string const yulCode = result.substr(codeStartPos, codeEndPos - codeStartPos);
return "0x" + yulCode;
}
else
ETH_FAIL_MESSAGE("Error compiling YUL!");
return "";
#endif
}
} // namespace compiler
} // namespace test
51 changes: 50 additions & 1 deletion retesteth/configs/ClientConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ ClientConfig::ClientConfig(fs::path const& _clientConfigPath) : m_id(ClientConfi
fs::path configFile = _clientConfigPath / "config";
ETH_FAIL_REQUIRE_MESSAGE(fs::exists(configFile), string("Client config not found: ") + configFile.c_str());

// Script to setup the instance
fs::path setupScript = _clientConfigPath / "setup.sh";
if (fs::exists(setupScript))
m_setupScriptPath = setupScript;

// Script to start the instance
fs::path startScript = _clientConfigPath / "start.sh";
if (fs::exists(startScript))
Expand Down Expand Up @@ -179,7 +184,7 @@ std::vector<FORK> ClientConfig::translateNetworks(set<string> const& _networks)

std::string const& ClientConfig::translateException(string const& _exceptionName) const
{
ClientConfigFile const& cfg = m_clientConfigFile.getCContent();
ClientConfigFile const& cfg = m_clientConfigFile;
if (cfg.exceptions().count(_exceptionName))
return cfg.exceptions().at(_exceptionName);

Expand Down Expand Up @@ -209,4 +214,48 @@ DataObject const& ClientConfig::getGenesisTemplate(FORK const& _fork) const
return m_genesisTemplate.at(_fork);
}

void ClientConfig::initializeFirstSetup()
{
if (!m_initialized)
{
m_initialized = true;
if (fs::exists(getSetupScript()))
{
std::cout << "Initialize setup script.." << std::endl;
string const setup = getSetupScript().c_str();
test::executeCmd(setup, ExecCMDWarning::NoWarning);
}
}
}

void ClientConfig::performFieldReplace(DataObject& _data, FieldReplaceDir const& _dir) const
{
if (cfgFile().fieldreplace().size() == 0)
return;

for (auto const& el : cfgFile().fieldreplace())
{
std::string const& retestethNotice = el.first;
std::string const& clientNotice = el.second;

if (_dir == FieldReplaceDir::RetestethToClient)
{
if (!_data.getKey().empty() && _data.getKey() == retestethNotice)
_data.setKey(clientNotice);
}
else
{
if (!_data.getKey().empty() && _data.getKey() == clientNotice)
_data.setKey(retestethNotice);
}
}

if (_data.type() == DataType::Object || _data.type() == DataType::Array)
{
for (auto& obj : _data.getSubObjectsUnsafe())
performFieldReplace(obj, _dir);
}
}


} // namespace test
Loading

0 comments on commit ab6c70d

Please sign in to comment.