aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-02-28 23:35:22 +0800
committerGitHub <noreply@github.com>2018-02-28 23:35:22 +0800
commitfb8c4bd7c2bfea7eb33116cac79789cb1c08e3d9 (patch)
tree6045939ffcd888e7ea738ba02e2af8846a5bea5f /test
parent22d26e059c46274d572403a9528cd24e8d4de867 (diff)
parent0346f723422698158b4d5d9b4d7737d185cd8e52 (diff)
downloaddexon-solidity-fb8c4bd7c2bfea7eb33116cac79789cb1c08e3d9.tar
dexon-solidity-fb8c4bd7c2bfea7eb33116cac79789cb1c08e3d9.tar.gz
dexon-solidity-fb8c4bd7c2bfea7eb33116cac79789cb1c08e3d9.tar.bz2
dexon-solidity-fb8c4bd7c2bfea7eb33116cac79789cb1c08e3d9.tar.lz
dexon-solidity-fb8c4bd7c2bfea7eb33116cac79789cb1c08e3d9.tar.xz
dexon-solidity-fb8c4bd7c2bfea7eb33116cac79789cb1c08e3d9.tar.zst
dexon-solidity-fb8c4bd7c2bfea7eb33116cac79789cb1c08e3d9.zip
Merge pull request #3615 from ethereum/test-framework
Simplify contract compilation in the test framework
Diffstat (limited to 'test')
-rw-r--r--test/contracts/AuctionRegistrar.cpp9
-rw-r--r--test/contracts/FixedFeeRegistrar.cpp9
-rw-r--r--test/contracts/Wallet.cpp9
-rw-r--r--test/libsolidity/SolidityExecutionFramework.h14
4 files changed, 18 insertions, 23 deletions
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index c9c744af..5e4991e2 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -220,13 +220,8 @@ protected:
void deployRegistrar()
{
if (!s_compiledRegistrar)
- {
- 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));
- }
+ s_compiledRegistrar.reset(new bytes(compileContract(registrarCode, "GlobalRegistrar")));
+
sendMessage(*s_compiledRegistrar, true);
BOOST_REQUIRE(!m_output.empty());
}
diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp
index 8327999d..a3a27c37 100644
--- a/test/contracts/FixedFeeRegistrar.cpp
+++ b/test/contracts/FixedFeeRegistrar.cpp
@@ -132,13 +132,8 @@ protected:
void deployRegistrar()
{
if (!s_compiledRegistrar)
- {
- 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));
- }
+ s_compiledRegistrar.reset(new bytes(compileContract(registrarCode, "FixedFeeRegistrar")));
+
sendMessage(*s_compiledRegistrar, true);
BOOST_REQUIRE(!m_output.empty());
}
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index 90334ad6..1031e8f1 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -447,13 +447,8 @@ protected:
)
{
if (!s_compiledWallet)
- {
- 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));
- }
+ s_compiledWallet.reset(new bytes(compileContract(walletCode, "Wallet")));
+
bytes args = encodeArgs(u256(0x60), _required, _dailyLimit, u256(_owners.size()), _owners);
sendMessage(*s_compiledWallet + args, true, _value);
BOOST_REQUIRE(!m_output.empty());
diff --git a/test/libsolidity/SolidityExecutionFramework.h b/test/libsolidity/SolidityExecutionFramework.h
index b853d558..f562721d 100644
--- a/test/libsolidity/SolidityExecutionFramework.h
+++ b/test/libsolidity/SolidityExecutionFramework.h
@@ -52,6 +52,17 @@ public:
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;
m_compiler.reset(false);
@@ -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: