Merge pull request #3615 from ethereum/test-framework

Simplify contract compilation in the test framework
This commit is contained in:
chriseth
2018-02-28 16:35:22 +01:00
committed by GitHub
4 changed files with 18 additions and 23 deletions
+12 -2
View File
@@ -51,6 +51,17 @@ public:
bytes const& _arguments = bytes(),
std::map<std::string, dev::test::Address> const& _libraryAddresses = std::map<std::string, dev::test::Address>()
) override
{
bytes bytecode = compileContract(_sourceCode, _contractName, _libraryAddresses);
sendMessage(bytecode + _arguments, true, _value);
return m_output;
}
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>()
)
{
// Silence compiler version warning
std::string sourceCode = "pragma solidity >=0.0;\n" + _sourceCode;
@@ -72,8 +83,7 @@ public:
}
eth::LinkerObject obj = m_compiler.object(_contractName.empty() ? m_compiler.lastContractName() : _contractName);
BOOST_REQUIRE(obj.linkReferences.empty());
sendMessage(obj.bytecode + _arguments, true, _value);
return m_output;
return obj.bytecode;
}
protected: