Merge pull request #6534 from ethereum/reuseLiteralContent-6472

Re-produce the original 'useLiteralContent' setting
This commit is contained in:
chriseth 2019-04-17 15:41:55 +02:00 committed by GitHub
commit 922ab0d72d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 1 deletions

View File

@ -11,6 +11,7 @@ Language Features:
Compiler Features:
* ABI Decoder: Raise a runtime error on dirty inputs when using the experimental decoder.
* Standartd JSON Interface: Metadata settings now re-produce the original 'useLiteralContent' setting from the compilation input.
* SMTChecker: Support arithmetic compound assignment operators.
* SMTChecker: Support unary increment and decrement for array and mapping access.
* SMTChecker: Show unsupported warning for inline assembly blocks.

View File

@ -92,7 +92,9 @@ explanatory purposes.
// Required for Solidity: Addresses for libraries used
libraries: {
"MyLib": "0x123123..."
}
},
// Reflects the setting used in the input json, defaults to false
"useLiteralContent": false
},
// Required: Generated information about the contract.
output:

View File

@ -1067,6 +1067,7 @@ string CompilerStack::createMetadata(Contract const& _contract) const
meta["settings"]["optimizer"]["details"] = std::move(details);
}
meta["settings"]["useLiteralContent"] = m_metadataLiteralSources;
meta["settings"]["evmVersion"] = m_evmVersion.name();
meta["settings"]["compilationTarget"][_contract.contract->sourceUnitName()] =
_contract.contract->annotation().canonicalName;

View File

@ -177,6 +177,37 @@ BOOST_AUTO_TEST_CASE(metadata_relevant_sources_imports)
BOOST_CHECK(metadata["sources"].isMember("C"));
}
BOOST_AUTO_TEST_CASE(metadata_useLiteralContent)
{
// Check that the metadata contains "useLiteralContent"
char const* sourceCode = R"(
pragma solidity >=0.0;
contract test {
}
)";
auto check = [](char const* _src, bool _check)
{
CompilerStack compilerStack;
compilerStack.setSources({{"", std::string(_src)}});
compilerStack.setEVMVersion(dev::test::Options::get().evmVersion());
compilerStack.setOptimiserSettings(dev::test::Options::get().optimize);
compilerStack.useMetadataLiteralSources(_check);
BOOST_REQUIRE_MESSAGE(compilerStack.compile(), "Compiling contract failed");
string metadata_str = compilerStack.metadata("test");
Json::Value metadata;
jsonParse(metadata_str, metadata);
BOOST_CHECK(metadata.isMember("settings"));
BOOST_CHECK(metadata["settings"].isMember("useLiteralContent"));
BOOST_CHECK(_check == metadata["settings"]["useLiteralContent"].asBool());
BOOST_CHECK(dev::test::isValidMetadata(metadata_str));
};
check(sourceCode, true);
check(sourceCode, false);
}
BOOST_AUTO_TEST_SUITE_END()
}