Merge pull request #8075 from ethereum/refactor-namespaces

Refactor namespaces
This commit is contained in:
Daniel Kirchner
2020-01-07 16:52:20 +01:00
committed by GitHub
544 changed files with 2881 additions and 3548 deletions
+14 -14
View File
@@ -24,20 +24,20 @@ set(contracts_sources
)
detect_stray_source_files("${contracts_sources}" "contracts/")
set(libdevcore_sources
libdevcore/Checksum.cpp
libdevcore/CommonData.cpp
libdevcore/IndentedWriter.cpp
libdevcore/IpfsHash.cpp
libdevcore/IterateReplacing.cpp
libdevcore/JSON.cpp
libdevcore/Keccak256.cpp
libdevcore/StringUtils.cpp
libdevcore/SwarmHash.cpp
libdevcore/UTF8.cpp
libdevcore/Whiskers.cpp
set(libsolutil_sources
libsolutil/Checksum.cpp
libsolutil/CommonData.cpp
libsolutil/IndentedWriter.cpp
libsolutil/IpfsHash.cpp
libsolutil/IterateReplacing.cpp
libsolutil/JSON.cpp
libsolutil/Keccak256.cpp
libsolutil/StringUtils.cpp
libsolutil/SwarmHash.cpp
libsolutil/UTF8.cpp
libsolutil/Whiskers.cpp
)
detect_stray_source_files("${libdevcore_sources}" "libdevcore/")
detect_stray_source_files("${libsolutil_sources}" "libsolutil/")
set(libevmasm_sources
libevmasm/Assembler.cpp
@@ -151,7 +151,7 @@ detect_stray_source_files("${libyul_sources}" "libyul/")
add_executable(soltest ${sources}
${contracts_sources}
${libdevcore_sources}
${libsolutil_sources}
${liblangutil_sources}
${libevmasm_sources}
${libyul_sources}
+3 -7
View File
@@ -17,16 +17,14 @@
#include <test/Common.h>
#include <libdevcore/Assertions.h>
#include <libsolutil/Assertions.h>
#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
namespace fs = boost::filesystem;
namespace po = boost::program_options;
namespace dev
{
namespace test
namespace solidity::test
{
/// If non-empty returns the value of the env. variable ETH_TEST_PATH, otherwise
@@ -91,7 +89,7 @@ CommonOptions::CommonOptions(std::string _caption):
{
options.add_options()
("evm-version", po::value(&evmVersionString), "which evm version to use")
("testpath", po::value<fs::path>(&this->testPath)->default_value(dev::test::testPath()), "path to test files")
("testpath", po::value<fs::path>(&this->testPath)->default_value(solidity::test::testPath()), "path to test files")
("evmonepath", po::value<fs::path>(&evmonePath)->default_value(EVMOneEnvOrDefaultPath()), "path to evmone library")
("no-smt", po::bool_switch(&disableSMT), "disable SMT checker");
}
@@ -138,5 +136,3 @@ langutil::EVMVersion CommonOptions::evmVersion() const
}
}
}
+3 -7
View File
@@ -17,17 +17,14 @@
#pragma once
#include <libdevcore/Exceptions.h>
#include <libsolutil/Exceptions.h>
#include <liblangutil/EVMVersion.h>
#include <boost/filesystem/path.hpp>
#include <boost/program_options.hpp>
#include <boost/noncopyable.hpp>
namespace dev
{
namespace test
namespace solidity::test
{
#ifdef _WIN32
@@ -42,7 +39,7 @@ static constexpr auto evmoneDownloadLink = "https://github.com/ethereum/evmone/r
#endif
struct ConfigException : public Exception {};
struct ConfigException : public util::Exception {};
struct CommonOptions: boost::noncopyable
{
@@ -68,4 +65,3 @@ private:
};
}
}
+10 -9
View File
@@ -25,14 +25,15 @@
#include <libevmasm/GasMeter.h>
#include <libdevcore/Exceptions.h>
#include <libdevcore/Assertions.h>
#include <libdevcore/Keccak256.h>
#include <libdevcore/picosha2.h>
#include <libsolutil/Exceptions.h>
#include <libsolutil/Assertions.h>
#include <libsolutil/Keccak256.h>
#include <libsolutil/picosha2.h>
using namespace std;
using namespace dev;
using namespace dev::test;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::test;
using namespace evmc::literals;
evmc::VM& EVMHost::getVM(string const& _path)
@@ -148,9 +149,9 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
evmc_message message = _message;
if (message.depth == 0)
{
message.gas -= message.kind == EVMC_CREATE ? eth::GasCosts::txCreateGas : eth::GasCosts::txGas;
message.gas -= message.kind == EVMC_CREATE ? evmasm::GasCosts::txCreateGas : evmasm::GasCosts::txGas;
for (size_t i = 0; i < message.input_size; ++i)
message.gas -= message.input_data[i] == 0 ? eth::GasCosts::txDataZeroGas : eth::GasCosts::txDataNonZeroGas(m_evmVersion);
message.gas -= message.input_data[i] == 0 ? evmasm::GasCosts::txDataZeroGas : evmasm::GasCosts::txDataNonZeroGas(m_evmVersion);
if (message.gas < 0)
{
evmc::result result({});
@@ -200,7 +201,7 @@ evmc::result EVMHost::call(evmc_message const& _message) noexcept
if (message.kind == EVMC_CREATE)
{
result.gas_left -= eth::GasCosts::createDataGas * result.output_size;
result.gas_left -= evmasm::GasCosts::createDataGas * result.output_size;
if (result.gas_left < 0)
{
result.gas_left = 0;
+5 -8
View File
@@ -27,13 +27,11 @@
#include <liblangutil/EVMVersion.h>
#include <libdevcore/FixedHash.h>
#include <libsolutil/FixedHash.h>
namespace dev
namespace solidity::test
{
namespace test
{
using Address = h160;
using Address = util::h160;
class EVMHost: public evmc::MockedHost
{
@@ -69,8 +67,8 @@ public:
static Address convertFromEVMC(evmc::address const& _addr);
static evmc::address convertToEVMC(Address const& _addr);
static h256 convertFromEVMC(evmc::bytes32 const& _data);
static evmc::bytes32 convertToEVMC(h256 const& _data);
static util::h256 convertFromEVMC(evmc::bytes32 const& _data);
static evmc::bytes32 convertToEVMC(util::h256 const& _data);
private:
evmc::address m_currentAddress = {};
@@ -97,4 +95,3 @@ private:
}
}
+11 -10
View File
@@ -26,7 +26,7 @@
#include <test/evmc/evmc.hpp>
#include <libdevcore/CommonIO.h>
#include <libsolutil/CommonIO.h>
#include <boost/test/framework.hpp>
#include <boost/algorithm/string/replace.hpp>
@@ -34,24 +34,25 @@
#include <cstdlib>
using namespace std;
using namespace dev;
using namespace dev::test;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::test;
ExecutionFramework::ExecutionFramework():
ExecutionFramework(dev::test::Options::get().evmVersion())
ExecutionFramework(solidity::test::Options::get().evmVersion())
{
}
ExecutionFramework::ExecutionFramework(langutil::EVMVersion _evmVersion):
m_evmVersion(_evmVersion),
m_optimiserSettings(solidity::OptimiserSettings::minimal()),
m_showMessages(dev::test::Options::get().showMessages),
m_optimiserSettings(solidity::frontend::OptimiserSettings::minimal()),
m_showMessages(solidity::test::Options::get().showMessages),
m_evmHost(make_shared<EVMHost>(m_evmVersion))
{
if (dev::test::Options::get().optimizeYul)
m_optimiserSettings = solidity::OptimiserSettings::full();
else if (dev::test::Options::get().optimize)
m_optimiserSettings = solidity::OptimiserSettings::standard();
if (solidity::test::Options::get().optimizeYul)
m_optimiserSettings = solidity::frontend::OptimiserSettings::full();
else if (solidity::test::Options::get().optimize)
m_optimiserSettings = solidity::frontend::OptimiserSettings::standard();
m_evmHost->reset();
for (size_t i = 0; i < 10; i++)
+17 -20
View File
@@ -29,21 +29,19 @@
#include <liblangutil/EVMVersion.h>
#include <libdevcore/FixedHash.h>
#include <libdevcore/Keccak256.h>
#include <libsolutil/FixedHash.h>
#include <libsolutil/Keccak256.h>
#include <functional>
namespace dev
{
namespace test
namespace solidity::test
{
class EVMHost;
using rational = boost::rational<dev::bigint>;
using rational = boost::rational<bigint>;
/// An Ethereum address: 20 bytes.
/// @NOTE This is not endian-specific; it's just a bunch of bytes.
using Address = h160;
using Address = util::h160;
// The various denominations; here for ease of use where needed within code.
static const u256 wei = 1;
@@ -101,7 +99,7 @@ public:
bytes const& callContractFunctionWithValueNoEncoding(std::string _sig, u256 const& _value, bytes const& _arguments)
{
FixedHash<4> hash(dev::keccak256(_sig));
util::FixedHash<4> hash(util::keccak256(_sig));
sendMessage(hash.asBytes() + _arguments, false, _value);
return m_output;
}
@@ -131,9 +129,9 @@ public:
BOOST_CHECK_MESSAGE(
contractResult == cppResult,
"Computed values do not match.\nContract: " +
toHex(contractResult) +
util::toHex(contractResult) +
"\nC++: " +
toHex(cppResult)
util::toHex(cppResult)
);
}
@@ -147,11 +145,11 @@ public:
BOOST_CHECK_MESSAGE(
contractResult == cppResult,
"Computed values do not match.\nContract: " +
toHex(contractResult) +
util::toHex(contractResult) +
"\nC++: " +
toHex(cppResult) +
util::toHex(cppResult) +
"\nArgument: " +
toHex(encode(argument))
util::toHex(encode(argument))
);
}
}
@@ -163,7 +161,7 @@ public:
static bytes encode(size_t _value) { return encode(u256(_value)); }
static bytes encode(char const* _value) { return encode(std::string(_value)); }
static bytes encode(uint8_t _value) { return bytes(31, 0) + bytes{_value}; }
static bytes encode(u256 const& _value) { return toBigEndian(_value); }
static bytes encode(u256 const& _value) { return util::toBigEndian(_value); }
/// @returns the fixed-point encoding of a rational number with a given
/// number of fractional bits.
static bytes encode(std::pair<rational, int> const& _valueAndPrecision)
@@ -172,13 +170,13 @@ public:
int fractionalBits = _valueAndPrecision.second;
return encode(u256((value.numerator() << fractionalBits) / value.denominator()));
}
static bytes encode(h256 const& _value) { return _value.asBytes(); }
static bytes encode(util::h256 const& _value) { return _value.asBytes(); }
static bytes encode(bytes const& _value, bool _padLeft = true)
{
bytes padding = bytes((32 - _value.size() % 32) % 32, 0);
return _padLeft ? padding + _value : _value + padding;
}
static bytes encode(std::string const& _value) { return encode(asBytes(_value), false); }
static bytes encode(std::string const& _value) { return encode(util::asBytes(_value), false); }
template <class _T>
static bytes encode(std::vector<_T> const& _value)
{
@@ -265,13 +263,13 @@ protected:
size_t numLogs() const;
size_t numLogTopics(size_t _logIdx) const;
h256 logTopic(size_t _logIdx, size_t _topicIdx) const;
util::h256 logTopic(size_t _logIdx, size_t _topicIdx) const;
Address logAddress(size_t _logIdx) const;
bytes logData(size_t _logIdx) const;
langutil::EVMVersion m_evmVersion;
solidity::RevertStrings m_revertStrings = solidity::RevertStrings::Default;
solidity::OptimiserSettings m_optimiserSettings = solidity::OptimiserSettings::minimal();
solidity::frontend::RevertStrings m_revertStrings = solidity::frontend::RevertStrings::Default;
solidity::frontend::OptimiserSettings m_optimiserSettings = solidity::frontend::OptimiserSettings::minimal();
bool m_showMessages = false;
std::shared_ptr<EVMHost> m_evmHost;
@@ -290,6 +288,5 @@ protected:
} while (0)
}
} // end namespaces
+1 -7
View File
@@ -33,11 +33,7 @@
#include <boost/filesystem.hpp>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
/** Container for all information regarding a testsuite */
@@ -72,5 +68,3 @@ Testsuite const g_interactiveTestsuites[] = {
};
}
}
}
+7 -10
View File
@@ -21,16 +21,14 @@
#include <string>
#include <iostream>
#include <libdevcore/Assertions.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/JSON.h>
#include <libsolutil/Assertions.h>
#include <libsolutil/CommonData.h>
#include <libsolutil/JSON.h>
#include <test/Metadata.h>
using namespace std;
namespace dev
{
namespace test
namespace solidity::test
{
bytes onlyMetadata(bytes const& _bytecode)
@@ -58,7 +56,7 @@ bytes bytecodeSansMetadata(bytes const& _bytecode)
string bytecodeSansMetadata(string const& _bytecode)
{
return toHex(bytecodeSansMetadata(fromHex(_bytecode, WhenError::Throw)));
return util::toHex(bytecodeSansMetadata(fromHex(_bytecode, util::WhenError::Throw)));
}
DEV_SIMPLE_EXCEPTION(CBORException);
@@ -84,7 +82,7 @@ public:
switch(nextType())
{
case MajorType::ByteString:
return toHex(readBytes(readLength()));
return util::toHex(readBytes(readLength()));
case MajorType::TextString:
return readString();
case MajorType::SimpleData:
@@ -174,7 +172,7 @@ std::optional<map<string, string>> parseCBORMetadata(bytes const& _metadata)
bool isValidMetadata(string const& _metadata)
{
Json::Value metadata;
if (!jsonParseStrict(_metadata, metadata))
if (!util::jsonParseStrict(_metadata, metadata))
return false;
if (
@@ -202,5 +200,4 @@ bool isValidMetadata(string const& _metadata)
return true;
}
}
} // end namespaces
+2 -5
View File
@@ -19,15 +19,13 @@
* Metadata processing helpers.
*/
#include <libdevcore/CommonData.h>
#include <libsolutil/CommonData.h>
#include <map>
#include <optional>
#include <string>
namespace dev
{
namespace test
namespace solidity::test
{
/// Returns only the CBOR metadata.
@@ -53,5 +51,4 @@ std::optional<std::map<std::string, std::string>> parseCBORMetadata(bytes const&
/// content is valid metadata.
bool isValidMetadata(std::string const& _metadata);
}
} // end namespaces
+1 -1
View File
@@ -31,7 +31,7 @@
#include <boost/program_options.hpp>
using namespace std;
using namespace dev::test;
using namespace solidity::test;
namespace fs = boost::filesystem;
namespace po = boost::program_options;
+1 -4
View File
@@ -27,9 +27,7 @@
#include <functional>
namespace dev
{
namespace test
namespace solidity::test
{
struct Options: CommonOptions
@@ -44,4 +42,3 @@ private:
};
}
}
+5 -5
View File
@@ -17,7 +17,7 @@
#include <test/TestCase.h>
#include <libdevcore/StringUtils.h>
#include <libsolutil/StringUtils.h>
#include <boost/algorithm/cxx11/none_of.hpp>
#include <boost/algorithm/string.hpp>
@@ -29,10 +29,10 @@
#include <iostream>
using namespace dev;
using namespace solidity;
using namespace dev::solidity::test;
using namespace std;
using namespace solidity;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
void TestCase::printUpdatedSettings(ostream& _stream, const string& _linePrefix, const bool)
{
@@ -57,7 +57,7 @@ bool TestCase::validateSettings(langutil::EVMVersion)
if (!m_settings.empty())
throw runtime_error(
"Unknown setting(s): " +
joinHumanReadable(m_settings | boost::adaptors::map_keys)
util::joinHumanReadable(m_settings | boost::adaptors::map_keys)
);
return true;
}
+2 -7
View File
@@ -28,11 +28,7 @@
#include <vector>
#include <map>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
/**
@@ -114,6 +110,5 @@ public:
/// Returns true, if the test case is supported for EVM version @arg _evmVersion, false otherwise.
bool validateSettings(langutil::EVMVersion _evmVersion) override;
};
}
}
}
+10 -9
View File
@@ -38,6 +38,7 @@
#include <test/InteractiveTests.h>
#include <test/Options.h>
#include <test/EVMHost.h>
#include <test/Common.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/predicate.hpp>
@@ -45,7 +46,7 @@
#include <string>
using namespace boost::unit_test;
using namespace dev::solidity::test;
using namespace solidity::frontend::test;
namespace fs = boost::filesystem;
using namespace std;
@@ -68,7 +69,7 @@ int registerTests(
{
int numTestsAdded = 0;
fs::path fullpath = _basepath / _path;
TestCase::Config config{fullpath.string(), dev::test::Options::get().evmVersion()};
TestCase::Config config{fullpath.string(), solidity::test::Options::get().evmVersion()};
if (fs::is_directory(fullpath))
{
test_suite* sub_suite = BOOST_TEST_SUITE(_path.filename().string());
@@ -93,7 +94,7 @@ int registerTests(
{
stringstream errorStream;
auto testCase = _testCaseCreator(config);
if (testCase->validateSettings(dev::test::Options::get().evmVersion()))
if (testCase->validateSettings(solidity::test::Options::get().evmVersion()))
switch (testCase->run(errorStream))
{
case TestCase::TestResult::Success:
@@ -126,20 +127,20 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
{
master_test_suite_t& master = framework::master_test_suite();
master.p_name.value = "SolidityTests";
dev::test::Options::get().validate();
solidity::test::Options::get().validate();
bool disableSemantics = !dev::test::EVMHost::getVM(dev::test::Options::get().evmonePath.string());
bool disableSemantics = !solidity::test::EVMHost::getVM(solidity::test::Options::get().evmonePath.string());
if (disableSemantics)
{
cout << "Unable to find " << dev::test::evmoneFilename << ". Please provide the path using -- --evmonepath <path>." << endl;
cout << "Unable to find " << solidity::test::evmoneFilename << ". Please provide the path using -- --evmonepath <path>." << endl;
cout << "You can download it at" << endl;
cout << dev::test::evmoneDownloadLink << endl;
cout << solidity::test::evmoneDownloadLink << endl;
cout << endl << "--- SKIPPING ALL SEMANTICS TESTS ---" << endl << endl;
}
// Include the interactive tests in the automatic tests as well
for (auto const& ts: g_interactiveTestsuites)
{
auto const& options = dev::test::Options::get();
auto const& options = solidity::test::Options::get();
if (ts.smt && options.disableSMT)
continue;
@@ -176,7 +177,7 @@ test_suite* init_unit_test_suite( int /*argc*/, char* /*argv*/[] )
removeTestSuite(suite);
}
if (dev::test::Options::get().disableSMT)
if (solidity::test::Options::get().disableSMT)
removeTestSuite("SMTChecker");
return 0;
+1 -1
View File
@@ -2,4 +2,4 @@ Warning: Yul is still experimental. Please use the output with care.
Exception while assembling:
Dynamic exception type:
std::exception::what: Variable a1 is 17 slot(s) too deep inside the stack.
[dev::tag_comment*] = Variable a1 is 17 slot(s) too deep inside the stack.
[solidity::util::tag_comment*] = Variable a1 is 17 slot(s) too deep inside the stack.
+4 -8
View File
@@ -29,13 +29,11 @@
#include <string>
using namespace std;
using namespace dev::test;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::test;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
namespace
@@ -455,6 +453,4 @@ BOOST_AUTO_TEST_CASE(auction_bidding)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+7 -10
View File
@@ -22,9 +22,7 @@
#include <functional>
namespace dev
{
namespace test
namespace solidity::test
{
class ContractInterface
@@ -58,7 +56,7 @@ protected:
BOOST_CHECK(call(_name + "(string,address,bool)", u256(0x60), _arg2, _arg3, _arg1.length(), _arg1).empty());
}
void callStringBytes32(std::string const& _name, std::string const& _arg1, h256 const& _arg2)
void callStringBytes32(std::string const& _name, std::string const& _arg1, util::h256 const& _arg2)
{
BOOST_CHECK(call(_name + "(string,bytes32)", u256(0x40), _arg2, _arg1.length(), _arg1).empty());
}
@@ -68,25 +66,25 @@ protected:
bytes const& ret = call(_name + "(string)", u256(0x20), _arg.length(), _arg);
BOOST_REQUIRE(ret.size() == 0x20);
BOOST_CHECK(std::count(ret.begin(), ret.begin() + 12, 0) == 12);
return u160(u256(h256(ret)));
return u160(u256(util::h256(ret)));
}
std::string callAddressReturnsString(std::string const& _name, u160 const& _arg)
{
bytesConstRef const ret(&call(_name + "(address)", _arg));
BOOST_REQUIRE(ret.size() >= 0x40);
u256 offset(h256(ret.cropped(0, 0x20)));
u256 offset(util::h256(ret.cropped(0, 0x20)));
BOOST_REQUIRE_EQUAL(offset, 0x20);
u256 len(h256(ret.cropped(0x20, 0x20)));
u256 len(util::h256(ret.cropped(0x20, 0x20)));
BOOST_REQUIRE_EQUAL(ret.size(), 0x40 + ((len + 0x1f) / 0x20) * 0x20);
return ret.cropped(0x40, size_t(len)).toString();
}
h256 callStringReturnsBytes32(std::string const& _name, std::string const& _arg)
util::h256 callStringReturnsBytes32(std::string const& _name, std::string const& _arg)
{
bytes const& ret = call(_name + "(string)", u256(0x20), _arg.length(), _arg);
BOOST_REQUIRE(ret.size() == 0x20);
return h256(ret);
return util::h256(ret);
}
private:
@@ -94,6 +92,5 @@ private:
ExecutionFramework& m_framework;
};
}
} // end namespaces
+4 -8
View File
@@ -35,13 +35,11 @@
#include <test/libsolidity/SolidityExecutionFramework.h>
using namespace std;
using namespace dev::test;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::test;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
namespace
@@ -249,6 +247,4 @@ BOOST_AUTO_TEST_CASE(disown)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+5 -10
View File
@@ -35,13 +35,10 @@
#include <test/libsolidity/SolidityExecutionFramework.h>
using namespace std;
using namespace dev::test;
using namespace solidity::test;
using namespace solidity::util;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
static char const* walletCode = R"DELIMITER(
@@ -467,7 +464,7 @@ BOOST_AUTO_TEST_CASE(creation)
{
deployWallet(200);
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(m_sender, h256::AlignRight)) == encodeArgs(true));
bool v2 = dev::test::Options::get().useABIEncoderV2;
bool v2 = solidity::test::Options::get().useABIEncoderV2;
BOOST_REQUIRE(callContractFunction("isOwner(address)", ~h256(m_sender, h256::AlignRight)) == (v2 ? encodeArgs() : encodeArgs(false)));
}
@@ -590,7 +587,7 @@ BOOST_AUTO_TEST_CASE(revoke_addOwner)
BOOST_REQUIRE(callContractFunction("changeRequirement(uint256)", u256(3)) == encodeArgs());
// add a new owner
Address deployer = m_sender;
h256 opHash = dev::keccak256(FixedHash<4>(dev::keccak256("addOwner(address)")).asBytes() + h256(0x33).asBytes());
h256 opHash = util::keccak256(FixedHash<4>(util::keccak256("addOwner(address)")).asBytes() + h256(0x33).asBytes());
BOOST_REQUIRE(callContractFunction("addOwner(address)", h256(0x33)) == encodeArgs());
BOOST_REQUIRE(callContractFunction("isOwner(address)", h256(0x33)) == encodeArgs(false));
m_sender = account(0);
@@ -703,6 +700,4 @@ BOOST_AUTO_TEST_CASE(daylimit_constructor)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+6 -12
View File
@@ -20,7 +20,7 @@
* Tests for the assembler.
*/
#include <libdevcore/JSON.h>
#include <libsolutil/JSON.h>
#include <libevmasm/Assembly.h>
#include <boost/test/unit_test.hpp>
@@ -30,19 +30,15 @@
#include <memory>
using namespace std;
using namespace langutil;
using namespace dev::eth;
using namespace solidity::langutil;
using namespace solidity::evmasm;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
namespace
{
void checkCompilation(::dev::eth::Assembly const& _assembly)
void checkCompilation(evmasm::Assembly const& _assembly)
{
LinkerObject output = _assembly.assemble();
BOOST_CHECK(output.bytecode.size() > 0);
@@ -127,7 +123,7 @@ BOOST_AUTO_TEST_CASE(all_assembly_items)
"auxdata: 0x4266eeaa\n"
);
BOOST_CHECK_EQUAL(
dev::jsonCompactPrint(_assembly.assemblyJSON()),
util::jsonCompactPrint(_assembly.assemblyJSON()),
"{\".auxdata\":\"4266eeaa\",\".code\":[{\"begin\":1,\"end\":3,\"name\":\"tag\",\"value\":\"1\"},"
"{\"begin\":1,\"end\":3,\"name\":\"JUMPDEST\"},"
"{\"begin\":1,\"end\":3,\"name\":\"PUSH\",\"value\":\"1\"},"
@@ -150,6 +146,4 @@ BOOST_AUTO_TEST_CASE(all_assembly_items)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+20 -26
View File
@@ -36,14 +36,10 @@
#include <memory>
using namespace std;
using namespace langutil;
using namespace dev::eth;
using namespace solidity::langutil;
using namespace solidity::evmasm;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
namespace
@@ -57,20 +53,20 @@ namespace
return input;
}
eth::KnownState createInitialState(AssemblyItems const& _input)
evmasm::KnownState createInitialState(AssemblyItems const& _input)
{
eth::KnownState state;
evmasm::KnownState state;
for (auto const& item: addDummyLocations(_input))
state.feedItem(item, true);
return state;
}
AssemblyItems CSE(AssemblyItems const& _input, eth::KnownState const& _state = eth::KnownState())
AssemblyItems CSE(AssemblyItems const& _input, evmasm::KnownState const& _state = evmasm::KnownState())
{
AssemblyItems input = addDummyLocations(_input);
bool usesMsize = (find(_input.begin(), _input.end(), AssemblyItem{Instruction::MSIZE}) != _input.end());
eth::CommonSubexpressionEliminator cse(_state);
evmasm::CommonSubexpressionEliminator cse(_state);
BOOST_REQUIRE(cse.feedItems(input.begin(), input.end(), usesMsize) == input.end());
AssemblyItems output = cse.getOptimizedItems();
@@ -84,7 +80,7 @@ namespace
void checkCSE(
AssemblyItems const& _input,
AssemblyItems const& _expectation,
KnownState const& _state = eth::KnownState()
KnownState const& _state = evmasm::KnownState()
)
{
AssemblyItems output = CSE(_input, _state);
@@ -118,8 +114,8 @@ BOOST_AUTO_TEST_SUITE(Optimiser)
BOOST_AUTO_TEST_CASE(cse_intermediate_swap)
{
eth::KnownState state;
eth::CommonSubexpressionEliminator cse(state);
evmasm::KnownState state;
evmasm::CommonSubexpressionEliminator cse(state);
AssemblyItems input{
Instruction::SWAP1, Instruction::POP, Instruction::ADD, u256(0), Instruction::SWAP1,
Instruction::SLOAD, Instruction::SWAP1, u256(100), Instruction::EXP, Instruction::SWAP1,
@@ -240,7 +236,7 @@ BOOST_AUTO_TEST_CASE(cse_associativity2)
BOOST_AUTO_TEST_CASE(cse_double_shift_right_overflow)
{
if (dev::test::Options::get().evmVersion().hasBitwiseShifting())
if (solidity::test::Options::get().evmVersion().hasBitwiseShifting())
{
AssemblyItems input{
Instruction::CALLVALUE,
@@ -255,7 +251,7 @@ BOOST_AUTO_TEST_CASE(cse_double_shift_right_overflow)
BOOST_AUTO_TEST_CASE(cse_double_shift_left_overflow)
{
if (dev::test::Options::get().evmVersion().hasBitwiseShifting())
if (solidity::test::Options::get().evmVersion().hasBitwiseShifting())
{
AssemblyItems input{
Instruction::DUP1,
@@ -508,7 +504,7 @@ BOOST_AUTO_TEST_CASE(cse_empty_keccak256)
Instruction::KECCAK256
};
checkCSE(input, {
u256(dev::keccak256(bytesConstRef()))
u256(util::keccak256(bytesConstRef()))
});
}
@@ -526,7 +522,7 @@ BOOST_AUTO_TEST_CASE(cse_partial_keccak256)
u256(0xabcd) << (256 - 16),
u256(0),
Instruction::MSTORE,
u256(dev::keccak256(bytes{0xab, 0xcd}))
u256(util::keccak256(bytes{0xab, 0xcd}))
});
}
@@ -651,7 +647,7 @@ BOOST_AUTO_TEST_CASE(cse_keccak256_twice_same_content_noninterfering_store_in_be
BOOST_AUTO_TEST_CASE(cse_with_initially_known_stack)
{
eth::KnownState state = createInitialState(AssemblyItems{
evmasm::KnownState state = createInitialState(AssemblyItems{
u256(0x12),
u256(0x20),
Instruction::ADD
@@ -664,7 +660,7 @@ BOOST_AUTO_TEST_CASE(cse_with_initially_known_stack)
BOOST_AUTO_TEST_CASE(cse_equality_on_initially_known_stack)
{
eth::KnownState state = createInitialState(AssemblyItems{Instruction::DUP1});
evmasm::KnownState state = createInitialState(AssemblyItems{Instruction::DUP1});
AssemblyItems input{
Instruction::EQ
};
@@ -677,7 +673,7 @@ BOOST_AUTO_TEST_CASE(cse_access_previous_sequence)
{
// Tests that the code generator detects whether it tries to access SLOAD instructions
// from a sequenced expression which is not in its scope.
eth::KnownState state = createInitialState(AssemblyItems{
evmasm::KnownState state = createInitialState(AssemblyItems{
u256(0),
Instruction::SLOAD,
u256(1),
@@ -1136,7 +1132,7 @@ BOOST_AUTO_TEST_CASE(jumpdest_removal_subassemblies)
main.append(t1.toSubAssemblyTag(subId));
main.append(u256(8));
main.optimise(true, dev::test::Options::get().evmVersion(), false, 200);
main.optimise(true, solidity::test::Options::get().evmVersion(), false, 200);
AssemblyItems expectationMain{
AssemblyItem(PushSubSize, 0),
@@ -1182,7 +1178,7 @@ BOOST_AUTO_TEST_CASE(cse_sub_zero)
BOOST_AUTO_TEST_CASE(cse_remove_redundant_shift_masking)
{
if (!dev::test::Options::get().evmVersion().hasBitwiseShifting())
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting())
return;
for (int i = 1; i < 256; i++)
@@ -1330,7 +1326,7 @@ BOOST_AUTO_TEST_CASE(cse_remove_unwanted_masking_of_address)
BOOST_AUTO_TEST_CASE(cse_replace_too_large_shift)
{
if (!dev::test::Options::get().evmVersion().hasBitwiseShifting())
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting())
return;
checkCSE({
@@ -1372,6 +1368,4 @@ BOOST_AUTO_TEST_CASE(cse_replace_too_large_shift)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+2 -5
View File
@@ -25,9 +25,7 @@
#include <test/Options.h>
namespace langutil
{
namespace test
namespace solidity::langutil::test
{
BOOST_AUTO_TEST_SUITE(CharStreamtest)
@@ -43,11 +41,10 @@ BOOST_AUTO_TEST_CASE(test_fail)
BOOST_CHECK('w' == source->setPosition(2));
BOOST_REQUIRE_THROW(
source->setPosition(200),
::langutil::InternalCompilerError
::solidity::langutil::InternalCompilerError
);
}
BOOST_AUTO_TEST_SUITE_END()
}
} // end namespaces
+1 -4
View File
@@ -24,9 +24,7 @@
#include <test/Options.h>
namespace langutil
{
namespace test
namespace solidity::langutil::test
{
BOOST_AUTO_TEST_SUITE(SourceLocationTest)
@@ -47,5 +45,4 @@ BOOST_AUTO_TEST_CASE(test_fail)
BOOST_AUTO_TEST_SUITE_END()
}
} // end namespaces
+6 -11
View File
@@ -22,7 +22,7 @@
#include <test/Options.h>
#include <libdevcore/FixedHash.h>
#include <libsolutil/FixedHash.h>
#include <liblll/Compiler.h>
@@ -32,12 +32,9 @@
#include <memory>
using namespace std;
using namespace solidity::util;
namespace dev
{
namespace lll
{
namespace test
namespace solidity::lll::test
{
namespace
@@ -46,7 +43,7 @@ namespace
bool successCompile(string const& _sourceCode)
{
vector<string> errors;
bytes bytecode = lll::compileLLL(_sourceCode, dev::test::Options::get().evmVersion(), false, &errors);
bytes bytecode = lll::compileLLL(_sourceCode, solidity::test::Options::get().evmVersion(), false, &errors);
if (!errors.empty())
return false;
if (bytecode.empty())
@@ -365,7 +362,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_functional)
for (size_t i = 0; i < opcodes_bytecode.size(); i++)
{
vector<string> errors;
bytes code = lll::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors);
bytes code = lll::compileLLL(opcodes_lll[i], solidity::test::Options::get().evmVersion(), false, &errors);
BOOST_REQUIRE_MESSAGE(errors.empty(), opcodes_lll[i]);
@@ -660,7 +657,7 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_asm)
for (size_t i = 0; i < opcodes_bytecode.size(); i++)
{
vector<string> errors;
bytes code = lll::compileLLL(opcodes_lll[i], dev::test::Options::get().evmVersion(), false, &errors);
bytes code = lll::compileLLL(opcodes_lll[i], solidity::test::Options::get().evmVersion(), false, &errors);
BOOST_REQUIRE_MESSAGE(errors.empty(), opcodes_lll[i]);
@@ -670,6 +667,4 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_asm)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+14 -19
View File
@@ -29,13 +29,10 @@
#include <memory>
using namespace std;
using namespace dev::test;
using namespace solidity::util;
using namespace solidity::test;
namespace dev
{
namespace lll
{
namespace test
namespace solidity::lll::test
{
BOOST_FIXTURE_TEST_SUITE(LLLEndToEndTest, LLLExecutionFramework)
@@ -605,7 +602,7 @@ BOOST_AUTO_TEST_CASE(send_two_args)
{
// "send" does not retain enough gas to be able to pay for account creation.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall())
{
char const* sourceCode = R"(
(returnlll
@@ -621,7 +618,7 @@ BOOST_AUTO_TEST_CASE(send_three_args)
{
// "send" does not retain enough gas to be able to pay for account creation.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall())
{
char const* sourceCode = R"(
(returnlll
@@ -740,7 +737,7 @@ BOOST_AUTO_TEST_CASE(msg_three_args)
{
// "msg" does not retain enough gas.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall())
{
char const* sourceCode = R"(
(returnlll
@@ -758,7 +755,7 @@ BOOST_AUTO_TEST_CASE(msg_two_args)
{
// "msg" does not retain enough gas.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall())
{
char const* sourceCode = R"(
(returnlll
@@ -776,7 +773,7 @@ BOOST_AUTO_TEST_CASE(create_one_arg)
{
// "call" does not retain enough gas.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall())
{
char const* sourceCode = R"(
(returnlll
@@ -795,7 +792,7 @@ BOOST_AUTO_TEST_CASE(create_two_args)
{
// "call" does not retain enough gas.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall())
{
char const* sourceCode = R"(
(returnlll
@@ -874,7 +871,7 @@ BOOST_AUTO_TEST_CASE(ecrecover)
{
// "ecrecover" does not retain enough gas.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall())
{
char const* sourceCode = R"(
(returnlll
@@ -898,7 +895,7 @@ BOOST_AUTO_TEST_CASE(sha256_two_args)
{
// "sha256" does not retain enough gas.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall())
{
char const* sourceCode = R"(
(returnlll
@@ -918,7 +915,7 @@ BOOST_AUTO_TEST_CASE(ripemd160_two_args)
{
// "ripemd160" does not retain enough gas.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall())
{
char const* sourceCode = R"(
(returnlll
@@ -938,7 +935,7 @@ BOOST_AUTO_TEST_CASE(sha256_one_arg)
{
// "sha256" does not retain enough gas.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall())
{
char const* sourceCode = R"(
(returnlll
@@ -956,7 +953,7 @@ BOOST_AUTO_TEST_CASE(ripemd160_one_arg)
{
// "ripemd160" does not retain enough gas.
// Disabling for non-tangerineWhistle VMs.
if (dev::test::Options::get().evmVersion().canOverchargeGasForCall())
if (solidity::test::Options::get().evmVersion().canOverchargeGasForCall())
{
char const* sourceCode = R"(
(returnlll
@@ -1026,6 +1023,4 @@ BOOST_AUTO_TEST_CASE(string_literal)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+2 -2
View File
@@ -24,8 +24,8 @@
#include <boost/test/framework.hpp>
#include <test/liblll/ExecutionFramework.h>
using namespace dev::test;
using namespace dev::lll::test;
using namespace solidity::test;
using namespace solidity::lll::test;
LLLExecutionFramework::LLLExecutionFramework() :
ExecutionFramework()
+5 -12
View File
@@ -29,15 +29,10 @@
#include <functional>
namespace dev
{
namespace lll
namespace solidity::lll::test
{
namespace test
{
class LLLExecutionFramework: public dev::test::ExecutionFramework
class LLLExecutionFramework: public solidity::test::ExecutionFramework
{
public:
LLLExecutionFramework();
@@ -47,7 +42,7 @@ public:
u256 const& _value = 0,
std::string const& _contractName = "",
bytes const& _arguments = bytes(),
std::map<std::string, dev::test::Address> const& _libraryAddresses = {}
std::map<std::string, solidity::test::Address> const& _libraryAddresses = {}
) override
{
BOOST_REQUIRE(_contractName.empty());
@@ -56,8 +51,8 @@ public:
std::vector<std::string> errors;
bytes bytecode = lll::compileLLL(
_sourceCode,
dev::test::Options::get().evmVersion(),
m_optimiserSettings == solidity::OptimiserSettings::standard(),
solidity::test::Options::get().evmVersion(),
m_optimiserSettings == solidity::frontend::OptimiserSettings::standard(),
&errors
);
if (!errors.empty())
@@ -71,6 +66,4 @@ public:
}
};
}
}
} // end namespaces
+5 -10
View File
@@ -28,14 +28,11 @@
#define ACCOUNT(n) h256(account(n), h256::AlignRight)
using namespace std;
using namespace dev::lll;
using namespace dev::test;
using namespace solidity::lll;
using namespace solidity::util;
using namespace solidity::test;
namespace dev
{
namespace lll
{
namespace test
namespace solidity::lll::test
{
namespace
@@ -346,7 +343,7 @@ protected:
if (!s_compiledEns)
{
vector<string> errors;
s_compiledEns.reset(new bytes(compileLLL(ensCode, dev::test::Options::get().evmVersion(), dev::test::Options::get().optimize, &errors)));
s_compiledEns.reset(new bytes(compileLLL(ensCode, solidity::test::Options::get().evmVersion(), solidity::test::Options::get().optimize, &errors)));
BOOST_REQUIRE(errors.empty());
}
sendMessage(*s_compiledEns, true);
@@ -503,6 +500,4 @@ BOOST_AUTO_TEST_CASE(fallback)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+5 -10
View File
@@ -33,14 +33,11 @@
#define SUCCESS encodeArgs(1)
using namespace std;
using namespace dev::lll;
using namespace dev::test;
using namespace solidity::lll;
using namespace solidity::util;
using namespace solidity::test;
namespace dev
{
namespace lll
{
namespace test
namespace solidity::lll::test
{
namespace
@@ -397,7 +394,7 @@ protected:
if (!s_compiledErc20)
{
vector<string> errors;
s_compiledErc20.reset(new bytes(compileLLL(erc20Code, dev::test::Options::get().evmVersion(), dev::test::Options::get().optimize, &errors)));
s_compiledErc20.reset(new bytes(compileLLL(erc20Code, solidity::test::Options::get().evmVersion(), solidity::test::Options::get().optimize, &errors)));
BOOST_REQUIRE(errors.empty());
}
sendMessage(*s_compiledErc20, true);
@@ -652,6 +649,4 @@ BOOST_AUTO_TEST_CASE(bad_data)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+1 -7
View File
@@ -27,11 +27,7 @@
using namespace std;
namespace dev
{
namespace lll
{
namespace test
namespace solidity::lll::test
{
namespace
@@ -182,6 +178,4 @@ BOOST_AUTO_TEST_CASE(macro_with_zero_args)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+6 -12
View File
@@ -29,13 +29,9 @@
using namespace std;
using namespace std::placeholders;
using namespace dev::test;
using namespace solidity::test;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
BOOST_FIXTURE_TEST_SUITE(ABIDecoderTest, SolidityExecutionFramework)
@@ -86,7 +82,7 @@ BOOST_AUTO_TEST_CASE(enums)
}
}
)";
bool newDecoder = dev::test::Options::get().useABIEncoderV2;
bool newDecoder = solidity::test::Options::get().useABIEncoderV2;
BOTH_ENCODERS(
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f(uint8)", 0), encodeArgs(u256(0)));
@@ -108,7 +104,7 @@ BOOST_AUTO_TEST_CASE(cleanup)
}
}
)";
bool newDecoder = dev::test::Options::get().useABIEncoderV2;
bool newDecoder = solidity::test::Options::get().useABIEncoderV2;
BOTH_ENCODERS(
compileAndRun(sourceCode);
ABI_CHECK(
@@ -577,7 +573,7 @@ BOOST_AUTO_TEST_CASE(validation_function_type)
function i(function () external[] calldata a) external pure returns (uint r) { a[0]; r = 4; }
}
)";
bool newDecoder = dev::test::Options::get().useABIEncoderV2;
bool newDecoder = solidity::test::Options::get().useABIEncoderV2;
string validFun{"01234567890123456789abcd"};
string invalidFun{"01234567890123456789abcdX"};
BOTH_ENCODERS(
@@ -954,7 +950,7 @@ BOOST_AUTO_TEST_CASE(out_of_bounds_bool_value)
function f(bool b) public pure returns (bool) { return b; }
}
)";
bool newDecoder = dev::test::Options::get().useABIEncoderV2;
bool newDecoder = solidity::test::Options::get().useABIEncoderV2;
BOTH_ENCODERS(
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f(bool)", true), encodeArgs(true));
@@ -967,6 +963,4 @@ BOOST_AUTO_TEST_CASE(out_of_bounds_bool_value)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+7 -12
View File
@@ -33,13 +33,10 @@
using namespace std;
using namespace std::placeholders;
using namespace dev::test;
using namespace solidity::util;
using namespace solidity::test;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
#define REQUIRE_LOG_DATA(DATA) do { \
@@ -168,7 +165,7 @@ BOOST_AUTO_TEST_CASE(memory_array_one_dim)
}
)";
if (!dev::test::Options::get().useABIEncoderV2)
if (!solidity::test::Options::get().useABIEncoderV2)
{
compileAndRun(sourceCode);
callContractFunction("f()");
@@ -343,7 +340,7 @@ BOOST_AUTO_TEST_CASE(external_function)
BOTH_ENCODERS(
compileAndRun(sourceCode);
callContractFunction("f(uint256)", u256(0));
string functionIdF = asString(m_contractAddress.ref()) + asString(FixedHash<4>(dev::keccak256("f(uint256)")).ref());
string functionIdF = asString(m_contractAddress.ref()) + asString(FixedHash<4>(keccak256("f(uint256)")).ref());
REQUIRE_LOG_DATA(encodeArgs(functionIdF, functionIdF));
)
}
@@ -453,7 +450,7 @@ BOOST_AUTO_TEST_CASE(structs)
);
BOOST_CHECK(callContractFunction("f()") == encoded);
REQUIRE_LOG_DATA(encoded);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("e(uint16,(uint16,uint16,(uint64[2])[],uint16))")));
BOOST_CHECK_EQUAL(logTopic(0, 0), keccak256(string("e(uint16,(uint16,uint16,(uint64[2])[],uint16))")));
)
}
@@ -755,7 +752,7 @@ BOOST_AUTO_TEST_CASE(struct_in_constructor_indirect)
}
}
)";
if (dev::test::Options::get().evmVersion().supportsReturndata())
if (solidity::test::Options::get().evmVersion().supportsReturndata())
{
NEW_ENCODER(
compileAndRun(sourceCode, 0, "D");
@@ -787,6 +784,4 @@ BOOST_AUTO_TEST_CASE(struct_in_constructor_data_short)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+8 -7
View File
@@ -23,17 +23,18 @@
#include <test/Options.h>
#include <libsolidity/interface/CompilerStack.h>
#include <libdevcore/JSON.h>
#include <libdevcore/AnsiColorized.h>
#include <libsolutil/JSON.h>
#include <libsolutil/AnsiColorized.h>
#include <boost/algorithm/string.hpp>
#include <fstream>
using namespace std;
using namespace dev;
using namespace dev::solidity;
using namespace dev::solidity::test;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
ABIJsonTest::ABIJsonTest(string const& _filename)
{
@@ -51,8 +52,8 @@ TestCase::TestResult ABIJsonTest::run(ostream& _stream, string const& _linePrefi
CompilerStack compiler;
compiler.setSources({{"", "pragma solidity >=0.0;\n" + m_source}});
compiler.setEVMVersion(dev::test::Options::get().evmVersion());
compiler.setOptimiserSettings(dev::test::Options::get().optimize);
compiler.setEVMVersion(solidity::test::Options::get().evmVersion());
compiler.setOptimiserSettings(solidity::test::Options::get().optimize);
if (!compiler.parseAndAnalyze())
BOOST_THROW_EXCEPTION(runtime_error("Parsing contract failed"));
+1 -7
View File
@@ -24,11 +24,7 @@
#include <string>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
@@ -53,5 +49,3 @@ private:
};
}
}
}
+1 -7
View File
@@ -17,11 +17,7 @@
#include <string>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
static std::string const NewEncoderPragma = "pragma experimental ABIEncoderV2;\n";
@@ -38,6 +34,4 @@ static std::string const NewEncoderPragma = "pragma experimental ABIEncoderV2;\n
NEW_ENCODER(CODE) \
}
}
}
} // end namespaces
+8 -7
View File
@@ -17,7 +17,7 @@
#include <test/libsolidity/ASTJSONTest.h>
#include <test/Options.h>
#include <libdevcore/AnsiColorized.h>
#include <libsolutil/AnsiColorized.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <libsolidity/ast/ASTJsonConverter.h>
#include <libsolidity/interface/CompilerStack.h>
@@ -28,11 +28,12 @@
#include <memory>
#include <stdexcept>
using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::test;
using namespace dev::formatting;
using namespace dev;
using namespace solidity::langutil;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
using namespace solidity::util::formatting;
using namespace solidity::util;
using namespace solidity;
using namespace std;
namespace fs = boost::filesystem;
using namespace boost::unit_test;
@@ -102,7 +103,7 @@ TestCase::TestResult ASTJSONTest::run(ostream& _stream, string const& _linePrefi
sourceIndices[m_sources[i].first] = i + 1;
}
c.setSources(sources);
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.setEVMVersion(solidity::test::Options::get().evmVersion());
if (c.parse())
c.analyze();
else
+2 -8
View File
@@ -17,7 +17,7 @@
#pragma once
#include <libdevcore/AnsiColorized.h>
#include <libsolutil/AnsiColorized.h>
#include <test/TestCase.h>
#include <iosfwd>
@@ -25,11 +25,7 @@
#include <vector>
#include <utility>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
class ASTJSONTest: public TestCase
@@ -54,5 +50,3 @@ private:
};
}
}
}
+8 -7
View File
@@ -29,15 +29,16 @@
#include <liblangutil/Scanner.h>
#include <libdevcore/Keccak256.h>
#include <libsolutil/Keccak256.h>
#include <boost/test/unit_test.hpp>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::test;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::langutil;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
pair<SourceUnit const*, ErrorList>
AnalysisFramework::parseAnalyseAndReturnError(
@@ -50,7 +51,7 @@ AnalysisFramework::parseAnalyseAndReturnError(
{
compiler().reset();
compiler().setSources({{"", _insertVersionPragma ? "pragma solidity >=0.0;\n" + _source : _source}});
compiler().setEVMVersion(dev::test::Options::get().evmVersion());
compiler().setEVMVersion(solidity::test::Options::get().evmVersion());
compiler().setParserErrorRecovery(_allowRecoveryErrors);
_allowMultipleErrors = _allowMultipleErrors || _allowRecoveryErrors;
if (!compiler().parse())
@@ -147,6 +148,6 @@ FunctionTypePointer AnalysisFramework::retrieveFunctionBySignature(
std::string const& _signature
)
{
FixedHash<4> hash(dev::keccak256(_signature));
FixedHash<4> hash(util::keccak256(_signature));
return _contract.interfaceFunctions()[hash];
}
+8 -12
View File
@@ -28,17 +28,15 @@
#include <string>
#include <memory>
namespace dev
namespace solidity::frontend
{
namespace solidity
{
class Type;
class FunctionType;
using TypePointer = Type const*;
using FunctionTypePointer = FunctionType const*;
}
namespace test
namespace solidity::frontend::test
{
class AnalysisFramework
@@ -74,23 +72,23 @@ protected:
std::vector<std::string> m_warningsToFilter = {"This is a pre-release compiler version"};
/// @returns reference to lazy-instanciated CompilerStack.
dev::solidity::CompilerStack& compiler()
solidity::frontend::CompilerStack& compiler()
{
if (!m_compiler)
m_compiler = std::make_unique<dev::solidity::CompilerStack>();
m_compiler = std::make_unique<solidity::frontend::CompilerStack>();
return *m_compiler;
}
/// @returns reference to lazy-instanciated CompilerStack.
dev::solidity::CompilerStack const& compiler() const
solidity::frontend::CompilerStack const& compiler() const
{
if (!m_compiler)
m_compiler = std::make_unique<dev::solidity::CompilerStack>();
m_compiler = std::make_unique<solidity::frontend::CompilerStack>();
return *m_compiler;
}
private:
mutable std::unique_ptr<dev::solidity::CompilerStack> m_compiler;
mutable std::unique_ptr<solidity::frontend::CompilerStack> m_compiler;
};
// Asserts that the compilation down to typechecking
@@ -154,5 +152,3 @@ do \
while(0)
}
}
}
+11 -18
View File
@@ -39,32 +39,27 @@
#include <iostream>
using namespace std;
using namespace langutil;
using namespace dev::eth;
using namespace solidity::langutil;
using namespace solidity::evmasm;
namespace dev
{
namespace solidity
{
class Contract;
namespace test
namespace solidity::frontend::test
{
namespace
{
eth::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
evmasm::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
{
ErrorList errors;
ErrorReporter errorReporter(errors);
Parser parser(errorReporter, dev::test::Options::get().evmVersion());
Parser parser(errorReporter, solidity::test::Options::get().evmVersion());
ASTPointer<SourceUnit> sourceUnit;
BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared<Scanner>(_sourceCode)));
BOOST_CHECK(!!sourceUnit);
map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes;
GlobalContext globalContext;
NameAndTypeResolver resolver(globalContext, dev::test::Options::get().evmVersion(), scopes, errorReporter);
NameAndTypeResolver resolver(globalContext, solidity::test::Options::get().evmVersion(), scopes, errorReporter);
solAssert(Error::containsOnlyWarnings(errorReporter.errors()), "");
resolver.registerDeclarations(*sourceUnit);
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
@@ -77,7 +72,7 @@ eth::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
TypeChecker checker(dev::test::Options::get().evmVersion(), errorReporter);
TypeChecker checker(solidity::test::Options::get().evmVersion(), errorReporter);
BOOST_REQUIRE_NO_THROW(checker.checkTypeRequirements(*contract));
if (!Error::containsOnlyWarnings(errorReporter.errors()))
return AssemblyItems();
@@ -86,9 +81,9 @@ eth::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
Compiler compiler(
dev::test::Options::get().evmVersion(),
solidity::test::Options::get().evmVersion(),
RevertStrings::Default,
dev::test::Options::get().optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal()
solidity::test::Options::get().optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal()
);
compiler.compileContract(*contract, map<ContractDefinition const*, shared_ptr<Compiler const>>{}, bytes());
@@ -166,12 +161,12 @@ BOOST_AUTO_TEST_CASE(location_test)
}
)", "");
AssemblyItems items = compileContract(sourceCode);
bool hasShifts = dev::test::Options::get().evmVersion().hasBitwiseShifting();
bool hasShifts = solidity::test::Options::get().evmVersion().hasBitwiseShifting();
auto codegenCharStream = make_shared<CharStream>("", "--CODEGEN--");
vector<SourceLocation> locations;
if (dev::test::Options::get().optimize)
if (solidity::test::Options::get().optimize)
locations =
vector<SourceLocation>(4, SourceLocation{2, 82, sourceCode}) +
vector<SourceLocation>(1, SourceLocation{8, 17, codegenCharStream}) +
@@ -204,6 +199,4 @@ BOOST_AUTO_TEST_CASE(location_test)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+6 -6
View File
@@ -20,15 +20,15 @@
*/
#include <test/libsolidity/ErrorCheck.h>
#include <libdevcore/Exceptions.h>
#include <libsolutil/Exceptions.h>
#include <string>
#include <set>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace dev::solidity;
using namespace solidity;
using namespace solidity::langutil;
using namespace solidity::frontend;
namespace
{
@@ -38,7 +38,7 @@ std::string errorMessage(Error const& _e)
}
}
bool dev::solidity::searchErrorMessage(Error const& _err, std::string const& _substr)
bool solidity::frontend::test::searchErrorMessage(Error const& _err, std::string const& _substr)
{
if (string const* errorMessage = _err.comment())
{
@@ -54,7 +54,7 @@ bool dev::solidity::searchErrorMessage(Error const& _err, std::string const& _su
return _substr.empty();
}
string dev::solidity::searchErrors(ErrorList const& _errors, vector<pair<Error::Type, string>> const& _expectations)
string solidity::frontend::test::searchErrors(ErrorList const& _errors, vector<pair<Error::Type, string>> const& _expectations)
{
auto expectations = _expectations;
for (auto const& error: _errors)
+4 -4
View File
@@ -26,14 +26,14 @@
#include <vector>
#include <tuple>
namespace dev
{
namespace solidity
namespace solidity::frontend::test
{
bool searchErrorMessage(langutil::Error const& _err, std::string const& _substr);
/// Checks that all provided errors are of the given type and have a given substring in their
/// description.
/// If the expectations are not met, returns a nonempty description, otherwise an empty string.
std::string searchErrors(langutil::ErrorList const& _errors, std::vector<std::pair<langutil::Error::Type, std::string>> const& _expectations);
}
}
+9 -14
View File
@@ -20,28 +20,25 @@
#include <test/libsolidity/SolidityExecutionFramework.h>
#include <liblangutil/EVMVersion.h>
#include <libdevcore/IpfsHash.h>
#include <libsolutil/IpfsHash.h>
#include <libevmasm/GasMeter.h>
#include <cmath>
using namespace std;
using namespace langutil;
using namespace dev::eth;
using namespace dev::solidity;
using namespace dev::test;
using namespace solidity::langutil;
using namespace solidity::langutil;
using namespace solidity::evmasm;
using namespace solidity::frontend;
using namespace solidity::test;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
#define CHECK_DEPLOY_GAS(_gasNoOpt, _gasOpt, _evmVersion) \
do \
{ \
u256 ipfsCost = GasMeter::dataGas(dev::ipfsHash(m_compiler.metadata(m_compiler.lastContractName())), true, _evmVersion); \
u256 ipfsCost = GasMeter::dataGas(util::ipfsHash(m_compiler.metadata(m_compiler.lastContractName())), true, _evmVersion); \
u256 gasOpt{_gasOpt}; \
u256 gasNoOpt{_gasNoOpt}; \
u256 gas = m_optimiserSettings == OptimiserSettings::minimal() ? gasNoOpt : gasOpt; \
@@ -96,7 +93,7 @@ BOOST_AUTO_TEST_CASE(string_storage)
m_compiler.overwriteReleaseFlag(true);
compileAndRun(sourceCode);
auto evmVersion = dev::test::Options::get().evmVersion();
auto evmVersion = solidity::test::Options::get().evmVersion();
if (evmVersion <= EVMVersion::byzantium())
CHECK_DEPLOY_GAS(134209, 130895, evmVersion);
@@ -200,5 +197,3 @@ BOOST_AUTO_TEST_CASE(single_callvaluecheck)
BOOST_AUTO_TEST_SUITE_END()
}
}
}
+16 -22
View File
@@ -29,16 +29,12 @@
#include <liblangutil/SourceReferenceFormatter.h>
using namespace std;
using namespace langutil;
using namespace dev::eth;
using namespace dev::solidity;
using namespace dev::test;
using namespace solidity::langutil;
using namespace solidity::evmasm;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
class GasMeterTestFramework: public SolidityExecutionFramework
@@ -48,7 +44,7 @@ public:
{
m_compiler.reset();
m_compiler.setSources({{"", "pragma solidity >=0.0;\n" + _sourceCode}});
m_compiler.setOptimiserSettings(dev::test::Options::get().optimize);
m_compiler.setOptimiserSettings(solidity::test::Options::get().optimize);
m_compiler.setEVMVersion(m_evmVersion);
BOOST_REQUIRE_MESSAGE(m_compiler.compile(), "Compiling contract failed");
@@ -56,7 +52,7 @@ public:
ASTNode const& sourceUnit = m_compiler.ast("");
BOOST_REQUIRE(items != nullptr);
m_gasCosts = GasEstimator::breakToStatementLevel(
GasEstimator(dev::test::Options::get().evmVersion()).structuralEstimation(*items, vector<ASTNode const*>({&sourceUnit})),
GasEstimator(solidity::test::Options::get().evmVersion()).structuralEstimation(*items, vector<ASTNode const*>({&sourceUnit})),
{&sourceUnit}
);
}
@@ -65,7 +61,7 @@ public:
{
compileAndRun(_sourceCode);
auto state = make_shared<KnownState>();
PathGasMeter meter(*m_compiler.assemblyItems(m_compiler.lastContractName()), dev::test::Options::get().evmVersion());
PathGasMeter meter(*m_compiler.assemblyItems(m_compiler.lastContractName()), solidity::test::Options::get().evmVersion());
GasMeter::GasConsumption gas = meter.estimateMax(0, state);
u256 bytecodeSize(m_compiler.runtimeObject(m_compiler.lastContractName()).bytecode.size());
// costs for deployment
@@ -75,7 +71,7 @@ public:
// Skip the tests when we force ABIEncoderV2.
// TODO: We should enable this again once the yul optimizer is activated.
if (!dev::test::Options::get().useABIEncoderV2)
if (!solidity::test::Options::get().useABIEncoderV2)
{
BOOST_REQUIRE(!gas.isInfinite);
BOOST_CHECK_LE(m_gasUsed, gas.value);
@@ -89,7 +85,7 @@ public:
{
u256 gasUsed = 0;
GasMeter::GasConsumption gas;
FixedHash<4> hash(dev::keccak256(_sig));
util::FixedHash<4> hash(util::keccak256(_sig));
for (bytes const& arguments: _argumentVariants)
{
sendMessage(hash.asBytes() + arguments, false, 0);
@@ -98,13 +94,13 @@ public:
gas = max(gas, gasForTransaction(hash.asBytes() + arguments, false));
}
gas += GasEstimator(dev::test::Options::get().evmVersion()).functionalEstimation(
gas += GasEstimator(solidity::test::Options::get().evmVersion()).functionalEstimation(
*m_compiler.runtimeAssemblyItems(m_compiler.lastContractName()),
_sig
);
// Skip the tests when we force ABIEncoderV2.
// TODO: We should enable this again once the yul optimizer is activated.
if (!dev::test::Options::get().useABIEncoderV2)
if (!solidity::test::Options::get().useABIEncoderV2)
{
BOOST_REQUIRE(!gas.isInfinite);
BOOST_CHECK_LE(m_gasUsed, gas.value);
@@ -114,7 +110,7 @@ public:
static GasMeter::GasConsumption gasForTransaction(bytes const& _data, bool _isCreation)
{
auto evmVersion = dev::test::Options::get().evmVersion();
auto evmVersion = solidity::test::Options::get().evmVersion();
GasMeter::GasConsumption gas = _isCreation ? GasCosts::txCreateGas : GasCosts::txGas;
for (auto i: _data)
gas += i != 0 ? GasCosts::txDataNonZeroGas(evmVersion) : GasCosts::txDataZeroGas;
@@ -122,7 +118,7 @@ public:
}
protected:
map<ASTNode const*, eth::GasMeter::GasConsumption> m_gasCosts;
map<ASTNode const*, evmasm::GasMeter::GasConsumption> m_gasCosts;
};
BOOST_FIXTURE_TEST_SUITE(GasMeterTests, GasMeterTestFramework)
@@ -149,7 +145,7 @@ BOOST_AUTO_TEST_CASE(non_overlapping_filtered_costs)
if (first->first->location().intersects(second->first->location()))
{
BOOST_CHECK_MESSAGE(false, "Source locations should not overlap!");
SourceReferenceFormatter formatter(cout);
langutil::SourceReferenceFormatter formatter(cout);
formatter.printSourceLocation(&first->first->location());
formatter.printSourceLocation(&second->first->location());
@@ -197,7 +193,7 @@ BOOST_AUTO_TEST_CASE(updating_store)
}
}
)";
testCreationTimeGas(sourceCode, m_evmVersion < EVMVersion::constantinople() ? u256(0) : u256(9600));
testCreationTimeGas(sourceCode, m_evmVersion < langutil::EVMVersion::constantinople() ? u256(0) : u256(9600));
}
BOOST_AUTO_TEST_CASE(branches)
@@ -362,5 +358,3 @@ BOOST_AUTO_TEST_CASE(complex_control_flow)
BOOST_AUTO_TEST_SUITE_END()
}
}
}
+6 -6
View File
@@ -17,8 +17,8 @@
#include <test/libsolidity/GasTest.h>
#include <test/Options.h>
#include <libdevcore/CommonIO.h>
#include <libdevcore/JSON.h>
#include <libsolutil/CommonIO.h>
#include <libsolutil/JSON.h>
#include <liblangutil/SourceReferenceFormatterHuman.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/predicate.hpp>
@@ -26,10 +26,10 @@
#include <fstream>
#include <stdexcept>
using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::test;
using namespace dev;
using namespace solidity::langutil;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
using namespace solidity;
using namespace std;
namespace fs = boost::filesystem;
using namespace boost::unit_test;
+1 -7
View File
@@ -26,11 +26,7 @@
#include <vector>
#include <utility>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
class GasTest: AnalysisFramework, public TestCase
@@ -56,5 +52,3 @@ private:
};
}
}
}
+6 -12
View File
@@ -32,11 +32,7 @@
using namespace std;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
BOOST_AUTO_TEST_SUITE(SolidityImports)
@@ -51,7 +47,7 @@ BOOST_AUTO_TEST_CASE(remappings)
{"s_1.4.6/s.sol", "contract S {} pragma solidity >=0.0;"},
{"Tee/tee.sol", "contract Tee {} pragma solidity >=0.0;"}
});
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.setEVMVersion(solidity::test::Options::get().evmVersion());
BOOST_CHECK(c.compile());
}
@@ -65,7 +61,7 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings)
{"s_1.4.6/s.sol", "contract SSix {} pragma solidity >=0.0;"},
{"s_1.4.7/s.sol", "contract SSeven {} pragma solidity >=0.0;"}
});
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.setEVMVersion(solidity::test::Options::get().evmVersion());
BOOST_CHECK(c.compile());
}
@@ -83,7 +79,7 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings_ensure_default_and_module_pres
{"vendor/foo_1.0.0/foo.sol", "contract Foo1 {} pragma solidity >=0.0;"},
{"vendor/foo_2.0.0/foo.sol", "contract Foo2 {} pragma solidity >=0.0;"}
});
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.setEVMVersion(solidity::test::Options::get().evmVersion());
BOOST_CHECK(c.compile());
}
@@ -97,7 +93,7 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings_order_independent_1)
{"d/z.sol", "contract D {} pragma solidity >=0.0;"},
{"e/y/z/z.sol", "contract E {} pragma solidity >=0.0;"}
});
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.setEVMVersion(solidity::test::Options::get().evmVersion());
BOOST_CHECK(c.compile());
}
@@ -111,12 +107,10 @@ BOOST_AUTO_TEST_CASE(context_dependent_remappings_order_independent_2)
{"d/z.sol", "contract D {} pragma solidity >=0.0;"},
{"e/y/z/z.sol", "contract E {} pragma solidity >=0.0;"}
});
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.setEVMVersion(solidity::test::Options::get().evmVersion());
BOOST_CHECK(c.compile());
}
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+13 -19
View File
@@ -41,14 +41,10 @@
#include <string>
using namespace std;
using namespace langutil;
using namespace yul;
using namespace solidity::langutil;
using namespace solidity::yul;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
namespace
@@ -62,7 +58,7 @@ std::optional<Error> parseAndReturnFirstError(
AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM
)
{
AssemblyStack stack(dev::test::Options::get().evmVersion(), _language, dev::solidity::OptimiserSettings::none());
AssemblyStack stack(solidity::test::Options::get().evmVersion(), _language, solidity::frontend::OptimiserSettings::none());
bool success = false;
try
{
@@ -129,7 +125,7 @@ Error expectError(
void parsePrintCompare(string const& _source, bool _canWarn = false)
{
AssemblyStack stack(dev::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
AssemblyStack stack(solidity::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
BOOST_REQUIRE(stack.parseAndAnalyze("", _source));
if (_canWarn)
BOOST_REQUIRE(Error::containsOnlyWarnings(stack.errors()));
@@ -542,7 +538,7 @@ BOOST_AUTO_TEST_CASE(print_string_literal_unicode)
{
string source = "{ let x := \"\\u1bac\" }";
string parsed = "object \"object\" {\n code { let x := \"\\xe1\\xae\\xac\" }\n}\n";
AssemblyStack stack(dev::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
AssemblyStack stack(solidity::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
BOOST_REQUIRE(stack.parseAndAnalyze("", source));
BOOST_REQUIRE(stack.errors().empty());
BOOST_CHECK_EQUAL(stack.print(), parsed);
@@ -689,42 +685,42 @@ BOOST_AUTO_TEST_CASE(keccak256)
BOOST_AUTO_TEST_CASE(returndatasize)
{
if (!dev::test::Options::get().evmVersion().supportsReturndata())
if (!solidity::test::Options::get().evmVersion().supportsReturndata())
return;
BOOST_CHECK(successAssemble("{ let r := returndatasize() }"));
}
BOOST_AUTO_TEST_CASE(returndatacopy)
{
if (!dev::test::Options::get().evmVersion().supportsReturndata())
if (!solidity::test::Options::get().evmVersion().supportsReturndata())
return;
BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }"));
}
BOOST_AUTO_TEST_CASE(returndatacopy_functional)
{
if (!dev::test::Options::get().evmVersion().supportsReturndata())
if (!solidity::test::Options::get().evmVersion().supportsReturndata())
return;
BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }"));
}
BOOST_AUTO_TEST_CASE(staticcall)
{
if (!dev::test::Options::get().evmVersion().hasStaticCall())
if (!solidity::test::Options::get().evmVersion().hasStaticCall())
return;
BOOST_CHECK(successAssemble("{ pop(staticcall(10000, 0x123, 64, 0x10, 128, 0x10)) }"));
}
BOOST_AUTO_TEST_CASE(create2)
{
if (!dev::test::Options::get().evmVersion().hasCreate2())
if (!solidity::test::Options::get().evmVersion().hasCreate2())
return;
BOOST_CHECK(successAssemble("{ pop(create2(10, 0x123, 32, 64)) }"));
}
BOOST_AUTO_TEST_CASE(shift)
{
if (!dev::test::Options::get().evmVersion().hasBitwiseShifting())
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting())
return;
BOOST_CHECK(successAssemble("{ pop(shl(10, 32)) }"));
BOOST_CHECK(successAssemble("{ pop(shr(10, 32)) }"));
@@ -733,7 +729,7 @@ BOOST_AUTO_TEST_CASE(shift)
BOOST_AUTO_TEST_CASE(shift_constantinople_warning)
{
if (dev::test::Options::get().evmVersion().hasBitwiseShifting())
if (solidity::test::Options::get().evmVersion().hasBitwiseShifting())
return;
CHECK_PARSE_WARNING("{ pop(shl(10, 32)) }", TypeError, "The \"shl\" instruction is only available for Constantinople-compatible VMs");
CHECK_PARSE_WARNING("{ pop(shr(10, 32)) }", TypeError, "The \"shr\" instruction is only available for Constantinople-compatible VMs");
@@ -750,6 +746,4 @@ BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+3 -9
View File
@@ -21,18 +21,14 @@
#include <string>
#include <boost/test/unit_test.hpp>
#include <libdevcore/JSON.h>
#include <libsolutil/JSON.h>
#include <libsolidity/interface/ReadFile.h>
#include <libsolidity/interface/Version.h>
#include <libsolc/libsolc.h>
using namespace std;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
namespace
@@ -64,7 +60,7 @@ Json::Value compile(string const& _input, CStyleReadFileCallback _callback = nul
solidity_free(output_ptr);
solidity_reset();
Json::Value ret;
BOOST_REQUIRE(jsonParseStrict(output, ret));
BOOST_REQUIRE(util::jsonParseStrict(output, ret));
return ret;
}
@@ -184,6 +180,4 @@ BOOST_AUTO_TEST_CASE(with_callback)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+34 -40
View File
@@ -23,26 +23,22 @@
#include <test/Options.h>
#include <libsolidity/interface/CompilerStack.h>
#include <libsolidity/interface/Version.h>
#include <libdevcore/SwarmHash.h>
#include <libdevcore/IpfsHash.h>
#include <libdevcore/JSON.h>
#include <libsolutil/SwarmHash.h>
#include <libsolutil/IpfsHash.h>
#include <libsolutil/JSON.h>
using namespace std;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
namespace
{
map<string, string> requireParsedCBORMetadata(bytes const& _bytecode)
{
bytes cborMetadata = dev::test::onlyMetadata(_bytecode);
bytes cborMetadata = solidity::test::onlyMetadata(_bytecode);
BOOST_REQUIRE(!cborMetadata.empty());
std::optional<map<string, string>> tmp = dev::test::parseCBORMetadata(cborMetadata);
std::optional<map<string, string>> tmp = solidity::test::parseCBORMetadata(cborMetadata);
BOOST_REQUIRE(tmp);
return *tmp;
}
@@ -70,13 +66,13 @@ BOOST_AUTO_TEST_CASE(metadata_stamp)
CompilerStack compilerStack;
compilerStack.overwriteReleaseFlag(release);
compilerStack.setSources({{"", std::string(sourceCode)}});
compilerStack.setEVMVersion(dev::test::Options::get().evmVersion());
compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize);
compilerStack.setMetadataHash(metadataHash);
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
bytes const& bytecode = compilerStack.runtimeObject("test").bytecode;
std::string const& metadata = compilerStack.metadata("test");
BOOST_CHECK(dev::test::isValidMetadata(metadata));
BOOST_CHECK(solidity::test::isValidMetadata(metadata));
auto const cborMetadata = requireParsedCBORMetadata(bytecode);
if (metadataHash == CompilerStack::MetadataHash::None)
@@ -87,25 +83,25 @@ BOOST_AUTO_TEST_CASE(metadata_stamp)
string hashMethod;
if (metadataHash == CompilerStack::MetadataHash::IPFS)
{
hash = dev::ipfsHash(metadata);
hash = util::ipfsHash(metadata);
BOOST_REQUIRE(hash.size() == 34);
hashMethod = "ipfs";
}
else
{
hash = dev::bzzr1Hash(metadata).asBytes();
hash = util::bzzr1Hash(metadata).asBytes();
BOOST_REQUIRE(hash.size() == 32);
hashMethod = "bzzr1";
}
BOOST_CHECK(cborMetadata.size() == 2);
BOOST_CHECK(cborMetadata.count(hashMethod) == 1);
BOOST_CHECK(cborMetadata.at(hashMethod) == toHex(hash));
BOOST_CHECK(cborMetadata.at(hashMethod) == util::toHex(hash));
}
BOOST_CHECK(cborMetadata.count("solc") == 1);
if (release)
BOOST_CHECK(cborMetadata.at("solc") == toHex(VersionCompactBytes));
BOOST_CHECK(cborMetadata.at("solc") == util::toHex(VersionCompactBytes));
else
BOOST_CHECK(cborMetadata.at("solc") == VersionStringStrict);
}
@@ -131,13 +127,13 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental)
CompilerStack compilerStack;
compilerStack.overwriteReleaseFlag(release);
compilerStack.setSources({{"", std::string(sourceCode)}});
compilerStack.setEVMVersion(dev::test::Options::get().evmVersion());
compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize);
compilerStack.setMetadataHash(metadataHash);
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
bytes const& bytecode = compilerStack.runtimeObject("test").bytecode;
std::string const& metadata = compilerStack.metadata("test");
BOOST_CHECK(dev::test::isValidMetadata(metadata));
BOOST_CHECK(solidity::test::isValidMetadata(metadata));
auto const cborMetadata = requireParsedCBORMetadata(bytecode);
if (metadataHash == CompilerStack::MetadataHash::None)
@@ -148,25 +144,25 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental)
string hashMethod;
if (metadataHash == CompilerStack::MetadataHash::IPFS)
{
hash = dev::ipfsHash(metadata);
hash = util::ipfsHash(metadata);
BOOST_REQUIRE(hash.size() == 34);
hashMethod = "ipfs";
}
else
{
hash = dev::bzzr1Hash(metadata).asBytes();
hash = util::bzzr1Hash(metadata).asBytes();
BOOST_REQUIRE(hash.size() == 32);
hashMethod = "bzzr1";
}
BOOST_CHECK(cborMetadata.size() == 3);
BOOST_CHECK(cborMetadata.count(hashMethod) == 1);
BOOST_CHECK(cborMetadata.at(hashMethod) == toHex(hash));
BOOST_CHECK(cborMetadata.at(hashMethod) == util::toHex(hash));
}
BOOST_CHECK(cborMetadata.count("solc") == 1);
if (release)
BOOST_CHECK(cborMetadata.at("solc") == toHex(VersionCompactBytes));
BOOST_CHECK(cborMetadata.at("solc") == util::toHex(VersionCompactBytes));
else
BOOST_CHECK(cborMetadata.at("solc") == VersionStringStrict);
BOOST_CHECK(cborMetadata.count("experimental") == 1);
@@ -193,14 +189,14 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources)
{"A", std::string(sourceCodeA)},
{"B", std::string(sourceCodeB)},
});
compilerStack.setEVMVersion(dev::test::Options::get().evmVersion());
compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize);
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
std::string const& serialisedMetadata = compilerStack.metadata("A");
BOOST_CHECK(dev::test::isValidMetadata(serialisedMetadata));
BOOST_CHECK(solidity::test::isValidMetadata(serialisedMetadata));
Json::Value metadata;
BOOST_REQUIRE(jsonParseStrict(serialisedMetadata, metadata));
BOOST_REQUIRE(util::jsonParseStrict(serialisedMetadata, metadata));
BOOST_CHECK_EQUAL(metadata["sources"].size(), 1);
BOOST_CHECK(metadata["sources"].isMember("A"));
@@ -234,14 +230,14 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports)
{"B", std::string(sourceCodeB)},
{"C", std::string(sourceCodeC)}
});
compilerStack.setEVMVersion(dev::test::Options::get().evmVersion());
compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize);
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
std::string const& serialisedMetadata = compilerStack.metadata("C");
BOOST_CHECK(dev::test::isValidMetadata(serialisedMetadata));
BOOST_CHECK(solidity::test::isValidMetadata(serialisedMetadata));
Json::Value metadata;
BOOST_REQUIRE(jsonParseStrict(serialisedMetadata, metadata));
BOOST_REQUIRE(util::jsonParseStrict(serialisedMetadata, metadata));
BOOST_CHECK_EQUAL(metadata["sources"].size(), 3);
BOOST_CHECK(metadata["sources"].isMember("A"));
@@ -262,14 +258,14 @@ BOOST_AUTO_TEST_CASE(metadata_useLiteralContent)
{
CompilerStack compilerStack;
compilerStack.setSources({{"", std::string(_src)}});
compilerStack.setEVMVersion(dev::test::Options::get().evmVersion());
compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize);
compilerStack.useMetadataLiteralSources(_literal);
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
string metadata_str = compilerStack.metadata("test");
Json::Value metadata;
jsonParseStrict(metadata_str, metadata);
BOOST_CHECK(dev::test::isValidMetadata(metadata_str));
util::jsonParseStrict(metadata_str, metadata);
BOOST_CHECK(solidity::test::isValidMetadata(metadata_str));
BOOST_CHECK(metadata.isMember("settings"));
BOOST_CHECK(metadata["settings"].isMember("metadata"));
BOOST_CHECK(metadata["settings"]["metadata"].isMember("bytecodeHash"));
@@ -297,9 +293,9 @@ BOOST_AUTO_TEST_CASE(metadata_revert_strings)
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
std::string const& serialisedMetadata = compilerStack.metadata("A");
BOOST_CHECK(dev::test::isValidMetadata(serialisedMetadata));
BOOST_CHECK(solidity::test::isValidMetadata(serialisedMetadata));
Json::Value metadata;
BOOST_REQUIRE(jsonParseStrict(serialisedMetadata, metadata));
BOOST_REQUIRE(util::jsonParseStrict(serialisedMetadata, metadata));
BOOST_CHECK_EQUAL(metadata["settings"]["debug"]["revertStrings"], "strip");
}
@@ -307,5 +303,3 @@ BOOST_AUTO_TEST_CASE(metadata_revert_strings)
BOOST_AUTO_TEST_SUITE_END()
}
}
}
+4 -10
View File
@@ -26,13 +26,9 @@
#include <string>
using namespace std;
using namespace langutil;
using namespace solidity::langutil;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
class SMTCheckerFramework: public AnalysisFramework
@@ -87,7 +83,7 @@ BOOST_AUTO_TEST_CASE(import_base)
}
)"}
});
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.setEVMVersion(solidity::test::Options::get().evmVersion());
BOOST_CHECK(c.compile());
unsigned asserts = 0;
@@ -126,7 +122,7 @@ BOOST_AUTO_TEST_CASE(import_library)
}
)"}
});
c.setEVMVersion(dev::test::Options::get().evmVersion());
c.setEVMVersion(solidity::test::Options::get().evmVersion());
BOOST_CHECK(c.compile());
unsigned asserts = 0;
@@ -145,5 +141,3 @@ BOOST_AUTO_TEST_CASE(import_library)
BOOST_AUTO_TEST_SUITE_END()
}
}
}
+7 -6
View File
@@ -18,8 +18,8 @@
#include <test/libsolidity/SMTCheckerJSONTest.h>
#include <test/Options.h>
#include <libsolidity/interface/StandardCompiler.h>
#include <libdevcore/CommonIO.h>
#include <libdevcore/JSON.h>
#include <libsolutil/CommonIO.h>
#include <libsolutil/JSON.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/predicate.hpp>
@@ -29,11 +29,12 @@
#include <stdexcept>
#include <sstream>
using namespace dev::solidity::test;
using namespace dev::solidity;
using namespace dev::formatting;
using namespace dev;
using namespace std;
using namespace solidity;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
using namespace solidity::util;
using namespace solidity::util::formatting;
using namespace boost::unit_test;
SMTCheckerJSONTest::SMTCheckerJSONTest(string const& _filename, langutil::EVMVersion _evmVersion)
+2 -8
View File
@@ -19,15 +19,11 @@
#include <test/libsolidity/SyntaxTest.h>
#include <libdevcore/JSON.h>
#include <libsolutil/JSON.h>
#include <string>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
class SMTCheckerJSONTest: public SyntaxTest
@@ -49,5 +45,3 @@ private:
};
}
}
}
+4 -4
View File
@@ -20,11 +20,11 @@
#include <libsolidity/formal/ModelChecker.h>
using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::test;
using namespace dev;
using namespace std;
using namespace solidity;
using namespace solidity::langutil;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
SMTCheckerTest::SMTCheckerTest(string const& _filename, langutil::EVMVersion _evmVersion): SyntaxTest(_filename, _evmVersion)
{
+1 -7
View File
@@ -23,11 +23,7 @@
#include <string>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
class SMTCheckerTest: public SyntaxTest
@@ -51,5 +47,3 @@ protected:
};
}
}
}
+2 -8
View File
@@ -28,13 +28,9 @@
#include <test/Options.h>
using namespace std;
using namespace langutil;
using namespace solidity::langutil;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
BOOST_AUTO_TEST_SUITE(SemVerMatcher)
@@ -238,6 +234,4 @@ BOOST_AUTO_TEST_CASE(negative_range)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+6 -6
View File
@@ -25,11 +25,11 @@
#include <memory>
#include <stdexcept>
using namespace dev;
using namespace solidity;
using namespace dev::solidity::test;
using namespace dev::formatting;
using namespace std;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::util::formatting;
using namespace solidity::frontend::test;
using namespace boost;
using namespace boost::algorithm;
using namespace boost::unit_test;
@@ -78,7 +78,7 @@ TestCase::TestResult SemanticTest::run(ostream& _stream, string const& _linePref
for (auto& test: m_tests)
test.reset();
map<string, dev::test::Address> libraries;
map<string, solidity::test::Address> libraries;
bool constructed = false;
@@ -190,7 +190,7 @@ void SemanticTest::parseExpectations(istream& _stream)
std::move(functionCalls.begin(), functionCalls.end(), back_inserter(m_tests));
}
bool SemanticTest::deploy(string const& _contractName, u256 const& _value, bytes const& _arguments, map<string, dev::test::Address> const& _libraries)
bool SemanticTest::deploy(string const& _contractName, u256 const& _value, bytes const& _arguments, map<string, solidity::test::Address> const& _libraries)
{
auto output = compileAndRunWithoutCheck(m_source, _value, _contractName, _arguments, _libraries);
return !output.empty() && m_transactionSuccessful;
+3 -9
View File
@@ -20,18 +20,14 @@
#include <test/libsolidity/AnalysisFramework.h>
#include <test/TestCase.h>
#include <liblangutil/Exceptions.h>
#include <libdevcore/AnsiColorized.h>
#include <libsolutil/AnsiColorized.h>
#include <iosfwd>
#include <string>
#include <vector>
#include <utility>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
/**
@@ -60,7 +56,7 @@ public:
/// Compiles and deploys currently held source.
/// Returns true if deployment was successful, false otherwise.
bool deploy(std::string const& _contractName, u256 const& _value, bytes const& _arguments, std::map<std::string, dev::test::Address> const& _libraries = {});
bool deploy(std::string const& _contractName, u256 const& _value, bytes const& _arguments, std::map<std::string, solidity::test::Address> const& _libraries = {});
private:
std::string m_source;
@@ -71,5 +67,3 @@ private:
};
}
}
}
+4 -10
View File
@@ -24,11 +24,7 @@
using namespace std;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
BOOST_FIXTURE_TEST_SUITE(SolidityCompiler, AnalysisFramework)
@@ -42,11 +38,11 @@ BOOST_AUTO_TEST_CASE(does_not_include_creation_time_only_internal_functions)
function f() internal { for (uint i = 0; i < 10; ++i) x += 3 + i; }
}
)";
compiler().setOptimiserSettings(dev::test::Options::get().optimize);
compiler().setOptimiserSettings(solidity::test::Options::get().optimize);
BOOST_REQUIRE(success(sourceCode));
BOOST_REQUIRE_MESSAGE(compiler().compile(), "Compiling contract failed");
bytes const& creationBytecode = dev::test::bytecodeSansMetadata(compiler().object("C").bytecode);
bytes const& runtimeBytecode = dev::test::bytecodeSansMetadata(compiler().runtimeObject("C").bytecode);
bytes const& creationBytecode = solidity::test::bytecodeSansMetadata(compiler().object("C").bytecode);
bytes const& runtimeBytecode = solidity::test::bytecodeSansMetadata(compiler().runtimeObject("C").bytecode);
BOOST_CHECK(creationBytecode.size() >= 90);
BOOST_CHECK(creationBytecode.size() <= 120);
BOOST_CHECK(runtimeBytecode.size() >= 10);
@@ -56,5 +52,3 @@ BOOST_AUTO_TEST_CASE(does_not_include_creation_time_only_internal_functions)
BOOST_AUTO_TEST_SUITE_END()
}
}
}
+100 -104
View File
@@ -31,7 +31,7 @@
#include <libevmasm/Assembly.h>
#include <libdevcore/Keccak256.h>
#include <libsolutil/Keccak256.h>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/test/unit_test.hpp>
@@ -42,8 +42,10 @@
using namespace std;
using namespace std::placeholders;
using namespace dev::test;
using namespace langutil;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::test;
using namespace solidity::langutil;
#define ALSO_VIA_YUL(CODE) \
{ \
@@ -52,11 +54,7 @@ using namespace langutil;
{ CODE } \
}
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
BOOST_FIXTURE_TEST_SUITE(SolidityEndToEndTest, SolidityExecutionFramework)
@@ -1081,8 +1079,8 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors)
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("data()"), encodeArgs(8));
ABI_CHECK(callContractFunction("name()"), encodeArgs("Celina"));
ABI_CHECK(callContractFunction("a_hash()"), encodeArgs(dev::keccak256(bytes(1, 0x7b))));
ABI_CHECK(callContractFunction("an_address()"), encodeArgs(toBigEndian(u160(0x1337))));
ABI_CHECK(callContractFunction("a_hash()"), encodeArgs(util::keccak256(bytes(1, 0x7b))));
ABI_CHECK(callContractFunction("an_address()"), encodeArgs(util::toBigEndian(u160(0x1337))));
ABI_CHECK(callContractFunction("super_secret_data()"), bytes());
);
}
@@ -1136,7 +1134,7 @@ BOOST_AUTO_TEST_CASE(msg_sig)
)";
ALSO_VIA_YUL(
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("foo(uint256)", 0), encodeArgs(asString(FixedHash<4>(dev::keccak256("foo(uint256)")).asBytes())));
ABI_CHECK(callContractFunction("foo(uint256)", 0), encodeArgs(asString(FixedHash<4>(util::keccak256("foo(uint256)")).asBytes())));
)
}
@@ -1154,7 +1152,7 @@ BOOST_AUTO_TEST_CASE(msg_sig_after_internal_call_is_same)
)";
ALSO_VIA_YUL(
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("foo(uint256)", 0), encodeArgs(asString(FixedHash<4>(dev::keccak256("foo(uint256)")).asBytes())));
ABI_CHECK(callContractFunction("foo(uint256)", 0), encodeArgs(asString(FixedHash<4>(util::keccak256("foo(uint256)")).asBytes())));
)
}
@@ -1391,7 +1389,7 @@ BOOST_AUTO_TEST_CASE(keccak256)
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> u256
{
return dev::keccak256(toBigEndian(_x));
return util::keccak256(toBigEndian(_x));
};
testContractAgainstCpp("a(bytes32)", f, u256(4));
testContractAgainstCpp("a(bytes32)", f, u256(5));
@@ -1462,7 +1460,7 @@ BOOST_AUTO_TEST_CASE(packed_keccak256)
compileAndRun(sourceCode);
auto f = [&](u256 const& _x) -> u256
{
return dev::keccak256(
return util::keccak256(
toCompactBigEndian(unsigned(8)) +
toBigEndian(_x) +
toCompactBigEndian(unsigned(65536)) +
@@ -1494,9 +1492,9 @@ BOOST_AUTO_TEST_CASE(packed_keccak256_complex_types)
compileAndRun(sourceCode);
// Strangely, arrays are encoded with intra-element padding.
ABI_CHECK(callContractFunction("f()"), encodeArgs(
dev::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))),
dev::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))),
dev::keccak256(fromHex(m_contractAddress.hex() + "26121ff0"))
util::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))),
util::keccak256(encodeArgs(u256("0xfffffffffffffffffffffffffffffe"), u256("0xfffffffffffffffffffffffffffffd"), u256("0xfffffffffffffffffffffffffffffc"))),
util::keccak256(fromHex(m_contractAddress.hex() + "26121ff0"))
));
}
@@ -2508,7 +2506,7 @@ BOOST_AUTO_TEST_CASE(default_fallback_throws)
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f()"), encodeArgs(0));
if (dev::test::Options::get().evmVersion().hasStaticCall())
if (solidity::test::Options::get().evmVersion().hasStaticCall())
{
char const* sourceCode = R"YY(
contract A {
@@ -2549,7 +2547,7 @@ BOOST_AUTO_TEST_CASE(event)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK_EQUAL(h256(logData(0)), h256(u256(value)));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 3);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,bytes32,uint256)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bytes32,uint256)")));
BOOST_CHECK_EQUAL(logTopic(0, 1), h256(m_sender, h256::AlignRight));
BOOST_CHECK_EQUAL(logTopic(0, 2), h256(id));
}
@@ -2574,7 +2572,7 @@ BOOST_AUTO_TEST_CASE(event_emit)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK_EQUAL(h256(logData(0)), h256(u256(value)));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 3);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,bytes32,uint256)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bytes32,uint256)")));
BOOST_CHECK_EQUAL(logTopic(0, 1), h256(m_sender, h256::AlignRight));
BOOST_CHECK_EQUAL(logTopic(0, 2), h256(id));
)
@@ -2598,7 +2596,7 @@ BOOST_AUTO_TEST_CASE(event_no_arguments)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0).empty());
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit()")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit()")));
)
}
@@ -2621,7 +2619,7 @@ BOOST_AUTO_TEST_CASE(event_access_through_base_name_emit)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0).empty());
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("x()")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("x()")));
}
BOOST_AUTO_TEST_CASE(events_with_same_name)
@@ -2659,28 +2657,28 @@ BOOST_AUTO_TEST_CASE(events_with_same_name)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0).empty());
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit()")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit()")));
ABI_CHECK(callContractFunction("deposit(address)", c_loggedAddress), encodeArgs(u256(2)));
BOOST_REQUIRE_EQUAL(numLogs(), 1);
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
ABI_CHECK(logData(0), encodeArgs(c_loggedAddress));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address)")));
ABI_CHECK(callContractFunction("deposit(address,uint256)", c_loggedAddress, u256(100)), encodeArgs(u256(3)));
BOOST_REQUIRE_EQUAL(numLogs(), 1);
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
ABI_CHECK(logData(0), encodeArgs(c_loggedAddress, 100));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,uint256)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,uint256)")));
ABI_CHECK(callContractFunction("deposit(address,bool)", c_loggedAddress, false), encodeArgs(u256(4)));
BOOST_REQUIRE_EQUAL(numLogs(), 1);
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
ABI_CHECK(logData(0), encodeArgs(c_loggedAddress, false));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,bool)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bool)")));
)
}
@@ -2720,21 +2718,21 @@ BOOST_AUTO_TEST_CASE(events_with_same_name_inherited_emit)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0).empty());
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit()")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit()")));
ABI_CHECK(callContractFunction("deposit(address)", c_loggedAddress), encodeArgs(u256(1)));
BOOST_REQUIRE_EQUAL(numLogs(), 1);
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs(c_loggedAddress));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address)")));
ABI_CHECK(callContractFunction("deposit(address,uint256)", c_loggedAddress, u256(100)), encodeArgs(u256(1)));
BOOST_REQUIRE_EQUAL(numLogs(), 1);
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
ABI_CHECK(logData(0), encodeArgs(c_loggedAddress, 100));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,uint256)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,uint256)")));
)
}
@@ -2800,7 +2798,7 @@ BOOST_AUTO_TEST_CASE(event_lots_of_data)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs((u160)m_sender, id, value, true));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,bytes32,uint256,bool)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bytes32,uint256,bool)")));
)
}
@@ -2818,9 +2816,9 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data)
callContractFunction("deposit()");
BOOST_REQUIRE_EQUAL(numLogs(), 1);
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK_EQUAL(toHex(logData(0)), toHex(encodeArgs(10, 0x60, 15, 4, asString(FixedHash<4>(dev::keccak256("deposit()")).asBytes()))));
BOOST_CHECK_EQUAL(toHex(logData(0)), toHex(encodeArgs(10, 0x60, 15, 4, asString(FixedHash<4>(util::keccak256("deposit()")).asBytes()))));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(uint256,bytes,uint256)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(uint256,bytes,uint256)")));
}
BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage)
@@ -2843,7 +2841,7 @@ BOOST_AUTO_TEST_CASE(event_really_lots_of_data_from_storage)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK_EQUAL(toHex(logData(0)), toHex(encodeArgs(10, 0x60, 15, 3, string("ABC"))));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(uint256,bytes,uint256)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(uint256,bytes,uint256)")));
}
BOOST_AUTO_TEST_CASE(event_really_really_lots_of_data_from_storage)
@@ -2868,7 +2866,7 @@ BOOST_AUTO_TEST_CASE(event_really_really_lots_of_data_from_storage)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs(10, 0x60, 15, 31, string("ABC") + string(27, 0) + "Z"));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(uint256,bytes,uint256)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(uint256,bytes,uint256)")));
}
BOOST_AUTO_TEST_CASE(event_struct_memory_v2)
@@ -2890,7 +2888,7 @@ BOOST_AUTO_TEST_CASE(event_struct_memory_v2)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs(x));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint256))")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint256))")));
}
BOOST_AUTO_TEST_CASE(event_struct_storage_v2)
@@ -2914,7 +2912,7 @@ BOOST_AUTO_TEST_CASE(event_struct_storage_v2)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs(x));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint256))")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint256))")));
}
BOOST_AUTO_TEST_CASE(event_dynamic_array_memory)
@@ -2938,7 +2936,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_memory)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs(0x20, 3, x, x + 1, x + 2));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[])")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[])")));
}
BOOST_AUTO_TEST_CASE(event_dynamic_array_memory_v2)
@@ -2963,7 +2961,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_memory_v2)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs(0x20, 3, x, x + 1, x + 2));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[])")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[])")));
}
BOOST_AUTO_TEST_CASE(event_dynamic_nested_array_memory_v2)
@@ -2991,7 +2989,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_nested_array_memory_v2)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs(0x20, 2, 0x40, 0xa0, 2, x, x + 1, 2, x + 2, x + 3));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[][])")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[][])")));
}
BOOST_AUTO_TEST_CASE(event_dynamic_array_storage)
@@ -3018,7 +3016,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_storage)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs(0x20, 3, x, x + 1, x + 2));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[])")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[])")));
)
}
@@ -3047,7 +3045,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_array_storage_v2)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs(0x20, 3, x, x + 1, x + 2));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[])")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[])")));
)
}
@@ -3078,7 +3076,7 @@ BOOST_AUTO_TEST_CASE(event_dynamic_nested_array_storage_v2)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs(0x20, 2, 0x40, 0xa0, 2, x, x + 1, 2, x + 2, x + 3));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(uint256[][])")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(uint256[][])")));
}
BOOST_AUTO_TEST_CASE(event_indexed_string)
@@ -3110,11 +3108,11 @@ BOOST_AUTO_TEST_CASE(event_indexed_string)
dynx[i] = i;
BOOST_CHECK(logData(0) == bytes());
BOOST_REQUIRE_EQUAL(numLogTopics(0), 3);
BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(dynx));
BOOST_CHECK_EQUAL(logTopic(0, 2), dev::keccak256(
BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(dynx));
BOOST_CHECK_EQUAL(logTopic(0, 2), util::keccak256(
encodeArgs(u256(4), u256(5), u256(6), u256(7))
));
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(string,uint256[4])")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(string,uint256[4])")));
}
BOOST_AUTO_TEST_CASE(empty_name_input_parameter_with_named_one)
@@ -3204,7 +3202,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments)
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("foo(uint256,uint256,uint256)", 10, 12, 13), encodeArgs(
dev::keccak256(
util::keccak256(
toBigEndian(u256(10)) +
toBigEndian(u256(12)) +
toBigEndian(u256(13))
@@ -3225,7 +3223,7 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_numeric_literals)
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("foo(uint256,uint16)", 10, 12), encodeArgs(
dev::keccak256(
util::keccak256(
toBigEndian(u256(10)) +
bytes{0x0, 0xc} +
bytes(1, 0x91)
@@ -3249,10 +3247,10 @@ BOOST_AUTO_TEST_CASE(keccak256_multiple_arguments_with_string_literals)
)";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("foo()"), encodeArgs(dev::keccak256("foo")));
ABI_CHECK(callContractFunction("foo()"), encodeArgs(util::keccak256("foo")));
ABI_CHECK(callContractFunction("bar(uint256,uint16)", 10, 12), encodeArgs(
dev::keccak256(
util::keccak256(
toBigEndian(u256(10)) +
bytes{0x0, 0xc} +
bytes(1, 0x91) +
@@ -3295,7 +3293,7 @@ BOOST_AUTO_TEST_CASE(iterated_keccak256_with_bytes)
)ABC";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("foo()"), encodeArgs(
u256(dev::keccak256(bytes{'b'} + dev::keccak256("xyz").asBytes() + bytes{'a'}))
u256(util::keccak256(bytes{'b'} + util::keccak256("xyz").asBytes() + bytes{'a'}))
));
}
@@ -3373,7 +3371,7 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall)
BOOST_AUTO_TEST_CASE(generic_staticcall)
{
if (dev::test::Options::get().evmVersion().hasStaticCall())
if (solidity::test::Options::get().evmVersion().hasStaticCall())
{
char const* sourceCode = R"**(
contract A {
@@ -3518,10 +3516,10 @@ BOOST_AUTO_TEST_CASE(bytes_from_calldata_to_memory)
}
)";
compileAndRun(sourceCode);
bytes calldata1 = FixedHash<4>(dev::keccak256("f()")).asBytes() + bytes(61, 0x22) + bytes(12, 0x12);
bytes calldata1 = FixedHash<4>(util::keccak256("f()")).asBytes() + bytes(61, 0x22) + bytes(12, 0x12);
sendMessage(calldata1, false);
BOOST_CHECK(m_transactionSuccessful);
BOOST_CHECK(m_output == encodeArgs(dev::keccak256(bytes{'a', 'b', 'c'} + calldata1)));
BOOST_CHECK(m_output == encodeArgs(util::keccak256(bytes{'a', 'b', 'c'} + calldata1)));
}
BOOST_AUTO_TEST_CASE(call_forward_bytes)
@@ -3914,7 +3912,7 @@ BOOST_AUTO_TEST_CASE(storing_invalid_boolean)
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_CHECK(logData(0) == encodeArgs(1));
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Ev(bool)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Ev(bool)")));
}
@@ -4185,8 +4183,8 @@ BOOST_AUTO_TEST_CASE(bytes_in_arguments)
)";
compileAndRun(sourceCode);
string innercalldata1 = asString(FixedHash<4>(dev::keccak256("f(uint256,uint256)")).asBytes() + encodeArgs(8, 9));
string innercalldata2 = asString(FixedHash<4>(dev::keccak256("g(uint256)")).asBytes() + encodeArgs(3));
string innercalldata1 = asString(FixedHash<4>(util::keccak256("f(uint256,uint256)")).asBytes() + encodeArgs(8, 9));
string innercalldata2 = asString(FixedHash<4>(util::keccak256("g(uint256)")).asBytes() + encodeArgs(3));
bytes calldata = encodeArgs(
12, 32 * 4, u256(32 * 4 + 32 + (innercalldata1.length() + 31) / 32 * 32), 13,
u256(innercalldata1.length()), innercalldata1,
@@ -5477,7 +5475,7 @@ BOOST_AUTO_TEST_CASE(assignment_to_const_var_involving_keccak)
}
)";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("f()"), encodeArgs(dev::keccak256("abc")));
ABI_CHECK(callContractFunction("f()"), encodeArgs(util::keccak256("abc")));
}
// Disabled until https://github.com/ethereum/solidity/issues/715 is implemented
@@ -5759,7 +5757,7 @@ BOOST_AUTO_TEST_CASE(bool_conversion)
}
)";
compileAndRun(sourceCode, 0, "C");
bool v2 = dev::test::Options::get().useABIEncoderV2;
bool v2 = solidity::test::Options::get().useABIEncoderV2;
ABI_CHECK(callContractFunction("f(bool)", 0), encodeArgs(0));
ABI_CHECK(callContractFunction("f(bool)", 1), encodeArgs(1));
ABI_CHECK(callContractFunction("f(bool)", 2), v2 ? encodeArgs() : encodeArgs(1));
@@ -5874,7 +5872,7 @@ BOOST_AUTO_TEST_CASE(invalid_enum_logged)
BOOST_REQUIRE_EQUAL(numLogs(), 1);
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_REQUIRE_EQUAL(numLogTopics(0), 1);
BOOST_REQUIRE_EQUAL(logTopic(0, 0), dev::keccak256(string("Log(uint8)")));
BOOST_REQUIRE_EQUAL(logTopic(0, 0), util::keccak256(string("Log(uint8)")));
BOOST_CHECK_EQUAL(h256(logData(0)), h256(u256(0)));
// should throw
@@ -6205,7 +6203,7 @@ BOOST_AUTO_TEST_CASE(reusing_memory)
}
)";
compileAndRun(sourceCode, 0, "Main");
BOOST_REQUIRE(callContractFunction("f(uint256)", 0x34) == encodeArgs(dev::keccak256(dev::toBigEndian(u256(0x34)))));
BOOST_REQUIRE(callContractFunction("f(uint256)", 0x34) == encodeArgs(util::keccak256(util::toBigEndian(u256(0x34)))));
}
BOOST_AUTO_TEST_CASE(return_string)
@@ -7235,8 +7233,8 @@ BOOST_AUTO_TEST_CASE(calldata_struct_function_type)
)";
compileAndRun(sourceCode, 0, "C");
bytes fn_C_g = m_contractAddress.asBytes() + FixedHash<4>(dev::keccak256("g(uint256)")).asBytes() + bytes(8,0);
bytes fn_C_h = m_contractAddress.asBytes() + FixedHash<4>(dev::keccak256("h(uint256)")).asBytes() + bytes(8,0);
bytes fn_C_g = m_contractAddress.asBytes() + FixedHash<4>(util::keccak256("g(uint256)")).asBytes() + bytes(8,0);
bytes fn_C_h = m_contractAddress.asBytes() + FixedHash<4>(util::keccak256("h(uint256)")).asBytes() + bytes(8,0);
ABI_CHECK(callContractFunctionNoEncoding("f((function))", fn_C_g), encodeArgs(42 * 3));
ABI_CHECK(callContractFunctionNoEncoding("f((function))", fn_C_h), encodeArgs(23));
}
@@ -10020,7 +10018,7 @@ BOOST_AUTO_TEST_CASE(cleanup_bytes_types)
)";
compileAndRun(sourceCode, 0, "C");
// We input longer data on purpose.
bool v2 = dev::test::Options::get().useABIEncoderV2;
bool v2 = solidity::test::Options::get().useABIEncoderV2;
ABI_CHECK(callContractFunction("f(bytes2,uint16)", string("abc"), u256(0x040102)), v2 ? encodeArgs() : encodeArgs(0));
}
BOOST_AUTO_TEST_CASE(cleanup_bytes_types_shortening)
@@ -10057,7 +10055,7 @@ BOOST_AUTO_TEST_CASE(cleanup_address_types)
)";
compileAndRun(sourceCode, 0, "C");
bool v2 = dev::test::Options::get().useABIEncoderV2;
bool v2 = solidity::test::Options::get().useABIEncoderV2;
// We input longer data on purpose.
ABI_CHECK(callContractFunction("f(address)", u256("0xFFFF1234567890123456789012345678901234567890")), v2 ? encodeArgs() : encodeArgs(0));
ABI_CHECK(callContractFunction("g(address)", u256("0xFFFF1234567890123456789012345678901234567890")), v2 ? encodeArgs() : encodeArgs(0));
@@ -10665,7 +10663,7 @@ BOOST_AUTO_TEST_CASE(receive_external_function_type)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction(
"f(function)",
m_contractAddress.asBytes() + FixedHash<4>(dev::keccak256("g()")).asBytes() + bytes(32 - 4 - 20, 0)
m_contractAddress.asBytes() + FixedHash<4>(util::keccak256("g()")).asBytes() + bytes(32 - 4 - 20, 0)
), encodeArgs(u256(7)));
}
@@ -10683,7 +10681,7 @@ BOOST_AUTO_TEST_CASE(return_external_function_type)
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(
callContractFunction("f()"),
m_contractAddress.asBytes() + FixedHash<4>(dev::keccak256("g()")).asBytes() + bytes(32 - 4 - 20, 0)
m_contractAddress.asBytes() + FixedHash<4>(util::keccak256("g()")).asBytes() + bytes(32 - 4 - 20, 0)
);
}
@@ -11310,7 +11308,7 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled)
}
)";
compileAndRun(sourceCode, 0, "C");
bool v2 = dev::test::Options::get().useABIEncoderV2;
bool v2 = solidity::test::Options::get().useABIEncoderV2;
ABI_CHECK(callContractFunction("f(uint8,uint8)", u256(0x0), u256(4)), encodeArgs(u256(0xf)));
ABI_CHECK(callContractFunction("f(uint8,uint8)", u256(0x0), u256(0x1004)), v2 ? encodeArgs() : encodeArgs(u256(0xf)));
}
@@ -11336,7 +11334,7 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled_signed)
}
)";
compileAndRun(sourceCode, 0, "C");
bool v2 = dev::test::Options::get().useABIEncoderV2;
bool v2 = solidity::test::Options::get().useABIEncoderV2;
ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(3)), encodeArgs(u256(-2)));
ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(4)), encodeArgs(u256(-1)));
ABI_CHECK(callContractFunction("f(int8,uint8)", u256(0x0), u256(0xFF)), encodeArgs(u256(-1)));
@@ -11530,7 +11528,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int8)
}
)";
compileAndRun(sourceCode, 0, "C");
bool v2 = dev::test::Options::get().useABIEncoderV2;
bool v2 = solidity::test::Options::get().useABIEncoderV2;
ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(0)), v2 ? encodeArgs() : encodeArgs(u256(-103)));
ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(1)), v2 ? encodeArgs() : encodeArgs(u256(-52)));
ABI_CHECK(callContractFunction("f(int8,int8)", u256(0x99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26)));
@@ -11548,7 +11546,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int16)
}
)";
compileAndRun(sourceCode, 0, "C");
bool v2 = dev::test::Options::get().useABIEncoderV2;
bool v2 = solidity::test::Options::get().useABIEncoderV2;
ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(0)), v2 ? encodeArgs() : encodeArgs(u256(-103)));
ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(1)), v2 ? encodeArgs() : encodeArgs(u256(-52)));
ABI_CHECK(callContractFunction("f(int16,int16)", u256(0xFF99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26)));
@@ -11566,7 +11564,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int32)
}
)";
compileAndRun(sourceCode, 0, "C");
bool v2 = dev::test::Options::get().useABIEncoderV2;
bool v2 = solidity::test::Options::get().useABIEncoderV2;
ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(0)), v2 ? encodeArgs() : encodeArgs(u256(-103)));
ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(1)), v2 ? encodeArgs() : encodeArgs(u256(-52)));
ABI_CHECK(callContractFunction("f(int32,int32)", u256(0xFFFFFF99u), u256(2)), v2 ? encodeArgs() : encodeArgs(u256(-26)));
@@ -12094,7 +12092,7 @@ BOOST_AUTO_TEST_CASE(revert_with_cause)
}
}
)";
if (dev::test::Options::get().evmVersion().supportsReturndata())
if (solidity::test::Options::get().evmVersion().supportsReturndata())
{
compileAndRun(sourceCode, 0, "C");
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0};
@@ -12168,7 +12166,7 @@ BOOST_AUTO_TEST_CASE(require_with_message)
}
}
)";
if (dev::test::Options::get().evmVersion().supportsReturndata())
if (solidity::test::Options::get().evmVersion().supportsReturndata())
{
compileAndRun(sourceCode, 0, "C");
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0};
@@ -12214,7 +12212,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages)
}
}
)";
if (dev::test::Options::get().evmVersion().supportsReturndata())
if (solidity::test::Options::get().evmVersion().supportsReturndata())
{
compileAndRun(sourceCode, 0, "C");
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0};
@@ -12252,7 +12250,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_transfer)
}
}
)";
if (dev::test::Options::get().evmVersion().supportsReturndata())
if (solidity::test::Options::get().evmVersion().supportsReturndata())
{
compileAndRun(sourceCode, 0, "C");
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0};
@@ -12291,7 +12289,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_create)
}
}
)";
if (dev::test::Options::get().evmVersion().supportsReturndata())
if (solidity::test::Options::get().evmVersion().supportsReturndata())
{
compileAndRun(sourceCode, 0, "C");
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0};
@@ -12496,7 +12494,7 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address)
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1)));
ABI_CHECK(callContractFunction("h()"), encodeArgs(u256(1)));
if (dev::test::Options::get().evmVersion().hasStaticCall())
if (solidity::test::Options::get().evmVersion().hasStaticCall())
{
char const* sourceCode = R"YY(
contract C {
@@ -12512,10 +12510,10 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address)
BOOST_AUTO_TEST_CASE(bare_call_return_data)
{
if (dev::test::Options::get().evmVersion().supportsReturndata())
if (solidity::test::Options::get().evmVersion().supportsReturndata())
{
vector<string> calltypes = {"call", "delegatecall"};
if (dev::test::Options::get().evmVersion().hasStaticCall())
if (solidity::test::Options::get().evmVersion().hasStaticCall())
calltypes.emplace_back("staticcall");
for (string const& calltype: calltypes)
{
@@ -12639,7 +12637,7 @@ BOOST_AUTO_TEST_CASE(bare_call_return_data)
BOOST_AUTO_TEST_CASE(delegatecall_return_value)
{
if (dev::test::Options::get().evmVersion().supportsReturndata())
if (solidity::test::Options::get().evmVersion().supportsReturndata())
{
char const* sourceCode = R"DELIMITER(
contract C {
@@ -12735,10 +12733,10 @@ BOOST_AUTO_TEST_CASE(function_types_sig)
}
)";
compileAndRun(sourceCode, 0, "C");
ABI_CHECK(callContractFunction("f()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("f()")).asBytes())));
ABI_CHECK(callContractFunction("g()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("f()")).asBytes())));
ABI_CHECK(callContractFunction("h()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("f()")).asBytes())));
ABI_CHECK(callContractFunction("i()"), encodeArgs(asString(FixedHash<4>(dev::keccak256("x()")).asBytes())));
ABI_CHECK(callContractFunction("f()"), encodeArgs(asString(FixedHash<4>(util::keccak256("f()")).asBytes())));
ABI_CHECK(callContractFunction("g()"), encodeArgs(asString(FixedHash<4>(util::keccak256("f()")).asBytes())));
ABI_CHECK(callContractFunction("h()"), encodeArgs(asString(FixedHash<4>(util::keccak256("f()")).asBytes())));
ABI_CHECK(callContractFunction("i()"), encodeArgs(asString(FixedHash<4>(util::keccak256("x()")).asBytes())));
}
BOOST_AUTO_TEST_CASE(constant_string)
@@ -13149,12 +13147,12 @@ BOOST_AUTO_TEST_CASE(abi_encodePackedV2_structs)
bytes structEnc = encodeArgs(int(0x12), u256(-7), int(2), int(3), u256(-7), u256(-8));
ABI_CHECK(callContractFunction("testStorage()"), encodeArgs());
BOOST_REQUIRE_EQUAL(numLogTopics(0), 2);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint8,int16,uint8[2],int16[]))")));
BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(asString(structEnc)));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint8,int16,uint8[2],int16[]))")));
BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(asString(structEnc)));
ABI_CHECK(callContractFunction("testMemory()"), encodeArgs());
BOOST_REQUIRE_EQUAL(numLogTopics(0), 2);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint8,int16,uint8[2],int16[]))")));
BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(asString(structEnc)));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint8,int16,uint8[2],int16[]))")));
BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(asString(structEnc)));
}
BOOST_AUTO_TEST_CASE(abi_encodePackedV2_nestedArray)
@@ -13182,8 +13180,8 @@ BOOST_AUTO_TEST_CASE(abi_encodePackedV2_nestedArray)
bytes structEnc = encodeArgs(1, 2, 3, 0, 0, 0, 0, 4);
ABI_CHECK(callContractFunction("testNestedArrays()"), encodeArgs());
BOOST_REQUIRE_EQUAL(numLogTopics(0), 2);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint8,int16)[2][][3])")));
BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(asString(structEnc)));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint8,int16)[2][][3])")));
BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(asString(structEnc)));
}
BOOST_AUTO_TEST_CASE(abi_encodePackedV2_arrayOfStrings)
@@ -13210,12 +13208,12 @@ BOOST_AUTO_TEST_CASE(abi_encodePackedV2_arrayOfStrings)
bytes arrayEncoding = encodeArgs("abc", "0123456789012345678901234567890123456789");
ABI_CHECK(callContractFunction("testStorage()"), encodeArgs());
BOOST_REQUIRE_EQUAL(numLogTopics(0), 2);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(string[])")));
BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(asString(arrayEncoding)));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(string[])")));
BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(asString(arrayEncoding)));
ABI_CHECK(callContractFunction("testMemory()"), encodeArgs());
BOOST_REQUIRE_EQUAL(numLogTopics(0), 2);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E(string[])")));
BOOST_CHECK_EQUAL(logTopic(0, 1), dev::keccak256(asString(arrayEncoding)));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E(string[])")));
BOOST_CHECK_EQUAL(logTopic(0, 1), util::keccak256(asString(arrayEncoding)));
}
BOOST_AUTO_TEST_CASE(event_signature_in_library)
@@ -13243,7 +13241,7 @@ BOOST_AUTO_TEST_CASE(event_signature_in_library)
)";
compileAndRun(sourceCode, 0, "C");
BOOST_REQUIRE_EQUAL(numLogTopics(0), 2);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("E((uint8,int16),(uint8,int16))")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("E((uint8,int16),(uint8,int16))")));
}
@@ -13440,7 +13438,7 @@ BOOST_AUTO_TEST_CASE(abi_encode_empty_string)
)";
compileAndRun(sourceCode, 0, "C");
if (!dev::test::Options::get().useABIEncoderV2)
if (!solidity::test::Options::get().useABIEncoderV2)
{
// ABI Encoder V2 has slightly different padding, tested below.
ABI_CHECK(callContractFunction("f()"), encodeArgs(
@@ -13564,7 +13562,7 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure)
compileAndRun(sourceCode, 0, "D");
// This should work (called via CALL)
ABI_CHECK(callContractFunction("f()"), encodeArgs(1));
if (dev::test::Options::get().evmVersion().hasStaticCall())
if (solidity::test::Options::get().evmVersion().hasStaticCall())
{
// These should throw (called via STATICCALL)
ABI_CHECK(callContractFunction("fview()"), encodeArgs());
@@ -13579,7 +13577,7 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure)
BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
{
if (!dev::test::Options::get().evmVersion().hasBitwiseShifting())
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting())
return;
char const* sourceCode = R"(
contract C {
@@ -13618,7 +13616,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
{
if (!dev::test::Options::get().evmVersion().hasBitwiseShifting())
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting())
return;
char const* sourceCode = R"(
contract C {
@@ -13685,7 +13683,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople_combined)
{
if (!dev::test::Options::get().evmVersion().hasBitwiseShifting())
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting())
return;
char const* sourceCode = R"(
contract C {
@@ -14324,7 +14322,7 @@ BOOST_AUTO_TEST_CASE(event_wrong_abi_name)
BOOST_REQUIRE_EQUAL(numLogs(), 1);
BOOST_CHECK_EQUAL(logAddress(0), m_contractAddress);
BOOST_REQUIRE_EQUAL(numLogTopics(0), 3);
BOOST_CHECK_EQUAL(logTopic(0, 0), dev::keccak256(string("Deposit(address,bytes32,uint256)")));
BOOST_CHECK_EQUAL(logTopic(0, 0), util::keccak256(string("Deposit(address,bytes32,uint256)")));
}
BOOST_AUTO_TEST_CASE(uninitialized_internal_storage_function)
@@ -14441,7 +14439,7 @@ BOOST_AUTO_TEST_CASE(try_catch_library_call)
}
}
)";
if (dev::test::Options::get().evmVersion().supportsReturndata())
if (solidity::test::Options::get().evmVersion().supportsReturndata())
{
compileAndRun(sourceCode, 0, "L", bytes());
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"L", m_contractAddress}});
@@ -14504,6 +14502,4 @@ BOOST_AUTO_TEST_CASE(strip_reason_strings)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
@@ -24,10 +24,10 @@
#include <boost/test/framework.hpp>
#include <test/libsolidity/SolidityExecutionFramework.h>
using namespace dev;
using namespace dev::test;
using namespace dev::solidity;
using namespace dev::solidity::test;
using namespace solidity;
using namespace solidity::test;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
using namespace std;
bytes SolidityExecutionFramework::compileContract(
@@ -39,7 +39,7 @@ bytes SolidityExecutionFramework::compileContract(
// Silence compiler version warning
std::string sourceCode = "pragma solidity >=0.0;\n";
if (
dev::test::Options::get().useABIEncoderV2 &&
solidity::test::Options::get().useABIEncoderV2 &&
_sourceCode.find("pragma experimental ABIEncoderV2;") == std::string::npos
)
sourceCode += "pragma experimental ABIEncoderV2;\n";
@@ -59,7 +59,7 @@ bytes SolidityExecutionFramework::compileContract(
formatter.printErrorInformation(*error);
BOOST_ERROR("Compiling contract failed");
}
eth::LinkerObject obj;
evmasm::LinkerObject obj;
if (m_compileViaYul)
{
yul::AssemblyStack asmStack(
+5 -12
View File
@@ -33,15 +33,10 @@
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatter.h>
namespace dev
{
namespace solidity
namespace solidity::frontend::test
{
namespace test
{
class SolidityExecutionFramework: public dev::test::ExecutionFramework
class SolidityExecutionFramework: public solidity::test::ExecutionFramework
{
public:
@@ -55,7 +50,7 @@ public:
u256 const& _value = 0,
std::string const& _contractName = "",
bytes const& _arguments = bytes(),
std::map<std::string, dev::test::Address> const& _libraryAddresses = std::map<std::string, dev::test::Address>()
std::map<std::string, solidity::test::Address> const& _libraryAddresses = std::map<std::string, solidity::test::Address>()
) override
{
bytes bytecode = compileContract(_sourceCode, _contractName, _libraryAddresses);
@@ -66,15 +61,13 @@ public:
bytes compileContract(
std::string const& _sourceCode,
std::string const& _contractName = "",
std::map<std::string, dev::test::Address> const& _libraryAddresses = std::map<std::string, dev::test::Address>()
std::map<std::string, solidity::test::Address> const& _libraryAddresses = std::map<std::string, solidity::test::Address>()
);
protected:
dev::solidity::CompilerStack m_compiler;
solidity::frontend::CompilerStack m_compiler;
bool m_compileViaYul = false;
};
}
}
} // end namespaces
+14 -20
View File
@@ -34,14 +34,10 @@
#include <test/Options.h>
using namespace std;
using namespace dev::eth;
using namespace langutil;
using namespace solidity::evmasm;
using namespace solidity::langutil;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
namespace
@@ -102,7 +98,7 @@ bytes compileFirstExpression(
{
ErrorList errors;
ErrorReporter errorReporter(errors);
sourceUnit = Parser(errorReporter, dev::test::Options::get().evmVersion()).parse(
sourceUnit = Parser(errorReporter, solidity::test::Options::get().evmVersion()).parse(
make_shared<Scanner>(CharStream(_sourceCode, ""))
);
if (!sourceUnit)
@@ -118,7 +114,7 @@ bytes compileFirstExpression(
ErrorReporter errorReporter(errors);
GlobalContext globalContext;
map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes;
NameAndTypeResolver resolver(globalContext, dev::test::Options::get().evmVersion(), scopes, errorReporter);
NameAndTypeResolver resolver(globalContext, solidity::test::Options::get().evmVersion(), scopes, errorReporter);
resolver.registerDeclarations(*sourceUnit);
vector<ContractDefinition const*> inheritanceHierarchy;
@@ -132,7 +128,7 @@ bytes compileFirstExpression(
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
ErrorReporter errorReporter(errors);
TypeChecker typeChecker(dev::test::Options::get().evmVersion(), errorReporter);
TypeChecker typeChecker(solidity::test::Options::get().evmVersion(), errorReporter);
BOOST_REQUIRE(typeChecker.checkTypeRequirements(*contract));
}
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
@@ -141,7 +137,7 @@ bytes compileFirstExpression(
FirstExpressionExtractor extractor(*contract);
BOOST_REQUIRE(extractor.expression() != nullptr);
CompilerContext context(dev::test::Options::get().evmVersion());
CompilerContext context(solidity::test::Options::get().evmVersion());
context.resetVisitedNodes(contract);
context.setInheritanceHierarchy(inheritanceHierarchy);
unsigned parametersSize = _localVariables.size(); // assume they are all one slot on the stack
@@ -155,7 +151,7 @@ bytes compileFirstExpression(
ExpressionCompiler(
context,
RevertStrings::Default,
dev::test::Options::get().optimize
solidity::test::Options::get().optimize
).compile(*extractor.expression());
for (vector<string> const& function: _functions)
@@ -164,7 +160,7 @@ bytes compileFirstExpression(
));
bytes instructions = context.assembledObject().bytecode;
// debug
// cout << eth::disassemble(instructions) << endl;
// cout << evmasm::disassemble(instructions) << endl;
return instructions;
}
BOOST_FAIL("No contract found in source.");
@@ -286,7 +282,7 @@ BOOST_AUTO_TEST_CASE(comparison)
bytes code = compileFirstExpression(sourceCode);
bytes expectation;
if (dev::test::Options::get().optimize)
if (solidity::test::Options::get().optimize)
expectation = {
uint8_t(Instruction::PUSH2), 0x11, 0xaa,
uint8_t(Instruction::PUSH2), 0x10, 0xaa,
@@ -349,7 +345,7 @@ BOOST_AUTO_TEST_CASE(arithmetic)
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}});
bytes expectation;
if (dev::test::Options::get().optimize)
if (solidity::test::Options::get().optimize)
expectation = {
uint8_t(Instruction::PUSH1), 0x2,
uint8_t(Instruction::PUSH1), 0x3,
@@ -430,7 +426,7 @@ BOOST_AUTO_TEST_CASE(unary_operators)
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}});
bytes expectation;
if (dev::test::Options::get().optimize)
if (solidity::test::Options::get().optimize)
expectation = {
uint8_t(Instruction::DUP1),
uint8_t(Instruction::PUSH1), 0x0,
@@ -521,7 +517,7 @@ BOOST_AUTO_TEST_CASE(assignment)
// Stack: a, b
bytes expectation;
if (dev::test::Options::get().optimize)
if (solidity::test::Options::get().optimize)
expectation = {
uint8_t(Instruction::DUP1),
uint8_t(Instruction::DUP3),
@@ -633,7 +629,7 @@ BOOST_AUTO_TEST_CASE(selfbalance)
bytes code = compileFirstExpression(sourceCode, {}, {});
if (dev::test::Options::get().evmVersion() == EVMVersion::istanbul())
if (solidity::test::Options::get().evmVersion() == EVMVersion::istanbul())
{
bytes expectation({uint8_t(Instruction::SELFBALANCE)});
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
@@ -642,6 +638,4 @@ BOOST_AUTO_TEST_CASE(selfbalance)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
@@ -26,20 +26,16 @@
#include <libsolidity/ast/AST.h>
#include <libdevcore/Keccak256.h>
#include <libsolutil/Keccak256.h>
#include <boost/test/unit_test.hpp>
#include <string>
using namespace std;
using namespace langutil;
using namespace solidity::langutil;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
BOOST_FIXTURE_TEST_SUITE(SolidityNameAndTypeResolution, AnalysisFramework)
@@ -365,7 +361,7 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible)
}
}
)";
if (dev::test::Options::get().evmVersion() == EVMVersion::homestead())
if (solidity::test::Options::get().evmVersion() == EVMVersion::homestead())
CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type string memory.");
else
CHECK_SUCCESS_NO_WARNINGS(sourceCode);
@@ -390,7 +386,7 @@ BOOST_AUTO_TEST_CASE(returndatasize_as_variable)
vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
});
if (!dev::test::Options::get().evmVersion().supportsReturndata())
if (!solidity::test::Options::get().evmVersion().supportsReturndata())
expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"returndatasize\" instruction is only available for Byzantium-compatible VMs")));
CHECK_ALLOW_MULTI(text, expectations);
}
@@ -405,7 +401,7 @@ BOOST_AUTO_TEST_CASE(create2_as_variable)
vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
});
if (!dev::test::Options::get().evmVersion().hasCreate2())
if (!solidity::test::Options::get().evmVersion().hasCreate2())
expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"create2\" instruction is only available for Constantinople-compatible VMs")));
CHECK_ALLOW_MULTI(text, expectations);
}
@@ -420,7 +416,7 @@ BOOST_AUTO_TEST_CASE(extcodehash_as_variable)
vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
});
if (!dev::test::Options::get().evmVersion().hasExtCodeHash())
if (!solidity::test::Options::get().evmVersion().hasExtCodeHash())
expectations.emplace_back(make_pair(Error::Type::TypeError, std::string("\"extcodehash\" instruction is only available for Constantinople-compatible VMs")));
CHECK_ALLOW_MULTI(text, expectations);
}
@@ -456,7 +452,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall)
}
)";
if (dev::test::Options::get().evmVersion().hasStaticCall())
if (solidity::test::Options::get().evmVersion().hasStaticCall())
CHECK_SUCCESS_NO_WARNINGS(sourceCode);
else
CHECK_ERROR(sourceCode, TypeError, "\"staticcall\" is not supported by the VM version.");
@@ -464,7 +460,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall)
BOOST_AUTO_TEST_CASE(address_staticcall_value)
{
if (dev::test::Options::get().evmVersion().hasStaticCall())
if (solidity::test::Options::get().evmVersion().hasStaticCall())
{
char const* sourceCode = R"(
contract C {
@@ -488,7 +484,7 @@ BOOST_AUTO_TEST_CASE(address_call_full_return_type)
}
)";
if (dev::test::Options::get().evmVersion().supportsReturndata())
if (solidity::test::Options::get().evmVersion().supportsReturndata())
CHECK_SUCCESS_NO_WARNINGS(sourceCode);
else
CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type bytes memory.");
@@ -505,7 +501,7 @@ BOOST_AUTO_TEST_CASE(address_delegatecall_full_return_type)
}
)";
if (dev::test::Options::get().evmVersion().supportsReturndata())
if (solidity::test::Options::get().evmVersion().supportsReturndata())
CHECK_SUCCESS_NO_WARNINGS(sourceCode);
else
CHECK_ERROR(sourceCode, TypeError, "Type inaccessible dynamic type is not implicitly convertible to expected type bytes memory.");
@@ -514,7 +510,7 @@ BOOST_AUTO_TEST_CASE(address_delegatecall_full_return_type)
BOOST_AUTO_TEST_CASE(address_staticcall_full_return_type)
{
if (dev::test::Options::get().evmVersion().hasStaticCall())
if (solidity::test::Options::get().evmVersion().hasStaticCall())
{
char const* sourceCode = R"(
contract C {
@@ -531,6 +527,4 @@ BOOST_AUTO_TEST_CASE(address_staticcall_full_return_type)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+7 -13
View File
@@ -22,18 +22,14 @@
#include <test/Options.h>
#include <string>
#include <libdevcore/JSON.h>
#include <libsolutil/JSON.h>
#include <libsolidity/interface/CompilerStack.h>
#include <liblangutil/Exceptions.h>
#include <libdevcore/Exceptions.h>
#include <libsolutil/Exceptions.h>
using namespace langutil;
using namespace solidity::langutil;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
class DocumentationChecker
@@ -48,7 +44,7 @@ public:
{
m_compilerStack.reset();
m_compilerStack.setSources({{"", "pragma solidity >=0.0;\n" + _code}});
m_compilerStack.setEVMVersion(dev::test::Options::get().evmVersion());
m_compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
BOOST_REQUIRE_MESSAGE(m_compilerStack.parseAndAnalyze(), "Parsing contract failed");
Json::Value generatedDocumentation;
@@ -57,7 +53,7 @@ public:
else
generatedDocumentation = m_compilerStack.natspecDev(_contractName);
Json::Value expectedDocumentation;
jsonParseStrict(_expectedDocumentationString, expectedDocumentation);
util::jsonParseStrict(_expectedDocumentationString, expectedDocumentation);
BOOST_CHECK_MESSAGE(
expectedDocumentation == generatedDocumentation,
"Expected:\n" << expectedDocumentation.toStyledString() <<
@@ -69,7 +65,7 @@ public:
{
m_compilerStack.reset();
m_compilerStack.setSources({{"", "pragma solidity >=0.0;\n" + _code}});
m_compilerStack.setEVMVersion(dev::test::Options::get().evmVersion());
m_compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
BOOST_CHECK(!m_compilerStack.parseAndAnalyze());
BOOST_REQUIRE(Error::containsErrorOfType(m_compilerStack.errors(), Error::Type::DocstringParsingError));
}
@@ -979,5 +975,3 @@ BOOST_AUTO_TEST_CASE(dev_constructor_and_function)
BOOST_AUTO_TEST_SUITE_END()
}
}
}
+5 -10
View File
@@ -33,14 +33,11 @@
#include <memory>
using namespace std;
using namespace dev::eth;
using namespace dev::test;
using namespace solidity::util;
using namespace solidity::evmasm;
using namespace solidity::test;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
class OptimizerTestFramework: public SolidityExecutionFramework
@@ -109,7 +106,7 @@ public:
bytes realCode = bytecodeSansMetadata(_bytecode);
BOOST_REQUIRE_MESSAGE(!realCode.empty(), "Invalid or missing metadata in bytecode.");
size_t instructions = 0;
dev::eth::eachInstruction(realCode, [&](Instruction _instr, u256 const&) {
evmasm::eachInstruction(realCode, [&](Instruction _instr, u256 const&) {
if (!_which || *_which == _instr)
instructions++;
});
@@ -714,6 +711,4 @@ BOOST_AUTO_TEST_CASE(shift_optimizer_bug)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+3 -9
View File
@@ -30,13 +30,9 @@
#include <libsolidity/ast/ASTVisitor.h>
using namespace std;
using namespace langutil;
using namespace solidity::langutil;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
namespace
@@ -46,7 +42,7 @@ ASTPointer<ContractDefinition> parseText(std::string const& _source, ErrorList&
ErrorReporter errorReporter(_errors);
ASTPointer<SourceUnit> sourceUnit = Parser(
errorReporter,
dev::test::Options::get().evmVersion(),
solidity::test::Options::get().evmVersion(),
errorRecovery
).parse(std::make_shared<Scanner>(CharStream(_source, "")));
if (!sourceUnit)
@@ -694,6 +690,4 @@ BOOST_AUTO_TEST_CASE(inline_asm_end_location)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+2 -8
View File
@@ -24,13 +24,9 @@
#include <boost/test/unit_test.hpp>
using namespace std;
using namespace langutil;
using namespace solidity::langutil;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
BOOST_AUTO_TEST_SUITE(SolidityScanner)
@@ -666,6 +662,4 @@ BOOST_AUTO_TEST_CASE(irregular_line_breaks_in_strings)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+4 -10
View File
@@ -23,17 +23,13 @@
#include <libsolidity/ast/Types.h>
#include <libsolidity/ast/TypeProvider.h>
#include <libsolidity/ast/AST.h>
#include <libdevcore/Keccak256.h>
#include <libsolutil/Keccak256.h>
#include <boost/test/unit_test.hpp>
using namespace std;
using namespace langutil;
using namespace solidity::langutil;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
BOOST_AUTO_TEST_SUITE(SolidityTypes)
@@ -274,7 +270,7 @@ BOOST_AUTO_TEST_CASE(helper_bool_result)
BOOST_AUTO_TEST_CASE(helper_string_result)
{
using StringResult = Result<string>;
using StringResult = util::Result<string>;
StringResult r1{string{"Success"}};
StringResult r2 = StringResult::err("Failure");
@@ -291,5 +287,3 @@ BOOST_AUTO_TEST_CASE(helper_string_result)
BOOST_AUTO_TEST_SUITE_END()
}
}
}
+37 -43
View File
@@ -23,17 +23,13 @@
#include <boost/test/unit_test.hpp>
#include <libsolidity/interface/StandardCompiler.h>
#include <libsolidity/interface/Version.h>
#include <libdevcore/JSON.h>
#include <libsolutil/JSON.h>
#include <test/Metadata.h>
using namespace std;
using namespace dev::eth;
using namespace solidity::evmasm;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
namespace
@@ -89,7 +85,7 @@ Json::Value compile(string _input)
StandardCompiler compiler;
string output = compiler.compile(std::move(_input));
Json::Value ret;
BOOST_REQUIRE(jsonParseStrict(output, ret));
BOOST_REQUIRE(util::jsonParseStrict(output, ret));
return ret;
}
@@ -102,7 +98,7 @@ BOOST_AUTO_TEST_CASE(assume_object_input)
Json::Value result;
/// Use the native JSON interface of StandardCompiler to trigger these
solidity::StandardCompiler compiler;
frontend::StandardCompiler compiler;
result = compiler.compile(Json::Value());
BOOST_CHECK(containsError(result, "JSONError", "Input is not a JSON object."));
result = compiler.compile(Json::Value("INVALID"));
@@ -352,19 +348,19 @@ BOOST_AUTO_TEST_CASE(basic_compilation)
Json::Value contract = getContractResult(result, "fileA", "A");
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["abi"].isArray());
BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]");
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]");
BOOST_CHECK(contract["devdoc"].isObject());
BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["devdoc"]), "{\"methods\":{}}");
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["devdoc"]), "{\"methods\":{}}");
BOOST_CHECK(contract["userdoc"].isObject());
BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["userdoc"]), "{\"methods\":{}}");
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["userdoc"]), "{\"methods\":{}}");
BOOST_CHECK(contract["evm"].isObject());
/// @TODO check evm.methodIdentifiers, legacyAssembly, bytecode, deployedBytecode
BOOST_CHECK(contract["evm"]["bytecode"].isObject());
BOOST_CHECK(contract["evm"]["bytecode"]["object"].isString());
BOOST_CHECK_EQUAL(
dev::test::bytecodeSansMetadata(contract["evm"]["bytecode"]["object"].asString()),
solidity::test::bytecodeSansMetadata(contract["evm"]["bytecode"]["object"].asString()),
string("6080604052348015600f57600080fd5b5060") +
(VersionIsRelease ? "3f" : toHex(bytes{uint8_t(61 + VersionStringStrict.size())})) +
(VersionIsRelease ? "3f" : util::toHex(bytes{uint8_t(61 + VersionStringStrict.size())})) +
"80601d6000396000f3fe6080604052600080fdfe"
);
BOOST_CHECK(contract["evm"]["assembly"].isString());
@@ -396,7 +392,7 @@ BOOST_AUTO_TEST_CASE(basic_compilation)
BOOST_CHECK(contract["evm"]["legacyAssembly"].isObject());
BOOST_CHECK(contract["evm"]["legacyAssembly"][".code"].isArray());
BOOST_CHECK_EQUAL(
dev::jsonCompactPrint(contract["evm"]["legacyAssembly"][".code"]),
util::jsonCompactPrint(contract["evm"]["legacyAssembly"][".code"]),
"[{\"begin\":0,\"end\":14,\"name\":\"PUSH\",\"value\":\"80\"},"
"{\"begin\":0,\"end\":14,\"name\":\"PUSH\",\"value\":\"40\"},"
"{\"begin\":0,\"end\":14,\"name\":\"MSTORE\"},"
@@ -420,12 +416,12 @@ BOOST_AUTO_TEST_CASE(basic_compilation)
"{\"begin\":0,\"end\":14,\"name\":\"RETURN\"}]"
);
BOOST_CHECK(contract["metadata"].isString());
BOOST_CHECK(dev::test::isValidMetadata(contract["metadata"].asString()));
BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].asString()));
BOOST_CHECK(result["sources"].isObject());
BOOST_CHECK(result["sources"]["fileA"].isObject());
BOOST_CHECK(result["sources"]["fileA"]["legacyAST"].isObject());
BOOST_CHECK_EQUAL(
dev::jsonCompactPrint(result["sources"]["fileA"]["legacyAST"]),
util::jsonCompactPrint(result["sources"]["fileA"]["legacyAST"]),
"{\"attributes\":{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]}},\"children\":"
"[{\"attributes\":{\"abstract\":false,\"baseContracts\":[null],\"contractDependencies\":[null],\"contractKind\":\"contract\","
"\"documentation\":null,\"fullyImplemented\":true,\"linearizedBaseContracts\":[1],\"name\":\"A\",\"nodes\":[null],\"scope\":2},"
@@ -464,7 +460,7 @@ BOOST_AUTO_TEST_CASE(compilation_error)
if (error["message"].asString().find("pre-release compiler") == string::npos)
{
BOOST_CHECK_EQUAL(
dev::jsonCompactPrint(error),
util::jsonCompactPrint(error),
"{\"component\":\"general\",\"formattedMessage\":\"fileA:1:23: ParserError: Expected identifier but got '}'\\n"
"contract A { function }\\n ^\\n\",\"message\":\"Expected identifier but got '}'\","
"\"severity\":\"error\",\"sourceLocation\":{\"end\":23,\"file\":\"fileA\",\"start\":22},\"type\":\"ParserError\"}"
@@ -499,7 +495,7 @@ BOOST_AUTO_TEST_CASE(output_selection_explicit)
Json::Value contract = getContractResult(result, "fileA", "A");
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["abi"].isArray());
BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]");
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]");
}
BOOST_AUTO_TEST_CASE(output_selection_all_contracts)
@@ -528,7 +524,7 @@ BOOST_AUTO_TEST_CASE(output_selection_all_contracts)
Json::Value contract = getContractResult(result, "fileA", "A");
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["abi"].isArray());
BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]");
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]");
}
BOOST_AUTO_TEST_CASE(output_selection_all_files_single_contract)
@@ -557,7 +553,7 @@ BOOST_AUTO_TEST_CASE(output_selection_all_files_single_contract)
Json::Value contract = getContractResult(result, "fileA", "A");
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["abi"].isArray());
BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]");
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]");
}
BOOST_AUTO_TEST_CASE(output_selection_all_files_all_contracts)
@@ -586,7 +582,7 @@ BOOST_AUTO_TEST_CASE(output_selection_all_files_all_contracts)
Json::Value contract = getContractResult(result, "fileA", "A");
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["abi"].isArray());
BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]");
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]");
}
BOOST_AUTO_TEST_CASE(output_selection_dependent_contract)
@@ -615,7 +611,7 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract)
Json::Value contract = getContractResult(result, "fileA", "A");
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["abi"].isArray());
BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[{\"inputs\":[],\"name\":\"f\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]");
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[{\"inputs\":[],\"name\":\"f\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]");
}
BOOST_AUTO_TEST_CASE(output_selection_dependent_contract_with_import)
@@ -647,7 +643,7 @@ BOOST_AUTO_TEST_CASE(output_selection_dependent_contract_with_import)
Json::Value contract = getContractResult(result, "fileA", "A");
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["abi"].isArray());
BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[{\"inputs\":[],\"name\":\"f\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]");
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[{\"inputs\":[],\"name\":\"f\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]");
}
BOOST_AUTO_TEST_CASE(filename_with_colon)
@@ -676,7 +672,7 @@ BOOST_AUTO_TEST_CASE(filename_with_colon)
Json::Value contract = getContractResult(result, "http://github.com/ethereum/solidity/std/StandardToken.sol", "A");
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["abi"].isArray());
BOOST_CHECK_EQUAL(dev::jsonCompactPrint(contract["abi"]), "[]");
BOOST_CHECK_EQUAL(util::jsonCompactPrint(contract["abi"]), "[]");
}
BOOST_AUTO_TEST_CASE(library_filename_with_colon)
@@ -933,7 +929,7 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_default_disabled)
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["metadata"].isString());
Json::Value metadata;
BOOST_CHECK(jsonParseStrict(contract["metadata"].asString(), metadata));
BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata));
Json::Value const& optimizer = metadata["settings"]["optimizer"];
BOOST_CHECK(optimizer.isMember("enabled"));
@@ -966,7 +962,7 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_default_enabled)
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["metadata"].isString());
Json::Value metadata;
BOOST_CHECK(jsonParseStrict(contract["metadata"].asString(), metadata));
BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata));
Json::Value const& optimizer = metadata["settings"]["optimizer"];
BOOST_CHECK(optimizer.isMember("enabled"));
@@ -1006,7 +1002,7 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_details_exactly_as_default_disabled)
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["metadata"].isString());
Json::Value metadata;
BOOST_CHECK(jsonParseStrict(contract["metadata"].asString(), metadata));
BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata));
Json::Value const& optimizer = metadata["settings"]["optimizer"];
BOOST_CHECK(optimizer.isMember("enabled"));
@@ -1048,7 +1044,7 @@ BOOST_AUTO_TEST_CASE(optimizer_settings_details_different)
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["metadata"].isString());
Json::Value metadata;
BOOST_CHECK(jsonParseStrict(contract["metadata"].asString(), metadata));
BOOST_CHECK(util::jsonParseStrict(contract["metadata"].asString(), metadata));
Json::Value const& optimizer = metadata["settings"]["optimizer"];
BOOST_CHECK(!optimizer.isMember("enabled"));
@@ -1097,7 +1093,7 @@ BOOST_AUTO_TEST_CASE(metadata_without_compilation)
Json::Value contract = getContractResult(result, "fileA", "A");
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["metadata"].isString());
BOOST_CHECK(dev::test::isValidMetadata(contract["metadata"].asString()));
BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].asString()));
}
BOOST_AUTO_TEST_CASE(common_pattern)
@@ -1124,7 +1120,7 @@ BOOST_AUTO_TEST_CASE(common_pattern)
Json::Value contract = getContractResult(result, "fileA", "A");
BOOST_CHECK(contract.isObject());
BOOST_CHECK(contract["metadata"].isString());
BOOST_CHECK(dev::test::isValidMetadata(contract["metadata"].asString()));
BOOST_CHECK(solidity::test::isValidMetadata(contract["metadata"].asString()));
BOOST_CHECK(contract["evm"]["bytecode"].isObject());
BOOST_CHECK(contract["evm"]["bytecode"]["object"].isString());
}
@@ -1178,9 +1174,9 @@ BOOST_AUTO_TEST_CASE(use_stack_optimization)
)";
Json::Value parsedInput;
BOOST_REQUIRE(jsonParseStrict(input, parsedInput));
BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput));
dev::solidity::StandardCompiler compiler;
solidity::frontend::StandardCompiler compiler;
Json::Value result = compiler.compile(parsedInput);
BOOST_CHECK(containsAtMostWarnings(result));
@@ -1223,9 +1219,9 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard)
)";
Json::Value parsedInput;
BOOST_REQUIRE(jsonParseStrict(input, parsedInput));
BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput));
dev::solidity::StandardCompiler compiler;
solidity::frontend::StandardCompiler compiler;
Json::Value result = compiler.compile(parsedInput);
BOOST_REQUIRE(result["contracts"].isObject());
@@ -1264,9 +1260,9 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_colon_source)
)";
Json::Value parsedInput;
BOOST_REQUIRE(jsonParseStrict(input, parsedInput));
BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput));
dev::solidity::StandardCompiler compiler;
solidity::frontend::StandardCompiler compiler;
Json::Value result = compiler.compile(parsedInput);
BOOST_REQUIRE(result["contracts"].isObject());
@@ -1304,9 +1300,9 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_empty_source)
)";
Json::Value parsedInput;
BOOST_REQUIRE(jsonParseStrict(input, parsedInput));
BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput));
dev::solidity::StandardCompiler compiler;
solidity::frontend::StandardCompiler compiler;
Json::Value result = compiler.compile(parsedInput);
BOOST_REQUIRE(result["contracts"].isObject());
@@ -1348,9 +1344,9 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_multiple_sources)
)";
Json::Value parsedInput;
BOOST_REQUIRE(jsonParseStrict(input, parsedInput));
BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput));
dev::solidity::StandardCompiler compiler;
solidity::frontend::StandardCompiler compiler;
Json::Value result = compiler.compile(parsedInput);
BOOST_REQUIRE(result["contracts"].isObject());
@@ -1368,6 +1364,4 @@ BOOST_AUTO_TEST_CASE(standard_output_selection_wildcard_multiple_sources)
BOOST_AUTO_TEST_SUITE_END()
}
}
} // end namespaces
+7 -6
View File
@@ -24,14 +24,15 @@
#include <memory>
#include <stdexcept>
using namespace langutil;
using namespace dev::solidity;
using namespace dev::solidity::test;
using namespace dev::formatting;
using namespace dev;
using namespace std;
namespace fs = boost::filesystem;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::util::formatting;
using namespace solidity::langutil;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
using namespace boost::unit_test;
namespace fs = boost::filesystem;
namespace
{
+3 -9
View File
@@ -20,18 +20,14 @@
#include <test/libsolidity/AnalysisFramework.h>
#include <test/TestCase.h>
#include <liblangutil/Exceptions.h>
#include <libdevcore/AnsiColorized.h>
#include <libsolutil/AnsiColorized.h>
#include <iosfwd>
#include <string>
#include <vector>
#include <utility>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
struct SyntaxTestError
@@ -74,7 +70,7 @@ public:
printErrorList(_stream, m_errorList, _linePrefix, false);
}
static std::string errorMessage(Exception const& _e);
static std::string errorMessage(util::Exception const& _e);
protected:
void setupCompiler();
void parseAndAnalyze();
@@ -100,5 +96,3 @@ protected:
};
}
}
}
+5 -11
View File
@@ -28,13 +28,9 @@
#include <tuple>
using namespace std;
using namespace langutil;
using namespace solidity::langutil;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
BOOST_FIXTURE_TEST_SUITE(ViewPureChecker, AnalysisFramework)
@@ -56,7 +52,7 @@ BOOST_AUTO_TEST_CASE(environment_access)
"this",
"address(1).balance",
};
if (dev::test::Options::get().evmVersion().hasStaticCall())
if (solidity::test::Options::get().evmVersion().hasStaticCall())
view.emplace_back("address(0x4242).staticcall(\"\")");
// ``block.blockhash`` and ``blockhash`` are tested separately below because their usage will
@@ -109,7 +105,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall)
}
}
)";
if (!dev::test::Options::get().evmVersion().hasStaticCall())
if (!solidity::test::Options::get().evmVersion().hasStaticCall())
CHECK_ERROR(text, TypeError, "\"staticcall\" is not supported by the VM version.");
else
CHECK_SUCCESS_NO_WARNINGS(text);
@@ -125,7 +121,7 @@ BOOST_AUTO_TEST_CASE(assembly_staticcall)
}
}
)";
if (!dev::test::Options::get().evmVersion().hasStaticCall())
if (!solidity::test::Options::get().evmVersion().hasStaticCall())
CHECK_ERROR(text, TypeError, "\"staticcall\" instruction is only available for Byzantium-compatible");
else
CHECK_SUCCESS_NO_WARNINGS(text);
@@ -134,5 +130,3 @@ BOOST_AUTO_TEST_CASE(assembly_staticcall)
BOOST_AUTO_TEST_SUITE_END()
}
}
}
+8 -7
View File
@@ -22,7 +22,7 @@
#include <liblangutil/Common.h>
#include <libdevcore/StringUtils.h>
#include <libsolutil/StringUtils.h>
#include <boost/algorithm/string.hpp>
@@ -32,10 +32,11 @@
#include <regex>
#include <stdexcept>
using namespace dev;
using namespace langutil;
using namespace solidity;
using namespace dev::solidity::test;
using namespace solidity::util;
using namespace solidity::langutil;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
using namespace std;
using namespace soltest;
@@ -205,7 +206,7 @@ string BytesUtils::formatString(bytes const& _bytes, size_t _cutOff)
string BytesUtils::formatRawBytes(
bytes const& _bytes,
dev::solidity::test::ParameterList const& _parameters,
solidity::frontend::test::ParameterList const& _parameters,
string _linePrefix)
{
stringstream os;
@@ -275,7 +276,7 @@ string BytesUtils::formatBytes(
string BytesUtils::formatBytesRange(
bytes _bytes,
dev::solidity::test::ParameterList const& _parameters,
solidity::frontend::test::ParameterList const& _parameters,
bool _highlight
)
{
@@ -297,7 +298,7 @@ string BytesUtils::formatBytesRange(
AnsiColorized(
os,
_highlight,
{dev::formatting::RED_BACKGROUND}
{util::formatting::RED_BACKGROUND}
) << formatBytes(byteRange, parameter.abiType);
else
os << parameter.rawString;
+2 -8
View File
@@ -16,13 +16,9 @@
#include <test/libsolidity/util/SoltestTypes.h>
#include <libdevcore/CommonData.h>
#include <libsolutil/CommonData.h>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
/**
@@ -129,5 +125,3 @@ public:
};
}
}
}
+13 -13
View File
@@ -32,17 +32,17 @@
#include <regex>
#include <stdexcept>
using namespace dev;
using namespace langutil;
using namespace solidity;
using namespace dev::solidity::test;
using namespace solidity::util;
using namespace solidity::langutil;
using namespace solidity::frontend::test;
using namespace std;
using namespace soltest;
namespace
{
using ParameterList = dev::solidity::test::ParameterList;
using ParameterList = solidity::frontend::test::ParameterList;
size_t arraySize(string const& _arrayType)
{
@@ -141,7 +141,7 @@ string functionSignatureFromABI(Json::Value const& _functionABI)
}
std::optional<dev::solidity::test::ParameterList> ContractABIUtils::parametersFromJsonOutputs(
std::optional<solidity::frontend::test::ParameterList> ContractABIUtils::parametersFromJsonOutputs(
ErrorReporter& _errorReporter,
Json::Value const& _contractABI,
string const& _functionSignature
@@ -255,8 +255,8 @@ bool ContractABIUtils::appendTypesFromName(
void ContractABIUtils::overwriteParameters(
ErrorReporter& _errorReporter,
dev::solidity::test::ParameterList& _targetParameters,
dev::solidity::test::ParameterList const& _sourceParameters
solidity::frontend::test::ParameterList& _targetParameters,
solidity::frontend::test::ParameterList const& _sourceParameters
)
{
boost::for_each(
@@ -280,10 +280,10 @@ void ContractABIUtils::overwriteParameters(
);
}
dev::solidity::test::ParameterList ContractABIUtils::preferredParameters(
solidity::frontend::test::ParameterList ContractABIUtils::preferredParameters(
ErrorReporter& _errorReporter,
dev::solidity::test::ParameterList const& _targetParameters,
dev::solidity::test::ParameterList const& _sourceParameters,
solidity::frontend::test::ParameterList const& _targetParameters,
solidity::frontend::test::ParameterList const& _sourceParameters,
bytes const& _bytes
)
{
@@ -300,7 +300,7 @@ dev::solidity::test::ParameterList ContractABIUtils::preferredParameters(
return _targetParameters;
}
dev::solidity::test::ParameterList ContractABIUtils::defaultParameters(size_t count)
solidity::frontend::test::ParameterList ContractABIUtils::defaultParameters(size_t count)
{
ParameterList parameters;
@@ -313,7 +313,7 @@ dev::solidity::test::ParameterList ContractABIUtils::defaultParameters(size_t co
return parameters;
}
dev::solidity::test::ParameterList ContractABIUtils::failureParameters(bytes const _bytes)
solidity::frontend::test::ParameterList ContractABIUtils::failureParameters(bytes const _bytes)
{
ParameterList parameters;
@@ -330,7 +330,7 @@ dev::solidity::test::ParameterList ContractABIUtils::failureParameters(bytes con
}
size_t ContractABIUtils::encodingSize(
dev::solidity::test::ParameterList const& _parameters
solidity::frontend::test::ParameterList const& _parameters
)
{
auto sizeFold = [](size_t const _a, Parameter const& _b) { return _a + _b.abiType.size; };
+2 -8
View File
@@ -18,15 +18,11 @@
#include <test/libsolidity/util/SoltestErrors.h>
#include <libdevcore/CommonData.h>
#include <libsolutil/CommonData.h>
#include <json/json.h>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
using ABITypes = std::vector<ABIType>;
@@ -98,5 +94,3 @@ private:
};
}
}
}
+8 -14
View File
@@ -14,15 +14,11 @@
#pragma once
#include <libdevcore/AnsiColorized.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/Exceptions.h>
#include <libsolutil/AnsiColorized.h>
#include <libsolutil/CommonData.h>
#include <libsolutil/Exceptions.h>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
#define soltestAssert(CONDITION, DESCRIPTION) \
@@ -101,17 +97,17 @@ public:
break;
case FormatError::Warning:
AnsiColorized(
util::AnsiColorized(
os,
_formatted,
{formatting::YELLOW}
{util::formatting::YELLOW}
) << _linePrefix << "Warning: " << error.message << std::endl;
break;
case FormatError::Error:
AnsiColorized(
util::AnsiColorized(
os,
_formatted,
{formatting::RED}
{util::formatting::RED}
) << _linePrefix << "Error: " << error.message << std::endl;
break;
}
@@ -124,5 +120,3 @@ private:
};
}
}
}
+3 -9
View File
@@ -14,15 +14,11 @@
#pragma once
#include <libdevcore/AnsiColorized.h>
#include <libdevcore/CommonData.h>
#include <libsolutil/AnsiColorized.h>
#include <libsolutil/CommonData.h>
#include <libsolidity/ast/Types.h>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
/**
@@ -274,5 +270,3 @@ struct FunctionCall
};
}
}
}
+4 -4
View File
@@ -31,10 +31,10 @@
#include <optional>
#include <stdexcept>
using namespace dev;
using namespace langutil;
using namespace solidity;
using namespace dev::solidity::test;
using namespace solidity::langutil;
using namespace solidity::frontend;
using namespace solidity::frontend::test;
using namespace std;
using namespace soltest;
@@ -48,7 +48,7 @@ char TestFileParser::Scanner::peek() const noexcept
return *next;
}
vector<dev::solidity::test::FunctionCall> TestFileParser::parseFunctionCalls(size_t _lineOffset)
vector<solidity::frontend::test::FunctionCall> TestFileParser::parseFunctionCalls(size_t _lineOffset)
{
vector<FunctionCall> calls;
if (!accept(Token::EOS))
+2 -8
View File
@@ -14,7 +14,7 @@
#pragma once
#include <libdevcore/CommonData.h>
#include <libsolutil/CommonData.h>
#include <libsolidity/ast/Types.h>
#include <liblangutil/Exceptions.h>
#include <test/libsolidity/util/SoltestTypes.h>
@@ -27,11 +27,7 @@
#include <vector>
#include <utility>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
/**
@@ -193,5 +189,3 @@ private:
};
}
}
}
@@ -28,13 +28,10 @@
#include <test/libsolidity/util/TestFileParser.h>
using namespace std;
using namespace dev::test;
using namespace solidity::util;
using namespace solidity::test;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
using fmt = ExecutionFramework;
@@ -936,5 +933,3 @@ BOOST_AUTO_TEST_CASE(library)
BOOST_AUTO_TEST_SUITE_END()
}
}
}
+9 -9
View File
@@ -17,7 +17,7 @@
#include <test/libsolidity/util/BytesUtils.h>
#include <test/libsolidity/util/ContractABIUtils.h>
#include <libdevcore/AnsiColorized.h>
#include <libsolutil/AnsiColorized.h>
#include <boost/algorithm/string/replace.hpp>
@@ -25,9 +25,9 @@
#include <stdexcept>
#include <string>
using namespace dev;
using namespace solidity;
using namespace dev::solidity::test;
using namespace solidity::util;
using namespace solidity::frontend::test;
using namespace std;
string TestFunctionCall::format(
@@ -110,7 +110,7 @@ string TestFunctionCall::format(
formatFailure(_errorReporter, m_call, m_rawBytes, _renderResult, highlight) :
formatRawParameters(m_call.expectations.result);
if (!result.empty())
AnsiColorized(stream, highlight, {dev::formatting::RED_BACKGROUND}) << ws << result;
AnsiColorized(stream, highlight, {util::formatting::RED_BACKGROUND}) << ws << result;
}
else
{
@@ -159,7 +159,7 @@ string TestFunctionCall::format(
}
if (isFailure)
AnsiColorized(stream, highlight, {dev::formatting::RED_BACKGROUND}) << ws << result;
AnsiColorized(stream, highlight, {util::formatting::RED_BACKGROUND}) << ws << result;
else
if (!result.empty())
stream << ws << result;
@@ -190,12 +190,12 @@ string TestFunctionCall::formatBytesParameters(
ErrorReporter& _errorReporter,
bytes const& _bytes,
string const& _signature,
dev::solidity::test::ParameterList const& _parameters,
solidity::frontend::test::ParameterList const& _parameters,
bool _highlight,
bool _failure
) const
{
using ParameterList = dev::solidity::test::ParameterList;
using ParameterList = solidity::frontend::test::ParameterList;
stringstream os;
@@ -248,7 +248,7 @@ string TestFunctionCall::formatBytesParameters(
string TestFunctionCall::formatFailure(
ErrorReporter& _errorReporter,
dev::solidity::test::FunctionCall const& _call,
solidity::frontend::test::FunctionCall const& _call,
bytes const& _output,
bool _renderResult,
bool _highlight
@@ -279,7 +279,7 @@ string TestFunctionCall::formatFailure(
}
string TestFunctionCall::formatRawParameters(
dev::solidity::test::ParameterList const& _params,
solidity::frontend::test::ParameterList const& _params,
std::string const& _linePrefix
) const
{
+3 -9
View File
@@ -19,8 +19,8 @@
#include <libsolidity/ast/Types.h>
#include <liblangutil/Exceptions.h>
#include <libdevcore/AnsiColorized.h>
#include <libdevcore/CommonData.h>
#include <libsolutil/AnsiColorized.h>
#include <libsolutil/CommonData.h>
#include <json/json.h>
@@ -30,11 +30,7 @@
#include <string>
#include <vector>
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
/**
@@ -136,5 +132,3 @@ private:
};
}
}
}
@@ -25,13 +25,10 @@
#include <test/libsolidity/util/TestFunctionCall.h>
using namespace std;
using namespace dev::test;
using namespace solidity::util;
using namespace solidity::test;
namespace dev
{
namespace solidity
{
namespace test
namespace solidity::frontend::test
{
BOOST_AUTO_TEST_SUITE(TestFunctionCallTest)
@@ -256,5 +253,3 @@ BOOST_AUTO_TEST_CASE(format_failure_singleline)
BOOST_AUTO_TEST_SUITE_END()
}
}
}
@@ -18,17 +18,15 @@
* Unit tests for the address checksum.
*/
#include <libdevcore/CommonData.h>
#include <libdevcore/Exceptions.h>
#include <libsolutil/CommonData.h>
#include <libsolutil/Exceptions.h>
#include <test/Options.h>
using namespace std;
namespace dev
{
namespace test
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(Checksum)
@@ -114,4 +112,3 @@ BOOST_AUTO_TEST_CASE(homocaps_invalid)
BOOST_AUTO_TEST_SUITE_END()
}
}
@@ -18,22 +18,20 @@
* Unit tests for the StringUtils routines.
*/
#include <libdevcore/Common.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/FixedHash.h>
#include <libsolutil/Common.h>
#include <libsolutil/CommonData.h>
#include <libsolutil/FixedHash.h>
#include <libsolidity/ast/Types.h> // for IntegerType
#include <test/Options.h>
using namespace std;
using namespace dev::solidity;
using namespace solidity::frontend;
// TODO: Fix Boost...
BOOST_TEST_DONT_PRINT_LOG_VALUE(dev::bytes);
BOOST_TEST_DONT_PRINT_LOG_VALUE(solidity::bytes);
namespace dev
{
namespace test
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(CommonData)
@@ -140,4 +138,3 @@ BOOST_AUTO_TEST_CASE(test_format_number)
BOOST_AUTO_TEST_SUITE_END()
}
}
@@ -18,15 +18,13 @@
* Unit tests for IndentedWriter.
*/
#include <libdevcore/IndentedWriter.h>
#include <libsolutil/IndentedWriter.h>
#include <test/Options.h>
using namespace std;
namespace dev
{
namespace test
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(IndentedWriterTest)
@@ -72,4 +70,3 @@ BOOST_AUTO_TEST_CASE(indent)
BOOST_AUTO_TEST_SUITE_END()
}
}
@@ -18,15 +18,13 @@
* Unit tests for the ipfs hash computation routine.
*/
#include <libdevcore/IpfsHash.h>
#include <libsolutil/IpfsHash.h>
#include <test/Options.h>
using namespace std;
namespace dev
{
namespace test
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(IpfsHash)
@@ -73,4 +71,3 @@ BOOST_AUTO_TEST_CASE(test_largest_unchunked)
BOOST_AUTO_TEST_SUITE_END()
}
}
@@ -18,15 +18,13 @@
* Unit tests for the iterateReplacing function
*/
#include <libdevcore/CommonData.h>
#include <libsolutil/CommonData.h>
#include <test/Options.h>
using namespace std;
namespace dev
{
namespace test
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(IterateReplacing)
@@ -94,4 +92,3 @@ BOOST_AUTO_TEST_CASE(inject_some_end)
BOOST_AUTO_TEST_SUITE_END()
}
}
@@ -19,15 +19,13 @@
* Unit tests for JSON.h.
*/
#include <libdevcore/JSON.h>
#include <libsolutil/JSON.h>
#include <test/Options.h>
using namespace std;
namespace dev
{
namespace test
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(JsonTest)
@@ -107,4 +105,3 @@ BOOST_AUTO_TEST_CASE(parse_json_strict)
BOOST_AUTO_TEST_SUITE_END()
}
}
@@ -17,15 +17,13 @@
/**
* Unit tests for keccak256.
*/
#include <libdevcore/Keccak256.h>
#include <libsolutil/Keccak256.h>
#include <boost/test/unit_test.hpp>
using namespace std;
namespace dev
{
namespace test
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(Keccak256)
@@ -73,4 +71,3 @@ BOOST_AUTO_TEST_CASE(strings)
BOOST_AUTO_TEST_SUITE_END()
}
}
@@ -18,9 +18,9 @@
* Unit tests for the StringUtils routines.
*/
#include <libdevcore/CommonData.h>
#include <libdevcore/FixedHash.h>
#include <libdevcore/StringUtils.h>
#include <libsolutil/CommonData.h>
#include <libsolutil/FixedHash.h>
#include <libsolutil/StringUtils.h>
#include <libsolidity/ast/Types.h> // for IntegerType
@@ -28,9 +28,7 @@
using namespace std;
namespace dev
{
namespace test
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(StringUtils)
@@ -153,12 +151,11 @@ BOOST_AUTO_TEST_CASE(test_format_number_readable)
// for formal/SMTChecker
BOOST_CHECK_EQUAL(
formatNumberReadable(solidity::IntegerType(256).minValue()), "0");
formatNumberReadable(frontend::IntegerType(256).minValue()), "0");
BOOST_CHECK_EQUAL(
formatNumberReadable(solidity::IntegerType(256).maxValue()), "2**256 - 1");
formatNumberReadable(frontend::IntegerType(256).maxValue()), "2**256 - 1");
}
BOOST_AUTO_TEST_SUITE_END()
}
}
@@ -18,17 +18,15 @@
* Unit tests for the swarm hash computation routine.
*/
#include <libdevcore/SwarmHash.h>
#include <libsolutil/SwarmHash.h>
#include <test/Options.h>
#include <libdevcore/Keccak256.h>
#include <libsolutil/Keccak256.h>
using namespace std;
namespace dev
{
namespace test
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(SwarmHash)
@@ -100,4 +98,3 @@ BOOST_AUTO_TEST_CASE(bzz_hash_nonzero)
BOOST_AUTO_TEST_SUITE_END()
}
}
@@ -18,16 +18,14 @@
* Unit tests for UTF-8 validation.
*/
#include <libdevcore/CommonData.h>
#include <libdevcore/UTF8.h>
#include <libsolutil/CommonData.h>
#include <libsolutil/UTF8.h>
#include <test/Options.h>
using namespace std;
namespace dev
{
namespace test
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(UTF8)
@@ -213,4 +211,3 @@ hélló
BOOST_AUTO_TEST_SUITE_END()
}
}
@@ -18,15 +18,13 @@
* Unit tests for the mini moustache class.
*/
#include <libdevcore/Whiskers.h>
#include <libsolutil/Whiskers.h>
#include <test/Options.h>
using namespace std;
namespace dev
{
namespace test
namespace solidity::util::test
{
BOOST_AUTO_TEST_SUITE(WhiskersTest)
@@ -197,4 +195,3 @@ BOOST_AUTO_TEST_CASE(invalid_param_rendered)
BOOST_AUTO_TEST_SUITE_END()
}
}
+8 -7
View File
@@ -40,14 +40,15 @@
#include <variant>
using namespace std;
using namespace langutil;
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::langutil;
namespace
{
Dialect const& defaultDialect(bool _yul)
{
return _yul ? yul::Dialect::yul() : yul::EVMDialect::strictAssemblyForEVM(dev::test::Options::get().evmVersion());
return _yul ? yul::Dialect::yul() : yul::EVMDialect::strictAssemblyForEVM(solidity::test::Options::get().evmVersion());
}
}
@@ -63,11 +64,11 @@ void yul::test::printErrors(ErrorList const& _errors)
pair<shared_ptr<Block>, shared_ptr<yul::AsmAnalysisInfo>> yul::test::parse(string const& _source, bool _yul)
{
AssemblyStack stack(
dev::test::Options::get().evmVersion(),
solidity::test::Options::get().evmVersion(),
_yul ? AssemblyStack::Language::Yul : AssemblyStack::Language::StrictAssembly,
dev::test::Options::get().optimize ?
dev::solidity::OptimiserSettings::standard() :
dev::solidity::OptimiserSettings::minimal()
solidity::test::Options::get().optimize ?
solidity::frontend::OptimiserSettings::standard() :
solidity::frontend::OptimiserSettings::minimal()
);
if (!stack.parseAndAnalyze("", _source) || !stack.errors().empty())
BOOST_FAIL("Invalid source.");
+3 -6
View File
@@ -27,20 +27,18 @@
#include <vector>
#include <memory>
namespace langutil
namespace solidity::langutil
{
class Error;
using ErrorList = std::vector<std::shared_ptr<Error const>>;
}
namespace yul
namespace solidity::yul
{
struct AsmAnalysisInfo;
}
namespace yul
{
namespace test
namespace solidity::yul::test
{
void printErrors(langutil::ErrorList const& _errors);
@@ -50,4 +48,3 @@ Block disambiguate(std::string const& _source, bool _yul = true);
std::string format(std::string const& _source, bool _yul = true);
}
}
+2 -5
View File
@@ -28,9 +28,7 @@
using namespace std;
namespace yul
{
namespace test
namespace solidity::yul::test
{
namespace
@@ -40,7 +38,7 @@ string check(string const& _input)
Object obj;
std::tie(obj.code, obj.analysisInfo) = yul::test::parse(_input, false);
BOOST_REQUIRE(obj.code);
map<YulString, int> functions = CompilabilityChecker::run(EVMDialect::strictAssemblyForEVM(dev::test::Options::get().evmVersion()), obj, true);
map<YulString, int> functions = CompilabilityChecker::run(EVMDialect::strictAssemblyForEVM(solidity::test::Options::get().evmVersion()), obj, true);
string out;
for (auto const& function: functions)
out += function.first.str() + ": " + to_string(function.second) + " ";
@@ -223,4 +221,3 @@ BOOST_AUTO_TEST_CASE(also_in_outer_block)
BOOST_AUTO_TEST_SUITE_END()
}
}

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