diff options
author | chriseth <chris@ethereum.org> | 2017-10-18 20:53:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-18 20:53:45 +0800 |
commit | 9cf6e910bd2b90d0c9415d9c257f85fe0c518de8 (patch) | |
tree | 6423baec5e26bbe174005c1a89d978cae15015d8 /test/ExecutionFramework.cpp | |
parent | bdeb9e52a2211510644fb53df93fb98258b40a65 (diff) | |
parent | c85c41880ad1c996517b0ae14f98678b1e6c5613 (diff) | |
download | dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar.gz dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar.bz2 dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar.lz dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar.xz dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.tar.zst dexon-solidity-9cf6e910bd2b90d0c9415d9c257f85fe0c518de8.zip |
Merge pull request #3099 from ethereum/develop
Merge develop into release for 0.4.18.
Diffstat (limited to 'test/ExecutionFramework.cpp')
-rw-r--r-- | test/ExecutionFramework.cpp | 28 |
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) |