mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Move unit test to new boost framework.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include "Serializer.h"
|
||||
@@ -665,7 +666,9 @@ static std::vector<unsigned char>IntToVUC(int v)
|
||||
return vuc;
|
||||
}
|
||||
|
||||
bool SHAMap::TestSHAMap()
|
||||
BOOST_AUTO_TEST_SUITE(shamap)
|
||||
|
||||
BOOST_AUTO_TEST_CASE( SHAMap_test )
|
||||
{ // h3 and h4 differ only in the leaf, same terminal node (level 19)
|
||||
uint256 h1, h2, h3, h4, h5;
|
||||
h1.SetHex("092891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7");
|
||||
@@ -677,16 +680,8 @@ bool SHAMap::TestSHAMap()
|
||||
SHAMap sMap;
|
||||
SHAMapItem i1(h1, IntToVUC(1)), i2(h2, IntToVUC(2)), i3(h3, IntToVUC(3)), i4(h4, IntToVUC(4)), i5(h5, IntToVUC(5));
|
||||
|
||||
if(!sMap.addItem(i2, true))
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
if(!sMap.addItem(i1, true))
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
if(!sMap.addItem(i2, true)) BOOST_FAIL("no add");
|
||||
if(!sMap.addItem(i1, true)) BOOST_FAIL("no add");
|
||||
|
||||
SHAMapItem::pointer i;
|
||||
|
||||
@@ -710,8 +705,8 @@ bool SHAMap::TestSHAMap()
|
||||
i=sMap.peekNextItem(i->getTag());
|
||||
assert(!i);
|
||||
|
||||
if(!syncTest())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END();
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stack>
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <openssl/rand.h>
|
||||
#include <iostream>
|
||||
@@ -358,7 +359,9 @@ std::list<std::vector<unsigned char> > SHAMap::getTrustedPath(const uint256& ind
|
||||
return path;
|
||||
}
|
||||
|
||||
bool SHAMap::syncTest()
|
||||
BOOST_AUTO_TEST_SUITE( SHAMapSync )
|
||||
|
||||
BOOST_AUTO_TEST_CASE( SHAMapSync_test )
|
||||
{
|
||||
unsigned int seed;
|
||||
RAND_pseudo_bytes(reinterpret_cast<unsigned char *>(&seed), sizeof(seed));
|
||||
@@ -375,7 +378,7 @@ bool SHAMap::syncTest()
|
||||
#ifdef DEBUG
|
||||
std::cerr << "Adding items, then removing them" << std::endl;
|
||||
#endif
|
||||
if(!confuseMap(source, 500)) return false;
|
||||
if(!confuseMap(source, 500)) BOOST_FAIL("ConfuseMap");
|
||||
|
||||
source.setImmutable();
|
||||
|
||||
@@ -398,20 +401,17 @@ bool SHAMap::syncTest()
|
||||
if (!source.getNodeFat(SHAMapNode(), nodeIDs, gotNodes))
|
||||
{
|
||||
std::cerr << "GetNodeFat(root) fails" << std::endl;
|
||||
assert(false);
|
||||
return false;
|
||||
BOOST_FAIL("GetNodeFat");
|
||||
}
|
||||
if (gotNodes.size() != 1)
|
||||
{
|
||||
std::cerr << "Didn't get root node " << gotNodes.size() << std::endl;
|
||||
assert(false);
|
||||
return false;
|
||||
BOOST_FAIL("NodeSize");
|
||||
}
|
||||
if (!destination.addRootNode(*gotNodes.begin()))
|
||||
{
|
||||
std::cerr << "AddRootNode fails" << std::endl;
|
||||
assert(false);
|
||||
return false;
|
||||
BOOST_FAIL("AddRootNode");
|
||||
}
|
||||
nodeIDs.clear();
|
||||
gotNodes.clear();
|
||||
@@ -441,8 +441,7 @@ bool SHAMap::syncTest()
|
||||
if (!source.getNodeFat(*nodeIDIterator, gotNodeIDs, gotNodes))
|
||||
{
|
||||
std::cerr << "GetNodeFat fails" << std::endl;
|
||||
assert(false);
|
||||
return false;
|
||||
BOOST_FAIL("GetNodeFat");
|
||||
}
|
||||
assert(gotNodeIDs.size() == gotNodes.size());
|
||||
nodeIDs.clear();
|
||||
@@ -451,8 +450,7 @@ bool SHAMap::syncTest()
|
||||
if (gotNodeIDs.empty())
|
||||
{
|
||||
std::cerr << "No nodes gotten" << std::endl;
|
||||
assert(false);
|
||||
return false;
|
||||
BOOST_FAIL("Got Node ID");
|
||||
}
|
||||
|
||||
#ifdef SMS_DEBUG
|
||||
@@ -468,8 +466,7 @@ bool SHAMap::syncTest()
|
||||
if (!destination.addKnownNode(*nodeIDIterator, *rawNodeIterator))
|
||||
{
|
||||
std::cerr << "AddKnownNode fails" << std::endl;
|
||||
assert(false);
|
||||
return false;
|
||||
BOOST_FAIL("AddKnownNode");
|
||||
}
|
||||
}
|
||||
gotNodeIDs.clear();
|
||||
@@ -487,8 +484,7 @@ bool SHAMap::syncTest()
|
||||
if (!source.deepCompare(destination))
|
||||
{
|
||||
std::cerr << "DeepCompare fails" << std::endl;
|
||||
assert(false);
|
||||
return false;
|
||||
BOOST_FAIL("Deep Compare");
|
||||
}
|
||||
|
||||
#ifdef SMS_DEBUG
|
||||
@@ -496,5 +492,8 @@ bool SHAMap::syncTest()
|
||||
passes << " passes, " << nodes << " nodes" << std::endl;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END();
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
Reference in New Issue
Block a user