mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
converted RLP test to a separate boost test case.
This commit is contained in:
parent
3b3ef76629
commit
84fd6bd28f
1
main.cpp
1
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.
|
||||||
|
37
rlp.cpp
37
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…
Reference in New Issue
Block a user