mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix test framework after change to Transaction.
This commit is contained in:
parent
3e73402ba3
commit
849ccb4159
@ -39,39 +39,56 @@ namespace test
|
|||||||
class ExecutionFramework
|
class ExecutionFramework
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExecutionFramework() { g_logVerbosity = 0; }
|
ExecutionFramework(): m_executive(m_state) { g_logVerbosity = 0; }
|
||||||
|
|
||||||
bytes compileAndRun(std::string const& _sourceCode)
|
bytes compileAndRun(std::string const& _sourceCode)
|
||||||
{
|
{
|
||||||
bytes code = dev::solidity::CompilerStack::compile(_sourceCode);
|
bytes code = dev::solidity::CompilerStack::compile(_sourceCode);
|
||||||
eth::Executive ex(m_state);
|
sendMessage(code, true);
|
||||||
BOOST_REQUIRE(!ex.create(Address(), 0, m_gasPrice, m_gas, &code, Address()));
|
m_contractAddress = m_executive.newAddress();
|
||||||
BOOST_REQUIRE(ex.go());
|
BOOST_REQUIRE(m_state.addressHasCode(m_contractAddress));
|
||||||
ex.finalize();
|
return m_output;
|
||||||
m_contractAddress = ex.newAddress();
|
|
||||||
return ex.out().toBytes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes callFunction(byte _index, bytes const& _data)
|
bytes callFunction(byte _index, bytes const& _data)
|
||||||
{
|
{
|
||||||
bytes data = bytes(1, _index) + _data;
|
sendMessage(bytes(1, _index) + _data, false);
|
||||||
eth::Executive ex(m_state);
|
return m_output;
|
||||||
BOOST_REQUIRE(!ex.call(m_contractAddress, Address(), 0, m_gasPrice, &data, m_gas, Address()));
|
|
||||||
BOOST_REQUIRE(ex.go());
|
|
||||||
ex.finalize();
|
|
||||||
return ex.out().toBytes();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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:
|
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;
|
Address m_contractAddress;
|
||||||
eth::State m_state;
|
eth::State m_state;
|
||||||
|
eth::Executive m_executive;
|
||||||
u256 const m_gasPrice = 100 * eth::szabo;
|
u256 const m_gasPrice = 100 * eth::szabo;
|
||||||
u256 const m_gas = 1000000;
|
u256 const m_gas = 1000000;
|
||||||
|
bytes m_output;
|
||||||
};
|
};
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(SolidityCompilerEndToEndTest)
|
BOOST_AUTO_TEST_SUITE(SolidityCompilerEndToEndTest)
|
||||||
|
Loading…
Reference in New Issue
Block a user