aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2014-11-06 00:50:59 +0800
committerChristian <c@ethdev.com>2014-11-06 01:10:37 +0800
commit849ccb41596ac77b429e8e33a98335cf59dfbbfa (patch)
tree6b89d9f901f284ad46f7aa330f597733afb9e94f
parent3e73402ba385182638a7730736244997dfd60e98 (diff)
downloaddexon-solidity-849ccb41596ac77b429e8e33a98335cf59dfbbfa.tar.gz
dexon-solidity-849ccb41596ac77b429e8e33a98335cf59dfbbfa.tar.zst
dexon-solidity-849ccb41596ac77b429e8e33a98335cf59dfbbfa.zip
Fix test framework after change to Transaction.
-rw-r--r--solidityEndToEndTest.cpp47
1 files changed, 32 insertions, 15 deletions
diff --git a/solidityEndToEndTest.cpp b/solidityEndToEndTest.cpp
index 7bb01fa1..5aeaf3e6 100644
--- a/solidityEndToEndTest.cpp
+++ b/solidityEndToEndTest.cpp
@@ -39,39 +39,56 @@ namespace test
class ExecutionFramework
{
public:
- ExecutionFramework() { g_logVerbosity = 0; }
+ ExecutionFramework(): m_executive(m_state) { g_logVerbosity = 0; }
bytes compileAndRun(std::string const& _sourceCode)
{
bytes code = dev::solidity::CompilerStack::compile(_sourceCode);
- eth::Executive ex(m_state);
- BOOST_REQUIRE(!ex.create(Address(), 0, m_gasPrice, m_gas, &code, Address()));
- BOOST_REQUIRE(ex.go());
- ex.finalize();
- m_contractAddress = ex.newAddress();
- return ex.out().toBytes();
+ sendMessage(code, true);
+ m_contractAddress = m_executive.newAddress();
+ BOOST_REQUIRE(m_state.addressHasCode(m_contractAddress));
+ return m_output;
}
bytes callFunction(byte _index, bytes const& _data)
{
- bytes data = bytes(1, _index) + _data;
- eth::Executive ex(m_state);
- BOOST_REQUIRE(!ex.call(m_contractAddress, Address(), 0, m_gasPrice, &data, m_gas, Address()));
- BOOST_REQUIRE(ex.go());
- ex.finalize();
- return ex.out().toBytes();
+ sendMessage(bytes(1, _index) + _data, false);
+ return m_output;
}
- bytes callFunction(byte _index, u256 const& _argument)
+ bytes callFunction(byte _index, u256 const& _argument1)
{
- return callFunction(_index, toBigEndian(_argument));
+ callFunction(_index, toBigEndian(_argument1));
+ return m_output;
}
private:
+ void sendMessage(bytes const& _data, bool _isCreation)
+ {
+ eth::Transaction t = _isCreation ? eth::Transaction(0, m_gasPrice, m_gas, _data)
+ : eth::Transaction(0, m_gasPrice, m_gas, m_contractAddress, _data);
+ bytes transactionRLP = t.rlp();
+ try
+ {
+ // this will throw since the transaction is invalid, but it should nevertheless store the transaction
+ m_executive.setup(&transactionRLP);
+ }
+ catch (...) {}
+ if (_isCreation)
+ BOOST_REQUIRE(!m_executive.create(Address(), 0, m_gasPrice, m_gas, &_data, Address()));
+ else
+ BOOST_REQUIRE(!m_executive.call(m_contractAddress, Address(), 0, m_gasPrice, &_data, m_gas, Address()));
+ BOOST_REQUIRE(m_executive.go());
+ m_executive.finalize();
+ m_output = m_executive.out().toBytes();
+ }
+
Address m_contractAddress;
eth::State m_state;
+ eth::Executive m_executive;
u256 const m_gasPrice = 100 * eth::szabo;
u256 const m_gas = 1000000;
+ bytes m_output;
};
BOOST_AUTO_TEST_SUITE(SolidityCompilerEndToEndTest)