mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #8135 from ethereum/fix-get-options-7112
TestFramework: Merge Options.h into Common.h
This commit is contained in:
@@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(enums)
|
||||
}
|
||||
}
|
||||
)";
|
||||
bool newDecoder = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool newDecoder = solidity::test::CommonOptions::get().useABIEncoderV2;
|
||||
BOTH_ENCODERS(
|
||||
compileAndRun(sourceCode);
|
||||
ABI_CHECK(callContractFunction("f(uint8)", 0), encodeArgs(u256(0)));
|
||||
@@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(cleanup)
|
||||
}
|
||||
}
|
||||
)";
|
||||
bool newDecoder = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool newDecoder = solidity::test::CommonOptions::get().useABIEncoderV2;
|
||||
BOTH_ENCODERS(
|
||||
compileAndRun(sourceCode);
|
||||
ABI_CHECK(
|
||||
@@ -573,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 = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool newDecoder = solidity::test::CommonOptions::get().useABIEncoderV2;
|
||||
string validFun{"01234567890123456789abcd"};
|
||||
string invalidFun{"01234567890123456789abcdX"};
|
||||
BOTH_ENCODERS(
|
||||
@@ -950,7 +950,7 @@ BOOST_AUTO_TEST_CASE(out_of_bounds_bool_value)
|
||||
function f(bool b) public pure returns (bool) { return b; }
|
||||
}
|
||||
)";
|
||||
bool newDecoder = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool newDecoder = solidity::test::CommonOptions::get().useABIEncoderV2;
|
||||
BOTH_ENCODERS(
|
||||
compileAndRun(sourceCode);
|
||||
ABI_CHECK(callContractFunction("f(bool)", true), encodeArgs(true));
|
||||
|
||||
@@ -165,7 +165,7 @@ BOOST_AUTO_TEST_CASE(memory_array_one_dim)
|
||||
}
|
||||
)";
|
||||
|
||||
if (!solidity::test::Options::get().useABIEncoderV2)
|
||||
if (!solidity::test::CommonOptions::get().useABIEncoderV2)
|
||||
{
|
||||
compileAndRun(sourceCode);
|
||||
callContractFunction("f()");
|
||||
@@ -752,7 +752,7 @@ BOOST_AUTO_TEST_CASE(struct_in_constructor_indirect)
|
||||
}
|
||||
}
|
||||
)";
|
||||
if (solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
{
|
||||
NEW_ENCODER(
|
||||
compileAndRun(sourceCode, 0, "D");
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <test/libsolidity/ABIJsonTest.h>
|
||||
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <libsolidity/interface/CompilerStack.h>
|
||||
#include <libsolutil/JSON.h>
|
||||
@@ -52,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(solidity::test::Options::get().evmVersion());
|
||||
compiler.setOptimiserSettings(solidity::test::Options::get().optimize);
|
||||
compiler.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
compiler.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
|
||||
if (!compiler.parseAndAnalyze())
|
||||
BOOST_THROW_EXCEPTION(runtime_error("Parsing contract failed"));
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <test/libsolidity/ASTJSONTest.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
#include <libsolutil/AnsiColorized.h>
|
||||
#include <liblangutil/SourceReferenceFormatterHuman.h>
|
||||
#include <libsolidity/ast/ASTJsonConverter.h>
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
@@ -46,7 +47,7 @@ void replaceVersionWithTag(string& _input)
|
||||
{
|
||||
boost::algorithm::replace_all(
|
||||
_input,
|
||||
"\"" + solidity::test::Options::get().evmVersion().name() + "\"",
|
||||
"\"" + solidity::test::CommonOptions::get().evmVersion().name() + "\"",
|
||||
"%EVMVERSION%"
|
||||
);
|
||||
}
|
||||
@@ -56,7 +57,7 @@ void replaceTagWithVersion(string& _input)
|
||||
boost::algorithm::replace_all(
|
||||
_input,
|
||||
"%EVMVERSION%",
|
||||
"\"" + solidity::test::Options::get().evmVersion().name() + "\""
|
||||
"\"" + solidity::test::CommonOptions::get().evmVersion().name() + "\""
|
||||
);
|
||||
}
|
||||
|
||||
@@ -128,7 +129,7 @@ TestCase::TestResult ASTJSONTest::run(ostream& _stream, string const& _linePrefi
|
||||
sourceIndices[m_sources[i].first] = i + 1;
|
||||
}
|
||||
c.setSources(sources);
|
||||
c.setEVMVersion(solidity::test::Options::get().evmVersion());
|
||||
c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
if (c.parse())
|
||||
c.analyze();
|
||||
else
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <test/libsolidity/AnalysisFramework.h>
|
||||
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <libsolidity/interface/CompilerStack.h>
|
||||
#include <liblangutil/SourceReferenceFormatter.h>
|
||||
@@ -51,7 +51,7 @@ AnalysisFramework::parseAnalyseAndReturnError(
|
||||
{
|
||||
compiler().reset();
|
||||
compiler().setSources({{"", _insertVersionPragma ? "pragma solidity >=0.0;\n" + _source : _source}});
|
||||
compiler().setEVMVersion(solidity::test::Options::get().evmVersion());
|
||||
compiler().setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
compiler().setParserErrorRecovery(_allowRecoveryErrors);
|
||||
_allowMultipleErrors = _allowMultipleErrors || _allowRecoveryErrors;
|
||||
if (!compiler().parse())
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* Unit tests for Assembly Items from evmasm/Assembly.h
|
||||
*/
|
||||
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <liblangutil/SourceLocation.h>
|
||||
#include <libevmasm/Assembly.h>
|
||||
@@ -52,14 +52,14 @@ evmasm::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
|
||||
{
|
||||
ErrorList errors;
|
||||
ErrorReporter errorReporter(errors);
|
||||
Parser parser(errorReporter, solidity::test::Options::get().evmVersion());
|
||||
Parser parser(errorReporter, solidity::test::CommonOptions::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, solidity::test::Options::get().evmVersion(), scopes, errorReporter);
|
||||
NameAndTypeResolver resolver(globalContext, solidity::test::CommonOptions::get().evmVersion(), scopes, errorReporter);
|
||||
solAssert(Error::containsOnlyWarnings(errorReporter.errors()), "");
|
||||
resolver.registerDeclarations(*sourceUnit);
|
||||
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
|
||||
@@ -72,7 +72,7 @@ evmasm::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
|
||||
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
|
||||
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
||||
{
|
||||
TypeChecker checker(solidity::test::Options::get().evmVersion(), errorReporter);
|
||||
TypeChecker checker(solidity::test::CommonOptions::get().evmVersion(), errorReporter);
|
||||
BOOST_REQUIRE_NO_THROW(checker.checkTypeRequirements(*contract));
|
||||
if (!Error::containsOnlyWarnings(errorReporter.errors()))
|
||||
return AssemblyItems();
|
||||
@@ -81,9 +81,9 @@ evmasm::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
|
||||
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
||||
{
|
||||
Compiler compiler(
|
||||
solidity::test::Options::get().evmVersion(),
|
||||
solidity::test::CommonOptions::get().evmVersion(),
|
||||
RevertStrings::Default,
|
||||
solidity::test::Options::get().optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal()
|
||||
solidity::test::CommonOptions::get().optimize ? OptimiserSettings::standard() : OptimiserSettings::minimal()
|
||||
);
|
||||
compiler.compileContract(*contract, map<ContractDefinition const*, shared_ptr<Compiler const>>{}, bytes());
|
||||
|
||||
@@ -161,12 +161,12 @@ BOOST_AUTO_TEST_CASE(location_test)
|
||||
}
|
||||
)", "");
|
||||
AssemblyItems items = compileContract(sourceCode);
|
||||
bool hasShifts = solidity::test::Options::get().evmVersion().hasBitwiseShifting();
|
||||
bool hasShifts = solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting();
|
||||
|
||||
auto codegenCharStream = make_shared<CharStream>("", "--CODEGEN--");
|
||||
|
||||
vector<SourceLocation> locations;
|
||||
if (solidity::test::Options::get().optimize)
|
||||
if (solidity::test::CommonOptions::get().optimize)
|
||||
locations =
|
||||
vector<SourceLocation>(4, SourceLocation{2, 82, sourceCode}) +
|
||||
vector<SourceLocation>(1, SourceLocation{8, 17, codegenCharStream}) +
|
||||
|
||||
@@ -93,14 +93,14 @@ BOOST_AUTO_TEST_CASE(string_storage)
|
||||
m_compiler.overwriteReleaseFlag(true);
|
||||
compileAndRun(sourceCode);
|
||||
|
||||
auto evmVersion = solidity::test::Options::get().evmVersion();
|
||||
auto evmVersion = solidity::test::CommonOptions::get().evmVersion();
|
||||
|
||||
if (evmVersion <= EVMVersion::byzantium())
|
||||
CHECK_DEPLOY_GAS(134209, 130895, evmVersion);
|
||||
// This is only correct on >=Constantinople.
|
||||
else if (Options::get().useABIEncoderV2)
|
||||
else if (CommonOptions::get().useABIEncoderV2)
|
||||
{
|
||||
if (Options::get().optimizeYul)
|
||||
if (CommonOptions::get().optimizeYul)
|
||||
{
|
||||
// Costs with 0 are cases which cannot be triggered in tests.
|
||||
if (evmVersion < EVMVersion::istanbul())
|
||||
@@ -127,9 +127,9 @@ BOOST_AUTO_TEST_CASE(string_storage)
|
||||
if (evmVersion == EVMVersion::byzantium())
|
||||
CHECK_GAS(21545, 21526, 20);
|
||||
// This is only correct on >=Constantinople.
|
||||
else if (Options::get().useABIEncoderV2)
|
||||
else if (CommonOptions::get().useABIEncoderV2)
|
||||
{
|
||||
if (Options::get().optimizeYul)
|
||||
if (CommonOptions::get().optimizeYul)
|
||||
{
|
||||
if (evmVersion < EVMVersion::istanbul())
|
||||
CHECK_GAS(0, 21567, 20);
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
{
|
||||
m_compiler.reset();
|
||||
m_compiler.setSources({{"", "pragma solidity >=0.0;\n" + _sourceCode}});
|
||||
m_compiler.setOptimiserSettings(solidity::test::Options::get().optimize);
|
||||
m_compiler.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
|
||||
m_compiler.setEVMVersion(m_evmVersion);
|
||||
BOOST_REQUIRE_MESSAGE(m_compiler.compile(), "Compiling contract failed");
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
ASTNode const& sourceUnit = m_compiler.ast("");
|
||||
BOOST_REQUIRE(items != nullptr);
|
||||
m_gasCosts = GasEstimator::breakToStatementLevel(
|
||||
GasEstimator(solidity::test::Options::get().evmVersion()).structuralEstimation(*items, vector<ASTNode const*>({&sourceUnit})),
|
||||
GasEstimator(solidity::test::CommonOptions::get().evmVersion()).structuralEstimation(*items, vector<ASTNode const*>({&sourceUnit})),
|
||||
{&sourceUnit}
|
||||
);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
{
|
||||
compileAndRun(_sourceCode);
|
||||
auto state = make_shared<KnownState>();
|
||||
PathGasMeter meter(*m_compiler.assemblyItems(m_compiler.lastContractName()), solidity::test::Options::get().evmVersion());
|
||||
PathGasMeter meter(*m_compiler.assemblyItems(m_compiler.lastContractName()), solidity::test::CommonOptions::get().evmVersion());
|
||||
GasMeter::GasConsumption gas = meter.estimateMax(0, state);
|
||||
u256 bytecodeSize(m_compiler.runtimeObject(m_compiler.lastContractName()).bytecode.size());
|
||||
// costs for deployment
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
|
||||
// Skip the tests when we force ABIEncoderV2.
|
||||
// TODO: We should enable this again once the yul optimizer is activated.
|
||||
if (!solidity::test::Options::get().useABIEncoderV2)
|
||||
if (!solidity::test::CommonOptions::get().useABIEncoderV2)
|
||||
{
|
||||
BOOST_REQUIRE(!gas.isInfinite);
|
||||
BOOST_CHECK_LE(m_gasUsed, gas.value);
|
||||
@@ -94,13 +94,13 @@ public:
|
||||
gas = max(gas, gasForTransaction(hash.asBytes() + arguments, false));
|
||||
}
|
||||
|
||||
gas += GasEstimator(solidity::test::Options::get().evmVersion()).functionalEstimation(
|
||||
gas += GasEstimator(solidity::test::CommonOptions::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 (!solidity::test::Options::get().useABIEncoderV2)
|
||||
if (!solidity::test::CommonOptions::get().useABIEncoderV2)
|
||||
{
|
||||
BOOST_REQUIRE(!gas.isInfinite);
|
||||
BOOST_CHECK_LE(m_gasUsed, gas.value);
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
|
||||
static GasMeter::GasConsumption gasForTransaction(bytes const& _data, bool _isCreation)
|
||||
{
|
||||
auto evmVersion = solidity::test::Options::get().evmVersion();
|
||||
auto evmVersion = solidity::test::CommonOptions::get().evmVersion();
|
||||
GasMeter::GasConsumption gas = _isCreation ? GasCosts::txCreateGas : GasCosts::txGas;
|
||||
for (auto i: _data)
|
||||
gas += i != 0 ? GasCosts::txDataNonZeroGas(evmVersion) : GasCosts::txDataZeroGas;
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
*/
|
||||
|
||||
#include <test/libsolidity/GasTest.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
#include <libsolutil/CommonIO.h>
|
||||
#include <libsolutil/JSON.h>
|
||||
#include <liblangutil/SourceReferenceFormatterHuman.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
#include <test/libsolidity/ErrorCheck.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <liblangutil/Exceptions.h>
|
||||
#include <libsolidity/interface/CompilerStack.h>
|
||||
@@ -47,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(solidity::test::Options::get().evmVersion());
|
||||
c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
BOOST_CHECK(c.compile());
|
||||
}
|
||||
|
||||
@@ -61,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(solidity::test::Options::get().evmVersion());
|
||||
c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
BOOST_CHECK(c.compile());
|
||||
}
|
||||
|
||||
@@ -79,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(solidity::test::Options::get().evmVersion());
|
||||
c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
BOOST_CHECK(c.compile());
|
||||
}
|
||||
|
||||
@@ -93,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(solidity::test::Options::get().evmVersion());
|
||||
c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
BOOST_CHECK(c.compile());
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ 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(solidity::test::Options::get().evmVersion());
|
||||
c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
BOOST_CHECK(c.compile());
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* Unit tests for inline assembly.
|
||||
*/
|
||||
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <test/libsolidity/ErrorCheck.h>
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <libevmasm/Assembly.h>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -58,7 +59,7 @@ std::optional<Error> parseAndReturnFirstError(
|
||||
AssemblyStack::Machine _machine = AssemblyStack::Machine::EVM
|
||||
)
|
||||
{
|
||||
AssemblyStack stack(solidity::test::Options::get().evmVersion(), _language, solidity::frontend::OptimiserSettings::none());
|
||||
AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), _language, solidity::frontend::OptimiserSettings::none());
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
@@ -125,7 +126,7 @@ Error expectError(
|
||||
|
||||
void parsePrintCompare(string const& _source, bool _canWarn = false)
|
||||
{
|
||||
AssemblyStack stack(solidity::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
|
||||
AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
|
||||
BOOST_REQUIRE(stack.parseAndAnalyze("", _source));
|
||||
if (_canWarn)
|
||||
BOOST_REQUIRE(Error::containsOnlyWarnings(stack.errors()));
|
||||
@@ -538,7 +539,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(solidity::test::Options::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
|
||||
AssemblyStack stack(solidity::test::CommonOptions::get().evmVersion(), AssemblyStack::Language::Assembly, OptimiserSettings::none());
|
||||
BOOST_REQUIRE(stack.parseAndAnalyze("", source));
|
||||
BOOST_REQUIRE(stack.errors().empty());
|
||||
BOOST_CHECK_EQUAL(stack.print(), parsed);
|
||||
@@ -685,42 +686,42 @@ BOOST_AUTO_TEST_CASE(keccak256)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(returndatasize)
|
||||
{
|
||||
if (!solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (!solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
return;
|
||||
BOOST_CHECK(successAssemble("{ let r := returndatasize() }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(returndatacopy)
|
||||
{
|
||||
if (!solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (!solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
return;
|
||||
BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(returndatacopy_functional)
|
||||
{
|
||||
if (!solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (!solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
return;
|
||||
BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(staticcall)
|
||||
{
|
||||
if (!solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (!solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
return;
|
||||
BOOST_CHECK(successAssemble("{ pop(staticcall(10000, 0x123, 64, 0x10, 128, 0x10)) }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(create2)
|
||||
{
|
||||
if (!solidity::test::Options::get().evmVersion().hasCreate2())
|
||||
if (!solidity::test::CommonOptions::get().evmVersion().hasCreate2())
|
||||
return;
|
||||
BOOST_CHECK(successAssemble("{ pop(create2(10, 0x123, 32, 64)) }"));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(shift)
|
||||
{
|
||||
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting())
|
||||
if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting())
|
||||
return;
|
||||
BOOST_CHECK(successAssemble("{ pop(shl(10, 32)) }"));
|
||||
BOOST_CHECK(successAssemble("{ pop(shr(10, 32)) }"));
|
||||
@@ -729,7 +730,7 @@ BOOST_AUTO_TEST_CASE(shift)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(shift_constantinople_warning)
|
||||
{
|
||||
if (solidity::test::Options::get().evmVersion().hasBitwiseShifting())
|
||||
if (solidity::test::CommonOptions::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");
|
||||
|
||||
@@ -20,13 +20,15 @@
|
||||
*/
|
||||
|
||||
#include <test/Metadata.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
#include <libsolidity/interface/CompilerStack.h>
|
||||
#include <libsolidity/interface/Version.h>
|
||||
#include <libsolutil/SwarmHash.h>
|
||||
#include <libsolutil/IpfsHash.h>
|
||||
#include <libsolutil/JSON.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace solidity::frontend::test
|
||||
@@ -66,8 +68,8 @@ BOOST_AUTO_TEST_CASE(metadata_stamp)
|
||||
CompilerStack compilerStack;
|
||||
compilerStack.overwriteReleaseFlag(release);
|
||||
compilerStack.setSources({{"", std::string(sourceCode)}});
|
||||
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
|
||||
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize);
|
||||
compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
|
||||
compilerStack.setMetadataHash(metadataHash);
|
||||
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
|
||||
bytes const& bytecode = compilerStack.runtimeObject("test").bytecode;
|
||||
@@ -127,8 +129,8 @@ BOOST_AUTO_TEST_CASE(metadata_stamp_experimental)
|
||||
CompilerStack compilerStack;
|
||||
compilerStack.overwriteReleaseFlag(release);
|
||||
compilerStack.setSources({{"", std::string(sourceCode)}});
|
||||
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
|
||||
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize);
|
||||
compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
|
||||
compilerStack.setMetadataHash(metadataHash);
|
||||
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
|
||||
bytes const& bytecode = compilerStack.runtimeObject("test").bytecode;
|
||||
@@ -189,8 +191,8 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources)
|
||||
{"A", std::string(sourceCodeA)},
|
||||
{"B", std::string(sourceCodeB)},
|
||||
});
|
||||
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
|
||||
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize);
|
||||
compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
|
||||
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
|
||||
|
||||
std::string const& serialisedMetadata = compilerStack.metadata("A");
|
||||
@@ -230,8 +232,8 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports)
|
||||
{"B", std::string(sourceCodeB)},
|
||||
{"C", std::string(sourceCodeC)}
|
||||
});
|
||||
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
|
||||
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize);
|
||||
compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
|
||||
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
|
||||
|
||||
std::string const& serialisedMetadata = compilerStack.metadata("C");
|
||||
@@ -258,8 +260,8 @@ BOOST_AUTO_TEST_CASE(metadata_useLiteralContent)
|
||||
{
|
||||
CompilerStack compilerStack;
|
||||
compilerStack.setSources({{"", std::string(_src)}});
|
||||
compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
|
||||
compilerStack.setOptimiserSettings(solidity::test::Options::get().optimize);
|
||||
compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
compilerStack.setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
|
||||
compilerStack.useMetadataLiteralSources(_literal);
|
||||
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
|
||||
string metadata_str = compilerStack.metadata("test");
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <test/libsolidity/AnalysisFramework.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
@@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(import_base)
|
||||
}
|
||||
)"}
|
||||
});
|
||||
c.setEVMVersion(solidity::test::Options::get().evmVersion());
|
||||
c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
BOOST_CHECK(c.compile());
|
||||
|
||||
unsigned asserts = 0;
|
||||
@@ -122,7 +122,7 @@ BOOST_AUTO_TEST_CASE(import_library)
|
||||
}
|
||||
)"}
|
||||
});
|
||||
c.setEVMVersion(solidity::test::Options::get().evmVersion());
|
||||
c.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
BOOST_CHECK(c.compile());
|
||||
|
||||
unsigned asserts = 0;
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
*/
|
||||
|
||||
#include <test/libsolidity/SMTCheckerJSONTest.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
#include <libsolidity/interface/StandardCompiler.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>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <test/libsolidity/SMTCheckerTest.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <libsolidity/formal/ModelChecker.h>
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
#include <tuple>
|
||||
#include <liblangutil/Scanner.h>
|
||||
#include <liblangutil/SemVerHandler.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity::langutil;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
#include <test/libsolidity/SemanticTest.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
|
||||
#include <test/libsolidity/AnalysisFramework.h>
|
||||
#include <test/Metadata.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -38,7 +40,7 @@ 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(solidity::test::Options::get().optimize);
|
||||
compiler().setOptimiserSettings(solidity::test::CommonOptions::get().optimize);
|
||||
BOOST_REQUIRE(success(sourceCode));
|
||||
BOOST_REQUIRE_MESSAGE(compiler().compile(), "Compiling contract failed");
|
||||
bytes const& creationBytecode = solidity::test::bytecodeSansMetadata(compiler().object("C").bytecode);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include <test/libsolidity/SolidityExecutionFramework.h>
|
||||
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
#include <test/EVMHost.h>
|
||||
|
||||
#include <liblangutil/Exceptions.h>
|
||||
@@ -2458,7 +2458,7 @@ BOOST_AUTO_TEST_CASE(default_fallback_throws)
|
||||
compileAndRun(sourceCode);
|
||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(0));
|
||||
|
||||
if (solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
{
|
||||
char const* sourceCode = R"YY(
|
||||
contract A {
|
||||
@@ -3323,7 +3323,7 @@ BOOST_AUTO_TEST_CASE(generic_delegatecall)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(generic_staticcall)
|
||||
{
|
||||
if (solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
{
|
||||
char const* sourceCode = R"**(
|
||||
contract A {
|
||||
@@ -5709,7 +5709,7 @@ BOOST_AUTO_TEST_CASE(bool_conversion)
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
bool v2 = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool v2 = solidity::test::CommonOptions::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));
|
||||
@@ -9970,7 +9970,7 @@ BOOST_AUTO_TEST_CASE(cleanup_bytes_types)
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
// We input longer data on purpose.
|
||||
bool v2 = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool v2 = solidity::test::CommonOptions::get().useABIEncoderV2;
|
||||
ABI_CHECK(callContractFunction("f(bytes2,uint16)", string("abc"), u256(0x040102)), v2 ? encodeArgs() : encodeArgs(0));
|
||||
}
|
||||
BOOST_AUTO_TEST_CASE(cleanup_bytes_types_shortening)
|
||||
@@ -10007,7 +10007,7 @@ BOOST_AUTO_TEST_CASE(cleanup_address_types)
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
|
||||
bool v2 = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool v2 = solidity::test::CommonOptions::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));
|
||||
@@ -11260,7 +11260,7 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled)
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
bool v2 = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool v2 = solidity::test::CommonOptions::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)));
|
||||
}
|
||||
@@ -11286,7 +11286,7 @@ BOOST_AUTO_TEST_CASE(shift_right_garbled_signed)
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
bool v2 = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool v2 = solidity::test::CommonOptions::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)));
|
||||
@@ -11480,7 +11480,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int8)
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
bool v2 = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool v2 = solidity::test::CommonOptions::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)));
|
||||
@@ -11498,7 +11498,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int16)
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
bool v2 = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool v2 = solidity::test::CommonOptions::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)));
|
||||
@@ -11516,7 +11516,7 @@ BOOST_AUTO_TEST_CASE(shift_right_negative_lvalue_signextend_int32)
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
bool v2 = solidity::test::Options::get().useABIEncoderV2;
|
||||
bool v2 = solidity::test::CommonOptions::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)));
|
||||
@@ -12044,7 +12044,7 @@ BOOST_AUTO_TEST_CASE(revert_with_cause)
|
||||
}
|
||||
}
|
||||
)";
|
||||
if (solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
{
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0};
|
||||
@@ -12118,7 +12118,7 @@ BOOST_AUTO_TEST_CASE(require_with_message)
|
||||
}
|
||||
}
|
||||
)";
|
||||
if (solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
{
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0};
|
||||
@@ -12164,7 +12164,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages)
|
||||
}
|
||||
}
|
||||
)";
|
||||
if (solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
{
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0};
|
||||
@@ -12202,7 +12202,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_transfer)
|
||||
}
|
||||
}
|
||||
)";
|
||||
if (solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
{
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0};
|
||||
@@ -12241,7 +12241,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_create)
|
||||
}
|
||||
}
|
||||
)";
|
||||
if (solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
{
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
bytes const errorSignature = bytes{0x08, 0xc3, 0x79, 0xa0};
|
||||
@@ -12446,7 +12446,7 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address)
|
||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(u256(1)));
|
||||
ABI_CHECK(callContractFunction("h()"), encodeArgs(u256(1)));
|
||||
|
||||
if (solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
{
|
||||
char const* sourceCode = R"YY(
|
||||
contract C {
|
||||
@@ -12462,10 +12462,10 @@ BOOST_AUTO_TEST_CASE(bare_call_invalid_address)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bare_call_return_data)
|
||||
{
|
||||
if (solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
{
|
||||
vector<string> calltypes = {"call", "delegatecall"};
|
||||
if (solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
calltypes.emplace_back("staticcall");
|
||||
for (string const& calltype: calltypes)
|
||||
{
|
||||
@@ -12589,7 +12589,7 @@ BOOST_AUTO_TEST_CASE(bare_call_return_data)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(delegatecall_return_value)
|
||||
{
|
||||
if (solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
{
|
||||
char const* sourceCode = R"DELIMITER(
|
||||
contract C {
|
||||
@@ -13390,7 +13390,7 @@ BOOST_AUTO_TEST_CASE(abi_encode_empty_string)
|
||||
)";
|
||||
|
||||
compileAndRun(sourceCode, 0, "C");
|
||||
if (!solidity::test::Options::get().useABIEncoderV2)
|
||||
if (!solidity::test::CommonOptions::get().useABIEncoderV2)
|
||||
{
|
||||
// ABI Encoder V2 has slightly different padding, tested below.
|
||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(
|
||||
@@ -13514,7 +13514,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 (solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
{
|
||||
// These should throw (called via STATICCALL)
|
||||
ABI_CHECK(callContractFunction("fview()"), encodeArgs());
|
||||
@@ -13529,7 +13529,7 @@ BOOST_AUTO_TEST_CASE(staticcall_for_view_and_pure)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
|
||||
{
|
||||
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting())
|
||||
if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting())
|
||||
return;
|
||||
char const* sourceCode = R"(
|
||||
contract C {
|
||||
@@ -13568,7 +13568,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
|
||||
{
|
||||
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting())
|
||||
if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting())
|
||||
return;
|
||||
char const* sourceCode = R"(
|
||||
contract C {
|
||||
@@ -13635,7 +13635,7 @@ BOOST_AUTO_TEST_CASE(bitwise_shifting_constants_constantinople)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bitwise_shifting_constantinople_combined)
|
||||
{
|
||||
if (!solidity::test::Options::get().evmVersion().hasBitwiseShifting())
|
||||
if (!solidity::test::CommonOptions::get().evmVersion().hasBitwiseShifting())
|
||||
return;
|
||||
char const* sourceCode = R"(
|
||||
contract C {
|
||||
@@ -14391,7 +14391,7 @@ BOOST_AUTO_TEST_CASE(try_catch_library_call)
|
||||
}
|
||||
}
|
||||
)";
|
||||
if (solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().supportsReturndata())
|
||||
{
|
||||
compileAndRun(sourceCode, 0, "L", bytes());
|
||||
compileAndRun(sourceCode, 0, "C", bytes(), map<string, Address>{{"L", m_contractAddress}});
|
||||
|
||||
@@ -39,7 +39,7 @@ bytes SolidityExecutionFramework::compileContract(
|
||||
// Silence compiler version warning
|
||||
std::string sourceCode = "pragma solidity >=0.0;\n";
|
||||
if (
|
||||
solidity::test::Options::get().useABIEncoderV2 &&
|
||||
solidity::test::CommonOptions::get().useABIEncoderV2 &&
|
||||
_sourceCode.find("pragma experimental ABIEncoderV2;") == std::string::npos
|
||||
)
|
||||
sourceCode += "pragma experimental ABIEncoderV2;\n";
|
||||
|
||||
@@ -31,7 +31,9 @@
|
||||
#include <libsolidity/ast/TypeProvider.h>
|
||||
#include <libsolidity/analysis/TypeChecker.h>
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity::evmasm;
|
||||
@@ -98,7 +100,7 @@ bytes compileFirstExpression(
|
||||
{
|
||||
ErrorList errors;
|
||||
ErrorReporter errorReporter(errors);
|
||||
sourceUnit = Parser(errorReporter, solidity::test::Options::get().evmVersion()).parse(
|
||||
sourceUnit = Parser(errorReporter, solidity::test::CommonOptions::get().evmVersion()).parse(
|
||||
make_shared<Scanner>(CharStream(_sourceCode, ""))
|
||||
);
|
||||
if (!sourceUnit)
|
||||
@@ -114,7 +116,7 @@ bytes compileFirstExpression(
|
||||
ErrorReporter errorReporter(errors);
|
||||
GlobalContext globalContext;
|
||||
map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes;
|
||||
NameAndTypeResolver resolver(globalContext, solidity::test::Options::get().evmVersion(), scopes, errorReporter);
|
||||
NameAndTypeResolver resolver(globalContext, solidity::test::CommonOptions::get().evmVersion(), scopes, errorReporter);
|
||||
resolver.registerDeclarations(*sourceUnit);
|
||||
|
||||
vector<ContractDefinition const*> inheritanceHierarchy;
|
||||
@@ -128,7 +130,7 @@ bytes compileFirstExpression(
|
||||
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
|
||||
{
|
||||
ErrorReporter errorReporter(errors);
|
||||
TypeChecker typeChecker(solidity::test::Options::get().evmVersion(), errorReporter);
|
||||
TypeChecker typeChecker(solidity::test::CommonOptions::get().evmVersion(), errorReporter);
|
||||
BOOST_REQUIRE(typeChecker.checkTypeRequirements(*contract));
|
||||
}
|
||||
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
|
||||
@@ -137,7 +139,7 @@ bytes compileFirstExpression(
|
||||
FirstExpressionExtractor extractor(*contract);
|
||||
BOOST_REQUIRE(extractor.expression() != nullptr);
|
||||
|
||||
CompilerContext context(solidity::test::Options::get().evmVersion());
|
||||
CompilerContext context(solidity::test::CommonOptions::get().evmVersion());
|
||||
context.resetVisitedNodes(contract);
|
||||
context.setInheritanceHierarchy(inheritanceHierarchy);
|
||||
unsigned parametersSize = _localVariables.size(); // assume they are all one slot on the stack
|
||||
@@ -151,7 +153,7 @@ bytes compileFirstExpression(
|
||||
ExpressionCompiler(
|
||||
context,
|
||||
RevertStrings::Default,
|
||||
solidity::test::Options::get().optimize
|
||||
solidity::test::CommonOptions::get().optimize
|
||||
).compile(*extractor.expression());
|
||||
|
||||
for (vector<string> const& function: _functions)
|
||||
@@ -282,7 +284,7 @@ BOOST_AUTO_TEST_CASE(comparison)
|
||||
bytes code = compileFirstExpression(sourceCode);
|
||||
|
||||
bytes expectation;
|
||||
if (solidity::test::Options::get().optimize)
|
||||
if (solidity::test::CommonOptions::get().optimize)
|
||||
expectation = {
|
||||
uint8_t(Instruction::PUSH2), 0x11, 0xaa,
|
||||
uint8_t(Instruction::PUSH2), 0x10, 0xaa,
|
||||
@@ -345,7 +347,7 @@ BOOST_AUTO_TEST_CASE(arithmetic)
|
||||
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}});
|
||||
|
||||
bytes expectation;
|
||||
if (solidity::test::Options::get().optimize)
|
||||
if (solidity::test::CommonOptions::get().optimize)
|
||||
expectation = {
|
||||
uint8_t(Instruction::PUSH1), 0x2,
|
||||
uint8_t(Instruction::PUSH1), 0x3,
|
||||
@@ -426,7 +428,7 @@ BOOST_AUTO_TEST_CASE(unary_operators)
|
||||
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}});
|
||||
|
||||
bytes expectation;
|
||||
if (solidity::test::Options::get().optimize)
|
||||
if (solidity::test::CommonOptions::get().optimize)
|
||||
expectation = {
|
||||
uint8_t(Instruction::DUP1),
|
||||
uint8_t(Instruction::PUSH1), 0x0,
|
||||
@@ -517,7 +519,7 @@ BOOST_AUTO_TEST_CASE(assignment)
|
||||
|
||||
// Stack: a, b
|
||||
bytes expectation;
|
||||
if (solidity::test::Options::get().optimize)
|
||||
if (solidity::test::CommonOptions::get().optimize)
|
||||
expectation = {
|
||||
uint8_t(Instruction::DUP1),
|
||||
uint8_t(Instruction::DUP3),
|
||||
@@ -629,7 +631,7 @@ BOOST_AUTO_TEST_CASE(selfbalance)
|
||||
|
||||
bytes code = compileFirstExpression(sourceCode, {}, {});
|
||||
|
||||
if (solidity::test::Options::get().evmVersion() == EVMVersion::istanbul())
|
||||
if (solidity::test::CommonOptions::get().evmVersion() == EVMVersion::istanbul())
|
||||
{
|
||||
bytes expectation({uint8_t(Instruction::SELFBALANCE)});
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end());
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <test/libsolidity/AnalysisFramework.h>
|
||||
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <libsolidity/ast/AST.h>
|
||||
|
||||
@@ -361,7 +361,7 @@ BOOST_AUTO_TEST_CASE(dynamic_return_types_not_possible)
|
||||
}
|
||||
}
|
||||
)";
|
||||
if (solidity::test::Options::get().evmVersion() == EVMVersion::homestead())
|
||||
if (solidity::test::CommonOptions::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);
|
||||
@@ -386,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 (!solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (!solidity::test::CommonOptions::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);
|
||||
}
|
||||
@@ -401,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 (!solidity::test::Options::get().evmVersion().hasCreate2())
|
||||
if (!solidity::test::CommonOptions::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);
|
||||
}
|
||||
@@ -416,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 (!solidity::test::Options::get().evmVersion().hasExtCodeHash())
|
||||
if (!solidity::test::CommonOptions::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);
|
||||
}
|
||||
@@ -452,7 +452,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall)
|
||||
}
|
||||
)";
|
||||
|
||||
if (solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
CHECK_SUCCESS_NO_WARNINGS(sourceCode);
|
||||
else
|
||||
CHECK_ERROR(sourceCode, TypeError, "\"staticcall\" is not supported by the VM version.");
|
||||
@@ -460,7 +460,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(address_staticcall_value)
|
||||
{
|
||||
if (solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract C {
|
||||
@@ -484,7 +484,7 @@ BOOST_AUTO_TEST_CASE(address_call_full_return_type)
|
||||
}
|
||||
)";
|
||||
|
||||
if (solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (solidity::test::CommonOptions::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.");
|
||||
@@ -501,7 +501,7 @@ BOOST_AUTO_TEST_CASE(address_delegatecall_full_return_type)
|
||||
}
|
||||
)";
|
||||
|
||||
if (solidity::test::Options::get().evmVersion().supportsReturndata())
|
||||
if (solidity::test::CommonOptions::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.");
|
||||
@@ -510,7 +510,7 @@ BOOST_AUTO_TEST_CASE(address_delegatecall_full_return_type)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(address_staticcall_full_return_type)
|
||||
{
|
||||
if (solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract C {
|
||||
|
||||
@@ -20,13 +20,15 @@
|
||||
* Unit tests for the solidity compiler JSON Interface output.
|
||||
*/
|
||||
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
#include <string>
|
||||
#include <libsolutil/JSON.h>
|
||||
#include <libsolidity/interface/CompilerStack.h>
|
||||
#include <liblangutil/Exceptions.h>
|
||||
#include <libsolutil/Exceptions.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace solidity::langutil;
|
||||
|
||||
namespace solidity::frontend::test
|
||||
@@ -44,7 +46,7 @@ public:
|
||||
{
|
||||
m_compilerStack.reset();
|
||||
m_compilerStack.setSources({{"", "pragma solidity >=0.0;\n" + _code}});
|
||||
m_compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
|
||||
m_compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
BOOST_REQUIRE_MESSAGE(m_compilerStack.parseAndAnalyze(), "Parsing contract failed");
|
||||
|
||||
Json::Value generatedDocumentation;
|
||||
@@ -65,7 +67,7 @@ public:
|
||||
{
|
||||
m_compilerStack.reset();
|
||||
m_compilerStack.setSources({{"", "pragma solidity >=0.0;\n" + _code}});
|
||||
m_compilerStack.setEVMVersion(solidity::test::Options::get().evmVersion());
|
||||
m_compilerStack.setEVMVersion(solidity::test::CommonOptions::get().evmVersion());
|
||||
BOOST_CHECK(!m_compilerStack.parseAndAnalyze());
|
||||
BOOST_REQUIRE(Error::containsErrorOfType(m_compilerStack.errors(), Error::Type::DocstringParsingError));
|
||||
}
|
||||
|
||||
@@ -25,10 +25,12 @@
|
||||
#include <liblangutil/Scanner.h>
|
||||
#include <libsolidity/parsing/Parser.h>
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
#include <test/libsolidity/ErrorCheck.h>
|
||||
#include <libsolidity/ast/ASTVisitor.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity::langutil;
|
||||
|
||||
@@ -42,7 +44,7 @@ ASTPointer<ContractDefinition> parseText(std::string const& _source, ErrorList&
|
||||
ErrorReporter errorReporter(_errors);
|
||||
ASTPointer<SourceUnit> sourceUnit = Parser(
|
||||
errorReporter,
|
||||
solidity::test::Options::get().evmVersion(),
|
||||
solidity::test::CommonOptions::get().evmVersion(),
|
||||
errorRecovery
|
||||
).parse(std::make_shared<Scanner>(CharStream(_source, "")));
|
||||
if (!sourceUnit)
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
*/
|
||||
|
||||
#include <test/libsolidity/SyntaxTest.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <test/libsolidity/AnalysisFramework.h>
|
||||
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
@@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(environment_access)
|
||||
"this",
|
||||
"address(1).balance",
|
||||
};
|
||||
if (solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
view.emplace_back("address(0x4242).staticcall(\"\")");
|
||||
|
||||
// ``block.blockhash`` and ``blockhash`` are tested separately below because their usage will
|
||||
@@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(address_staticcall)
|
||||
}
|
||||
}
|
||||
)";
|
||||
if (!solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (!solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
CHECK_ERROR(text, TypeError, "\"staticcall\" is not supported by the VM version.");
|
||||
else
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
@@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(assembly_staticcall)
|
||||
}
|
||||
}
|
||||
)";
|
||||
if (!solidity::test::Options::get().evmVersion().hasStaticCall())
|
||||
if (!solidity::test::CommonOptions::get().evmVersion().hasStaticCall())
|
||||
CHECK_ERROR(text, TypeError, "\"staticcall\" instruction is only available for Byzantium-compatible");
|
||||
else
|
||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <test/libsolidity/util/TestFileParser.h>
|
||||
|
||||
#include <test/libsolidity/util/BytesUtils.h>
|
||||
#include <test/Options.h>
|
||||
#include <test/Common.h>
|
||||
|
||||
#include <liblangutil/Common.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user