|
|
@ -24,16 +24,16 @@ |
|
|
|
#include "JsonSpiritHeaders.h" |
|
|
|
#include <Log.h> |
|
|
|
#include <RLP.h> |
|
|
|
#include <boost/test/unit_test.hpp> |
|
|
|
|
|
|
|
using namespace std; |
|
|
|
using namespace eth; |
|
|
|
namespace js = json_spirit; |
|
|
|
|
|
|
|
namespace eth |
|
|
|
{ |
|
|
|
|
|
|
|
template <> class UnitTest<2> |
|
|
|
namespace test |
|
|
|
{ |
|
|
|
public: |
|
|
|
static void buildRLP(js::mValue& _v, RLPStream& _rlp) |
|
|
|
{ |
|
|
|
if (_v.type() == js::array_type) |
|
|
@ -54,36 +54,29 @@ public: |
|
|
|
_rlp.append(s); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int operator()() |
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(rlp_test) |
|
|
|
{ |
|
|
|
cnote << "Testing RLP..."; |
|
|
|
js::mValue v; |
|
|
|
string s = asString(contents("../../tests/rlptest.json")); |
|
|
|
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'rlptest.json' is empty. Have you cloned the 'tests' repo branch develop?"); |
|
|
|
js::read_string(s, v); |
|
|
|
bool passed = true; |
|
|
|
for (auto& i: v.get_obj()) |
|
|
|
{ |
|
|
|
js::mObject& o = i.second.get_obj(); |
|
|
|
cnote << i.first; |
|
|
|
RLPStream s; |
|
|
|
buildRLP(o["in"], s); |
|
|
|
if (!o["out"].is_null() && o["out"].get_str() != toHex(s.out())) |
|
|
|
{ |
|
|
|
cwarn << "Test failed."; |
|
|
|
cwarn << "Test says:" << o["out"].get_str(); |
|
|
|
cwarn << "Impl says:" << toHex(s.out()); |
|
|
|
passed = false; |
|
|
|
eth::test::buildRLP(o["in"], s); |
|
|
|
BOOST_REQUIRE(!o["out"].is_null()); |
|
|
|
BOOST_CHECK(o["out"].get_str() == toHex(s.out()) ); |
|
|
|
} |
|
|
|
} |
|
|
|
return passed ? 0 : 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int rlpTest() |
|
|
|
{ |
|
|
|
cnote << "Testing RLP..."; |
|
|
|
return UnitTest<2>()(); |
|
|
|
} |
|
|
|
|
|
|
|