Browse Source

converted RLP test to a separate boost test case.

cl-refactor
Carl Allendorph 11 years ago
parent
commit
c7a1c2b0d2
  1. 1
      test/main.cpp
  2. 35
      test/rlp.cpp

1
test/main.cpp

@ -46,7 +46,6 @@ BOOST_AUTO_TEST_CASE(basic_tests)
int r = 0; int r = 0;
r += hexPrefixTest(); r += hexPrefixTest();
r += rlpTest();
r += trieTest(); r += trieTest();
r += vmTest(); r += vmTest();
r += cryptoTest(); // TODO: Put in tests repo. r += cryptoTest(); // TODO: Put in tests repo.

35
test/rlp.cpp

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

Loading…
Cancel
Save