Option to show messages in tests.

This commit is contained in:
chriseth 2016-12-06 18:38:59 +01:00
parent b201e148fa
commit 86953ca3e4
4 changed files with 15 additions and 0 deletions

View File

@ -46,6 +46,7 @@ string getIPCSocketPath()
ExecutionFramework::ExecutionFramework() : ExecutionFramework::ExecutionFramework() :
m_rpc(RPCSession::instance(getIPCSocketPath())), m_rpc(RPCSession::instance(getIPCSocketPath())),
m_optimize(dev::test::Options::get().optimize), m_optimize(dev::test::Options::get().optimize),
m_showMessages(dev::test::Options::get().showMessages),
m_sender(m_rpc.account(0)) m_sender(m_rpc.account(0))
{ {
m_rpc.test_rewindToBlock(0); m_rpc.test_rewindToBlock(0);
@ -53,6 +54,13 @@ ExecutionFramework::ExecutionFramework() :
void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256 const& _value) void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256 const& _value)
{ {
if (m_showMessages)
{
if (_isCreation)
cout << "CREATE " << toHex(m_sender) << ": " << toHex(_data) << endl;
else
cout << "CALL " << toHex(m_sender) << " -> " << toHex(m_contractAddress) << ": " << toHex(_data) << endl;
}
RPCSession::TransactionData d; RPCSession::TransactionData d;
d.data = "0x" + toHex(_data); d.data = "0x" + toHex(_data);
d.from = "0x" + toString(m_sender); d.from = "0x" + toString(m_sender);
@ -79,6 +87,9 @@ void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256
m_output = fromHex(code, WhenError::Throw); m_output = fromHex(code, WhenError::Throw);
} }
if (m_showMessages)
cout << " -> " << toHex(m_output) << endl;
m_gasUsed = u256(receipt.gasUsed); m_gasUsed = u256(receipt.gasUsed);
m_logs.clear(); m_logs.clear();
for (auto const& log: receipt.logEntries) for (auto const& log: receipt.logEntries)

View File

@ -281,6 +281,7 @@ protected:
unsigned m_optimizeRuns = 200; unsigned m_optimizeRuns = 200;
bool m_optimize = false; bool m_optimize = false;
bool m_showMessages = false;
Address m_sender; Address m_sender;
Address m_contractAddress; Address m_contractAddress;
u256 const m_gasPrice = 100 * szabo; u256 const m_gasPrice = 100 * szabo;

View File

@ -41,6 +41,8 @@ Options::Options()
} }
else if (string(suite.argv[i]) == "--optimize") else if (string(suite.argv[i]) == "--optimize")
optimize = true; optimize = true;
else if (string(suite.argv[i]) == "--show-messages")
showMessages = true;
if (ipcPath.empty()) if (ipcPath.empty())
if (auto path = getenv("ETH_TEST_IPC")) if (auto path = getenv("ETH_TEST_IPC"))

View File

@ -106,6 +106,7 @@ namespace test
struct Options: boost::noncopyable struct Options: boost::noncopyable
{ {
std::string ipcPath; std::string ipcPath;
bool showMessages = false;
bool optimize = false; bool optimize = false;
static Options const& get(); static Options const& get();