aboutsummaryrefslogtreecommitdiffstats
path: root/test/ExecutionFramework.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/ExecutionFramework.cpp')
-rw-r--r--test/ExecutionFramework.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ExecutionFramework.cpp b/test/ExecutionFramework.cpp
index b2de814a..85b5bd3b 100644
--- a/test/ExecutionFramework.cpp
+++ b/test/ExecutionFramework.cpp
@@ -25,6 +25,8 @@
#include <libdevcore/CommonIO.h>
#include <test/ExecutionFramework.h>
+#include <boost/algorithm/string/replace.hpp>
+
using namespace std;
using namespace dev;
using namespace dev::test;
@@ -54,6 +56,32 @@ ExecutionFramework::ExecutionFramework() :
m_rpc.test_rewindToBlock(0);
}
+std::pair<bool, string> ExecutionFramework::compareAndCreateMessage(
+ bytes const& _result,
+ bytes const& _expectation
+)
+{
+ if (_result == _expectation)
+ return std::make_pair(true, std::string{});
+ std::string message =
+ "Invalid encoded data\n"
+ " Result Expectation\n";
+ auto resultHex = boost::replace_all_copy(toHex(_result), "0", ".");
+ auto expectedHex = boost::replace_all_copy(toHex(_expectation), "0", ".");
+ for (size_t i = 0; i < std::max(resultHex.size(), expectedHex.size()); i += 0x40)
+ {
+ std::string result{i >= resultHex.size() ? string{} : resultHex.substr(i, 0x40)};
+ std::string expected{i > expectedHex.size() ? string{} : expectedHex.substr(i, 0x40)};
+ message +=
+ (result == expected ? " " : " X ") +
+ result +
+ std::string(0x41 - result.size(), ' ') +
+ expected +
+ "\n";
+ }
+ return make_pair(false, message);
+}
+
void ExecutionFramework::sendMessage(bytes const& _data, bool _isCreation, u256 const& _value)
{
if (m_showMessages)