mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #3615 from ethereum/test-framework
Simplify contract compilation in the test framework
This commit is contained in:
commit
fb8c4bd7c2
@ -220,13 +220,8 @@ protected:
|
|||||||
void deployRegistrar()
|
void deployRegistrar()
|
||||||
{
|
{
|
||||||
if (!s_compiledRegistrar)
|
if (!s_compiledRegistrar)
|
||||||
{
|
s_compiledRegistrar.reset(new bytes(compileContract(registrarCode, "GlobalRegistrar")));
|
||||||
m_compiler.reset(false);
|
|
||||||
m_compiler.addSource("", registrarCode);
|
|
||||||
m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns);
|
|
||||||
BOOST_REQUIRE_MESSAGE(m_compiler.compile(), "Compiling contract failed");
|
|
||||||
s_compiledRegistrar.reset(new bytes(m_compiler.object("GlobalRegistrar").bytecode));
|
|
||||||
}
|
|
||||||
sendMessage(*s_compiledRegistrar, true);
|
sendMessage(*s_compiledRegistrar, true);
|
||||||
BOOST_REQUIRE(!m_output.empty());
|
BOOST_REQUIRE(!m_output.empty());
|
||||||
}
|
}
|
||||||
|
@ -132,13 +132,8 @@ protected:
|
|||||||
void deployRegistrar()
|
void deployRegistrar()
|
||||||
{
|
{
|
||||||
if (!s_compiledRegistrar)
|
if (!s_compiledRegistrar)
|
||||||
{
|
s_compiledRegistrar.reset(new bytes(compileContract(registrarCode, "FixedFeeRegistrar")));
|
||||||
m_compiler.reset(false);
|
|
||||||
m_compiler.addSource("", registrarCode);
|
|
||||||
m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns);
|
|
||||||
BOOST_REQUIRE_MESSAGE(m_compiler.compile(), "Compiling contract failed");
|
|
||||||
s_compiledRegistrar.reset(new bytes(m_compiler.object("FixedFeeRegistrar").bytecode));
|
|
||||||
}
|
|
||||||
sendMessage(*s_compiledRegistrar, true);
|
sendMessage(*s_compiledRegistrar, true);
|
||||||
BOOST_REQUIRE(!m_output.empty());
|
BOOST_REQUIRE(!m_output.empty());
|
||||||
}
|
}
|
||||||
|
@ -447,13 +447,8 @@ protected:
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!s_compiledWallet)
|
if (!s_compiledWallet)
|
||||||
{
|
s_compiledWallet.reset(new bytes(compileContract(walletCode, "Wallet")));
|
||||||
m_compiler.reset(false);
|
|
||||||
m_compiler.addSource("", walletCode);
|
|
||||||
m_compiler.setOptimiserSettings(m_optimize, m_optimizeRuns);
|
|
||||||
BOOST_REQUIRE_MESSAGE(m_compiler.compile(), "Compiling contract failed");
|
|
||||||
s_compiledWallet.reset(new bytes(m_compiler.object("Wallet").bytecode));
|
|
||||||
}
|
|
||||||
bytes args = encodeArgs(u256(0x60), _required, _dailyLimit, u256(_owners.size()), _owners);
|
bytes args = encodeArgs(u256(0x60), _required, _dailyLimit, u256(_owners.size()), _owners);
|
||||||
sendMessage(*s_compiledWallet + args, true, _value);
|
sendMessage(*s_compiledWallet + args, true, _value);
|
||||||
BOOST_REQUIRE(!m_output.empty());
|
BOOST_REQUIRE(!m_output.empty());
|
||||||
|
@ -51,6 +51,17 @@ public:
|
|||||||
bytes const& _arguments = bytes(),
|
bytes const& _arguments = bytes(),
|
||||||
std::map<std::string, dev::test::Address> const& _libraryAddresses = std::map<std::string, dev::test::Address>()
|
std::map<std::string, dev::test::Address> const& _libraryAddresses = std::map<std::string, dev::test::Address>()
|
||||||
) override
|
) 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
|
// Silence compiler version warning
|
||||||
std::string sourceCode = "pragma solidity >=0.0;\n" + _sourceCode;
|
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);
|
eth::LinkerObject obj = m_compiler.object(_contractName.empty() ? m_compiler.lastContractName() : _contractName);
|
||||||
BOOST_REQUIRE(obj.linkReferences.empty());
|
BOOST_REQUIRE(obj.linkReferences.empty());
|
||||||
sendMessage(obj.bytecode + _arguments, true, _value);
|
return obj.bytecode;
|
||||||
return m_output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
Reference in New Issue
Block a user