Browse Source

Error logs

cl-refactor
Dimitry 9 years ago
parent
commit
fde97e186c
  1. 44
      test/TestHelper.cpp
  2. 5
      test/TestHelper.h
  3. 57
      test/boostTest.cpp
  4. 5
      test/fuzzTesting/fuzzHelper.cpp
  5. 25
      test/libdevcore/rlp.cpp
  6. 14
      test/libdevcrypto/AES.cpp
  7. 2
      test/libdevcrypto/hexPrefix.cpp
  8. 100
      test/libdevcrypto/trie.cpp
  9. 2
      test/libethcore/dagger.cpp
  10. 4
      test/libethereum/genesis.cpp
  11. 22
      test/libethereum/state.cpp
  12. 2
      test/libethereum/stateOriginal.cpp
  13. 40
      test/libethereum/transactionTests.cpp
  14. 15
      test/libevm/vm.cpp
  15. 2
      test/libevm/vm.h
  16. 4
      test/libp2p/capability.cpp
  17. 10
      test/libp2p/peer.cpp
  18. 4
      test/libsolidity/solidityExecutionFramework.h
  19. 12
      test/libwhisper/bloomFilter.cpp
  20. 20
      test/libwhisper/whisperDB.cpp
  21. 7
      test/libwhisper/whisperMessage.cpp
  22. 8
      test/libwhisper/whisperTopic.cpp

44
test/TestHelper.cpp

@ -253,15 +253,15 @@ void ImportTest::importTransaction(json_spirit::mObject const& o_tr)
importTransaction(o_tr, m_transaction);
}
void ImportTest::compareStates(State const& _stateExpect, State const& _statePost, AccountMaskMap const _expectedStateOptions, WhenError _throw)
int ImportTest::compareStates(State const& _stateExpect, State const& _statePost, AccountMaskMap const _expectedStateOptions, WhenError _throw)
{
#define CHECK(a,b) \
{ \
if (_throw == WhenError::Throw) \
{ \
TBOOST_CHECK(a); \
TBOOST_CHECK_MESSAGE(a, b); \
if (!a) \
std::cerr << b << std::endl;\
return 1; \
} \
else \
{TBOOST_WARN_MESSAGE(a,b);} \
@ -313,20 +313,26 @@ void ImportTest::compareStates(State const& _stateExpect, State const& _statePos
"Check State: " << a.first << ": incorrect code '" << toHex(_statePost.code(a.first)) << "', expected '" << toHex(_stateExpect.code(a.first)) << "'");
}
}
return 0;
}
void ImportTest::exportTest(bytes const& _output)
int ImportTest::exportTest(bytes const& _output)
{
// export output
m_testObject["out"] = (_output.size() > 4096 && !Options::get().fulloutput) ? "#" + toString(_output.size()) : toHex(_output, 2, HexPrefix::Add);
int err = 0;
// export output
m_TestObject["out"] = (_output.size() > 4096 && !Options::get().fulloutput) ? "#" + toString(_output.size()) : toHex(_output, 2, HexPrefix::Add);
// compare expected output with post output
if (m_testObject.count("expectOut") > 0)
{
std::string warning = "Check State: Error! Unexpected output: " + m_testObject["out"].get_str() + " Expected: " + m_testObject["expectOut"].get_str();
if (Options::get().checkState)
{TBOOST_CHECK_MESSAGE((m_testObject["out"].get_str() == m_testObject["expectOut"].get_str()), warning);}
{
bool statement = (m_testObject["out"].get_str() == m_testObject["expectOut"].get_str());
TBOOST_CHECK_MESSAGE(statement, warning);
if (!statement)
err = 1;
}
else
TBOOST_WARN_MESSAGE((m_testObject["out"].get_str() == m_testObject["expectOut"].get_str()), warning);
@ -354,6 +360,7 @@ void ImportTest::exportTest(bytes const& _output)
m_testObject["pre"] = fillJsonWithState(m_statePre);
m_testObject["env"] = makeAllFieldsHex(m_testObject["env"].get_obj());
m_testObject["transaction"] = makeAllFieldsHex(m_testObject["transaction"].get_obj());
return err;
}
json_spirit::mObject fillJsonWithTransaction(Transaction _txn)
@ -570,7 +577,10 @@ void userDefinedTest(std::function<void(json_spirit::mValue&, bool)> doTests)
auto& filename = Options::get().singleTestFile;
auto& testname = Options::get().singleTestName;
VerbosityHolder sentinel(12);
if (g_logVerbosity != -1)
VerbosityHolder sentinel(12);
try
{
cnote << "Testing user defined test: " << filename;
@ -635,7 +645,7 @@ void executeTests(const string& _name, const string& _testPathAppendix, const bo
try
{
std::cout << "TEST " << _name << ":\n";
cnote << "TEST " << _name << ":";
json_spirit::mValue v;
string s = asString(dev::contents(testPath + "/" + _name + ".json"));
TBOOST_REQUIRE_MESSAGE((s.length() > 0), "Contents of " + testPath + "/" + _name + ".json is empty. Have you cloned the 'tests' repo branch develop and set ETHEREUM_TEST_PATH to its path?");
@ -779,16 +789,16 @@ Options::Options()
fulloutput = true;
else if (arg == "--verbosity" && i + 1 < argc)
{
static std::ostringstream strCout;
std::string depthLevel = std::string{argv[i + 1]};
if (depthLevel == "0")
static std::ostringstream strCout; //static string to redirect logs to
std::string indentLevel = std::string{argv[i + 1]};
if (indentLevel == "0")
{
logVerbosity = Verbosity::None;
std::cout.rdbuf( strCout.rdbuf() );
std::cerr.rdbuf( strCout.rdbuf() );
std::cout.rdbuf(strCout.rdbuf());
std::cerr.rdbuf(strCout.rdbuf());
}
else
if (depthLevel == "1")
if (indentLevel == "1")
logVerbosity = Verbosity::NiceReport;
else
logVerbosity = Verbosity::Full;
@ -797,7 +807,7 @@ Options::Options()
//Default option
if (logVerbosity == Verbosity::NiceReport)
g_logVerbosity = -1; //disable cnote but not the cerr
g_logVerbosity = -1; //disable cnote but leave cerr and cout
}
Options const& Options::get()

5
test/TestHelper.h

@ -22,7 +22,6 @@
#pragma once
#include <functional>
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
@ -143,8 +142,8 @@ public:
static json_spirit::mObject& makeAllFieldsHex(json_spirit::mObject& _o);
bytes executeTest();
void exportTest(bytes const& _output);
static void compareStates(eth::State const& _stateExpect, eth::State const& _statePost, eth::AccountMaskMap const _expectedStateOptions = eth::AccountMaskMap(), WhenError _throw = WhenError::Throw);
int exportTest(bytes const& _output);
static int compareStates(eth::State const& _stateExpect, eth::State const& _statePost, eth::AccountMaskMap const _expectedStateOptions = eth::AccountMaskMap(), WhenError _throw = WhenError::Throw);
eth::State m_statePre;
eth::State m_statePost;

57
test/boostTest.cpp

@ -24,5 +24,62 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#define BOOST_DISABLE_WIN32 //disables SEH warning
#define BOOST_TEST_NO_MAIN
#include <boost/test/included/unit_test.hpp>
#pragma GCC diagnostic pop
#include <test/TestHelper.h>
using namespace boost::unit_test;
//Custom Boost Initialization
test_suite* init_func( int argc, char* argv[] )
{
if (argc == 0)
argv[1]=(char*)"a";
dev::test::Options::get();
return 0;
}
//Custom Boost Unit Test Main
int main( int argc, char* argv[] )
{
try {
framework::init( init_func, argc, argv );
if( !runtime_config::test_to_run().is_empty() ) {
test_case_filter filter( runtime_config::test_to_run() );
traverse_test_tree( framework::master_test_suite().p_id, filter );
}
framework::run();
results_reporter::make_report();
return runtime_config::no_result_code()
? boost::exit_success
: results_collector.results( framework::master_test_suite().p_id ).result_code();
}
catch( framework::nothing_to_test const& ) {
return boost::exit_success;
}
catch( framework::internal_error const& ex ) {
results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl;
return boost::exit_exception_failure;
}
catch( framework::setup_error const& ex ) {
results_reporter::get_stream() << "Test setup error: " << ex.what() << std::endl;
return boost::exit_exception_failure;
}
catch( ... ) {
results_reporter::get_stream() << "Boost.Test framework internal error: unknown reason" << std::endl;
return boost::exit_exception_failure;
}
return 0;
}

5
test/fuzzTesting/fuzzHelper.cpp

@ -402,13 +402,12 @@ void RandomCodeOptions::setWeights()
opCodeProbability = boostDescreteDistrib(weights);
}
BOOST_AUTO_TEST_SUITE(RandomCodeTests)
BOOST_AUTO_TEST_CASE(rndCode)
{
std::string code;
std::cout << "Testing Random Code: ";
cnote << "Testing Random Code: ";
try
{
code = dev::test::RandomCode::generate(10);
@ -417,7 +416,7 @@ BOOST_AUTO_TEST_CASE(rndCode)
{
BOOST_ERROR("Exception thrown when generating random code!");
}
std::cout << code;
cnote << code;
}
BOOST_AUTO_TEST_SUITE_END()

25
test/libdevcore/rlp.cpp

@ -52,6 +52,7 @@ namespace dev
void doRlpTests(json_spirit::mValue& v, bool _fillin)
{
string testname;
for (auto& i: v.get_obj())
{
js::mObject& o = i.second.get_obj();
@ -61,9 +62,11 @@ namespace dev
continue;
}
cout << " " << i.first << endl;
TBOOST_REQUIRE((o.count("out") > 0));
TBOOST_REQUIRE((!o["out"].is_null()));
cnote << " " << i.first;
testname = "(" + i.first + ") ";
TBOOST_REQUIRE_MESSAGE((o.count("out") > 0), testname + "out not set!");
TBOOST_REQUIRE_MESSAGE((!o["out"].is_null()), testname + "out is set to null!");
if (_fillin)
{
@ -88,7 +91,7 @@ namespace dev
else
{
//Check Encode
TBOOST_REQUIRE((o.count("in") > 0));
TBOOST_REQUIRE_MESSAGE((o.count("in") > 0), testname + "in not set!");
RlpType rlpType = RlpType::Test;
if (o["in"].type() == js::str_type)
{
@ -112,7 +115,7 @@ namespace dev
msg << " But Computed: " << computedText;
TBOOST_CHECK_MESSAGE(
(expectedText == computedText),
msg.str()
testname + msg.str()
);
}
@ -155,11 +158,11 @@ namespace dev
//Check that there was an exception as input is INVALID
if (rlpType == RlpType::Invalid && !was_exception)
TBOOST_ERROR("Expected RLP Exception as rlp should be invalid!");
TBOOST_ERROR(testname + "Expected RLP Exception as rlp should be invalid!");
//input is VALID check that there was no exceptions
if (was_exception)
TBOOST_ERROR("Unexpected RLP Exception!");
TBOOST_ERROR(testname + "Unexpected RLP Exception!");
}
}
}
@ -256,11 +259,11 @@ BOOST_AUTO_TEST_CASE(EmptyArrayList)
}
catch (Exception const& _e)
{
TBOOST_ERROR("Failed test with Exception: " << _e.what());
TBOOST_ERROR("(EmptyArrayList) Failed test with Exception: " << _e.what());
}
catch (exception const& _e)
{
TBOOST_ERROR("Failed test with Exception: " << _e.what());
TBOOST_ERROR("(EmptyArrayList) Failed test with Exception: " << _e.what());
}
}
@ -302,11 +305,11 @@ BOOST_AUTO_TEST_CASE(rlpRandom)
catch (Exception const& _e)
{
TBOOST_ERROR("Failed test with Exception: " << diagnostic_information(_e));
TBOOST_ERROR(path.filename().string() + "Failed test with Exception: " << diagnostic_information(_e));
}
catch (std::exception const& _e)
{
TBOOST_ERROR("Failed test with Exception: " << _e.what());
TBOOST_ERROR(path.filename().string() + "Failed test with Exception: " << _e.what());
}
}
}

14
test/libdevcrypto/AES.cpp

@ -25,6 +25,7 @@
#include <libdevcore/SHA3.h>
#include <libdevcrypto/AES.h>
#include <libdevcore/FixedHash.h>
#include <test/TestHelper.h>
using namespace std;
using namespace dev;
@ -33,7 +34,7 @@ BOOST_AUTO_TEST_SUITE(AES)
BOOST_AUTO_TEST_CASE(AesDecrypt)
{
cout << "AesDecrypt" << endl;
cnote << "AesDecrypt";
bytes seed = fromHex("2dbaead416c20cfd00c2fc9f1788ff9f965a2000799c96a624767cb0e1e90d2d7191efdd92349226742fdc73d1d87e2d597536c4641098b9a89836c94f58a2ab4c525c27c4cb848b3e22ea245b2bc5c8c7beaa900b0c479253fc96fce7ffc621");
KeyPair kp(sha3Secure(aesDecrypt(&seed, "test")));
BOOST_CHECK(Address("07746f871de684297923f933279555dda418f8a2") == kp.address());
@ -41,7 +42,7 @@ BOOST_AUTO_TEST_CASE(AesDecrypt)
BOOST_AUTO_TEST_CASE(AesDecryptWrongSeed)
{
cout << "AesDecryptWrongSeed" << endl;
cnote << "AesDecryptWrongSeed";
bytes seed = fromHex("badaead416c20cfd00c2fc9f1788ff9f965a2000799c96a624767cb0e1e90d2d7191efdd92349226742fdc73d1d87e2d597536c4641098b9a89836c94f58a2ab4c525c27c4cb848b3e22ea245b2bc5c8c7beaa900b0c479253fc96fce7ffc621");
KeyPair kp(sha3Secure(aesDecrypt(&seed, "test")));
BOOST_CHECK(Address("07746f871de684297923f933279555dda418f8a2") != kp.address());
@ -49,7 +50,7 @@ BOOST_AUTO_TEST_CASE(AesDecryptWrongSeed)
BOOST_AUTO_TEST_CASE(AesDecryptWrongPassword)
{
cout << "AesDecryptWrongPassword" << endl;
cnote << "AesDecryptWrongPassword";
bytes seed = fromHex("2dbaead416c20cfd00c2fc9f1788ff9f965a2000799c96a624767cb0e1e90d2d7191efdd92349226742fdc73d1d87e2d597536c4641098b9a89836c94f58a2ab4c525c27c4cb848b3e22ea245b2bc5c8c7beaa900b0c479253fc96fce7ffc621");
KeyPair kp(sha3Secure(aesDecrypt(&seed, "badtest")));
BOOST_CHECK(Address("07746f871de684297923f933279555dda418f8a2") != kp.address());
@ -57,24 +58,23 @@ BOOST_AUTO_TEST_CASE(AesDecryptWrongPassword)
BOOST_AUTO_TEST_CASE(AesDecryptFailInvalidSeed)
{
cout << "AesDecryptFailInvalidSeed" << endl;
cnote << "AesDecryptFailInvalidSeed";
bytes seed = fromHex("xdbaead416c20cfd00c2fc9f1788ff9f965a2000799c96a624767cb0e1e90d2d7191efdd92349226742fdc73d1d87e2d597536c4641098b9a89836c94f58a2ab4c525c27c4cb848b3e22ea245b2bc5c8c7beaa900b0c479253fc96fce7ffc621");
BOOST_CHECK(bytes() == aesDecrypt(&seed, "test"));
}
BOOST_AUTO_TEST_CASE(AesDecryptFailInvalidSeedSize)
{
cout << "AesDecryptFailInvalidSeedSize" << endl;
cnote << "AesDecryptFailInvalidSeedSize";
bytes seed = fromHex("000102030405060708090a0b0c0d0e0f");
BOOST_CHECK(bytes() == aesDecrypt(&seed, "test"));
}
BOOST_AUTO_TEST_CASE(AesDecryptFailInvalidSeed2)
{
cout << "AesDecryptFailInvalidSeed2" << endl;
cnote << "AesDecryptFailInvalidSeed2";
bytes seed = fromHex("000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f");
BOOST_CHECK(bytes() == aesDecrypt(&seed, "test"));
}
BOOST_AUTO_TEST_SUITE_END()

2
test/libdevcrypto/hexPrefix.cpp

@ -29,7 +29,7 @@
#include <libdevcore/CommonIO.h>
#include <libdevcore/Base64.h>
#include <libdevcore/TrieCommon.h>
#include "../TestHelper.h"
#include <test/TestHelper.h>
using namespace std;
using namespace dev;

100
test/libdevcrypto/trie.cpp

@ -27,7 +27,7 @@
#include <libdevcore/TrieDB.h>
#include <libdevcore/TrieHash.h>
#include "MemTrie.h"
#include "../TestHelper.h"
#include <test/TestHelper.h>
using namespace std;
using namespace dev;
@ -315,35 +315,35 @@ BOOST_AUTO_TEST_CASE(moreTrieTests)
MemoryDB m;
GenericTrieDB<MemoryDB> t(&m);
t.init(); // initialise as empty tree.
cout << t;
cout << m;
cout << t.root() << endl;
cout << stringMapHash256(StringMap()) << endl;
cnote << t;
cnote << m;
cnote << t.root();
cnote << stringMapHash256(StringMap());
t.insert(string("tesz"), string("test"));
cout << t;
cout << m;
cout << t.root() << endl;
cout << stringMapHash256({{"test", "test"}}) << endl;
cnote << t;
cnote << m;
cnote << t.root();
cnote << stringMapHash256({{"test", "test"}});
t.insert(string("tesa"), string("testy"));
cout << t;
cout << m;
cout << t.root() << endl;
cout << stringMapHash256({{"test", "test"}, {"te", "testy"}}) << endl;
cout << t.at(string("test")) << endl;
cout << t.at(string("te")) << endl;
cout << t.at(string("t")) << endl;
cnote << t;
cnote << m;
cnote << t.root();
cnote << stringMapHash256({{"test", "test"}, {"te", "testy"}});
cnote << t.at(string("test"));
cnote << t.at(string("te"));
cnote << t.at(string("t"));
t.remove(string("te"));
cout << m;
cout << t.root() << endl;
cout << stringMapHash256({{"test", "test"}}) << endl;
cnote << m;
cnote << t.root();
cnote << stringMapHash256({{"test", "test"}});
t.remove(string("test"));
cout << m;
cout << t.root() << endl;
cout << stringMapHash256(StringMap()) << endl;
cnote << m;
cnote << t.root();
cnote << stringMapHash256(StringMap());
}
{
MemoryDB m;
@ -351,37 +351,37 @@ BOOST_AUTO_TEST_CASE(moreTrieTests)
t.init(); // initialise as empty tree.
t.insert(string("a"), string("A"));
t.insert(string("b"), string("B"));
cout << t;
cout << m;
cout << t.root() << endl;
cout << stringMapHash256({{"b", "B"}, {"a", "A"}}) << endl;
cnote << t;
cnote << m;
cnote << t.root();
cnote << stringMapHash256({{"b", "B"}, {"a", "A"}});
bytes r(stringMapRlp256({{"b", "B"}, {"a", "A"}}));
cout << RLP(r) << endl;
cnote << RLP(r);
}
{
MemTrie t;
t.insert("dog", "puppy");
cout << hex << t.hash256() << endl;
cnote << hex << t.hash256();
bytes r(t.rlp());
cout << RLP(r) << endl;
cnote << RLP(r);
}
{
MemTrie t;
t.insert("bed", "d");
t.insert("be", "e");
cout << hex << t.hash256() << endl;
cnote << hex << t.hash256();
bytes r(t.rlp());
cout << RLP(r) << endl;
cnote << RLP(r);
}
{
cout << hex << stringMapHash256({{"dog", "puppy"}, {"doe", "reindeer"}}) << endl;
cnote << hex << stringMapHash256({{"dog", "puppy"}, {"doe", "reindeer"}});
MemTrie t;
t.insert("dog", "puppy");
t.insert("doe", "reindeer");
cout << hex << t.hash256() << endl;
cnote << hex << t.hash256();
bytes r(t.rlp());
cout << RLP(r) << endl;
cout << toHex(t.rlp()) << endl;
cnote << RLP(r);
cnote << toHex(t.rlp());
}
{
MemoryDB m;
@ -397,12 +397,12 @@ BOOST_AUTO_TEST_CASE(moreTrieTests)
t.insert(a, b);
s[a] = b;
cout << endl << "-------------------------------" << endl;
cout << a << " -> " << b << endl;
cout << d;
cout << m;
cout << d.root() << endl;
cout << stringMapHash256(s) << endl;
cnote << "/n-------------------------------";
cnote << a << " -> " << b;
cnote << d;
cnote << m;
cnote << d.root();
cnote << stringMapHash256(s);
BOOST_REQUIRE(d.check(true));
BOOST_REQUIRE_EQUAL(t.hash256(), stringMapHash256(s));
@ -421,12 +421,12 @@ BOOST_AUTO_TEST_CASE(moreTrieTests)
t.remove(a);
d.remove(string(a));
/*cout << endl << "-------------------------------" << endl;
cout << "X " << a << endl;
cout << d;
cout << m;
cout << d.root() << endl;
cout << hash256(s) << endl;*/
/*cnote << endl << "-------------------------------";
cnote << "X " << a;
cnote << d;
cnote << m;
cnote << d.root();
cnote << hash256(s);*/
BOOST_REQUIRE(d.check(true));
BOOST_REQUIRE(t.at(a).empty());
@ -559,9 +559,11 @@ BOOST_AUTO_TEST_CASE(trieStess)
// for (auto i: dm2.get())
// cwarn << i.first << ": " << RLP(i.second);
d2.debugStructure(cerr);
g_logVerbosity = 99;
if (g_logVerbosity != -1)
g_logVerbosity = 99;
d2.remove(k);
g_logVerbosity = 4;
if (g_logVerbosity != -1)
g_logVerbosity = 4;
cwarn << "Good?" << d2.root();
}

2
test/libethcore/dagger.cpp

@ -25,7 +25,7 @@
#include <libdevcore/CommonIO.h>
#include <libethcore/EthashAux.h>
#include <boost/test/unit_test.hpp>
#include "../TestHelper.h"
#include <test/TestHelper.h>
using namespace std;
using namespace dev;

4
test/libethereum/genesis.cpp

@ -21,11 +21,13 @@
*/
#include <fstream>
#include <random>
#include <boost/test/unit_test.hpp>
#include "../JsonSpiritHeaders.h"
#include <libdevcore/CommonIO.h>
#include <libethereum/CanonBlockChain.h>
#include "../TestHelper.h"
#include <test/TestHelper.h>
using namespace std;
using namespace dev;

22
test/libethereum/state.cpp

@ -41,6 +41,7 @@ namespace dev { namespace test {
void doStateTests(json_spirit::mValue& v, bool _fillin)
{
string testname;
for (auto& i: v.get_obj())
{
mObject& o = i.second.get_obj();
@ -50,10 +51,12 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
continue;
}
std::cout << " " << i.first << std::endl;
TBOOST_REQUIRE((o.count("env") > 0));
TBOOST_REQUIRE((o.count("pre") > 0));
TBOOST_REQUIRE((o.count("transaction") > 0));
cnote << i.first;
testname = "(" + i.first + ") ";
TBOOST_REQUIRE_MESSAGE((o.count("env") > 0), testname + "env not set!");
TBOOST_REQUIRE_MESSAGE((o.count("pre") > 0), testname + "pre not set!");
TBOOST_REQUIRE_MESSAGE((o.count("transaction") > 0), testname + "transaction not set!");
ImportTest importer(o, _fillin);
const State importedStatePost = importer.m_statePost;
@ -66,9 +69,10 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
if (_fillin)
{
#if ETH_FATDB
importer.exportTest(output);
if (importer.exportTest(output))
cerr << testname << endl;
#else
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("You can not fill tests when FATDB is switched off"));
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment(testname + "You can not fill tests when FATDB is switched off"));
#endif
}
else
@ -86,7 +90,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
#if ETH_FATDB
ImportTest::compareStates(importer.m_statePost, importedStatePost);
#endif
TBOOST_CHECK_MESSAGE((importer.m_statePost.rootHash() == h256(o["postStateRoot"].get_str())), "wrong post state root");
TBOOST_CHECK_MESSAGE((importer.m_statePost.rootHash() == h256(o["postStateRoot"].get_str())), testname + "wrong post state root");
}
}
}
@ -237,11 +241,11 @@ BOOST_AUTO_TEST_CASE(stRandom)
}
catch (Exception const& _e)
{
BOOST_ERROR("Failed test with Exception: " << diagnostic_information(_e));
BOOST_ERROR(path.filename().string() + "Failed test with Exception: " << diagnostic_information(_e));
}
catch (std::exception const& _e)
{
BOOST_ERROR("Failed test with Exception: " << _e.what());
BOOST_ERROR(path.filename().string() + "Failed test with Exception: " << _e.what());
}
}
}

2
test/libethereum/stateOriginal.cpp

@ -20,6 +20,7 @@
* State test functions.
*/
#include <test/TestHelper.h>
#include <boost/test/unit_test.hpp>
#include <boost/filesystem/operations.hpp>
#include <libethereum/CanonBlockChain.h>
@ -27,7 +28,6 @@
#include <libethcore/Farm.h>
#include <libethcore/BasicAuthority.h>
#include <libethereum/Defaults.h>
#include <test/TestHelper.h>
using namespace std;
using namespace dev;

40
test/libethereum/transactionTests.cpp

@ -32,6 +32,7 @@ namespace dev { namespace test {
void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
{
string testname;
for (auto& i: _v.get_obj())
{
mObject& o = i.second.get_obj();
@ -41,7 +42,8 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
continue;
}
cerr << i.first << endl;
testname = "(" + i.first ") ";
cnote << testname;
if (_fillin)
{
TBOOST_REQUIRE((o.count("transaction") > 0));
@ -55,7 +57,7 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
{
Transaction txFromFields(rlpStream.out(), CheckTransaction::Everything);
if (!txFromFields.signature().isValid())
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("transaction from RLP signature is invalid") );
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment(testname + "transaction from RLP signature is invalid") );
o["sender"] = toString(txFromFields.sender());
o["transaction"] = ImportTest::makeAllFieldsHex(tObj);
@ -69,9 +71,9 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
{
bool expectInValid = (o["expect"].get_str() == "invalid");
if (Options::get().checkState)
{TBOOST_CHECK_MESSAGE(expectInValid, "Check state: Transaction '" << i.first << "' is expected to be valid!");}
{TBOOST_CHECK_MESSAGE(expectInValid, testname + "Check state: Transaction '" << i.first << "' is expected to be valid!");}
else
{TBOOST_WARN_MESSAGE(expectInValid, "Check state: Transaction '" << i.first << "' is expected to be valid!");}
{TBOOST_WARN_MESSAGE(expectInValid, testname + "Check state: Transaction '" << i.first << "' is expected to be valid!");}
o.erase(o.find("expect"));
}
@ -82,9 +84,9 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
{
bool expectValid = (o["expect"].get_str() == "valid");
if (Options::get().checkState)
{TBOOST_CHECK_MESSAGE(expectValid, "Check state: Transaction '" << i.first << "' is expected to be invalid!");}
{TBOOST_CHECK_MESSAGE(expectValid, testname + "Check state: Transaction '" << i.first << "' is expected to be invalid!");}
else
{TBOOST_WARN_MESSAGE(expectValid, "Check state: Transaction '" << i.first << "' is expected to be invalid!");}
{TBOOST_WARN_MESSAGE(expectValid, testname + "Check state: Transaction '" << i.first << "' is expected to be invalid!");}
o.erase(o.find("expect"));
}
@ -99,39 +101,39 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin)
RLP rlp(stream);
txFromRlp = Transaction(rlp.data(), CheckTransaction::Everything);
if (!txFromRlp.signature().isValid())
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("transaction from RLP signature is invalid") );
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment(testname + "transaction from RLP signature is invalid") );
}
catch(Exception const& _e)
{
cnote << i.first;
cnote << "Transaction Exception: " << diagnostic_information(_e);
TBOOST_CHECK_MESSAGE((o.count("transaction") == 0), "A transaction object should not be defined because the RLP is invalid!");
TBOOST_CHECK_MESSAGE((o.count("transaction") == 0), testname + "A transaction object should not be defined because the RLP is invalid!");
continue;
}
catch(...)
{
TBOOST_CHECK_MESSAGE((o.count("transaction") == 0), "A transaction object should not be defined because the RLP is invalid!");
TBOOST_CHECK_MESSAGE((o.count("transaction") == 0), testname + "A transaction object should not be defined because the RLP is invalid!");
continue;
}
TBOOST_REQUIRE((o.count("transaction") > 0));
TBOOST_REQUIRE_MESSAGE((o.count("transaction") > 0), testname + "Expected a valid transaction!");
mObject tObj = o["transaction"].get_obj();
Transaction txFromFields(createRLPStreamFromTransactionFields(tObj).out(), CheckTransaction::Everything);
//Check the fields restored from RLP to original fields
TBOOST_CHECK_MESSAGE((txFromFields.data() == txFromRlp.data()), "Data in given RLP not matching the Transaction data!");
TBOOST_CHECK_MESSAGE((txFromFields.value() == txFromRlp.value()), "Value in given RLP not matching the Transaction value!");
TBOOST_CHECK_MESSAGE((txFromFields.gasPrice() == txFromRlp.gasPrice()), "GasPrice in given RLP not matching the Transaction gasPrice!");
TBOOST_CHECK_MESSAGE((txFromFields.gas() == txFromRlp.gas()),"Gas in given RLP not matching the Transaction gas!");
TBOOST_CHECK_MESSAGE((txFromFields.nonce() == txFromRlp.nonce()),"Nonce in given RLP not matching the Transaction nonce!");
TBOOST_CHECK_MESSAGE((txFromFields.receiveAddress() == txFromRlp.receiveAddress()), "Receive address in given RLP not matching the Transaction 'to' address!");
TBOOST_CHECK_MESSAGE((txFromFields.sender() == txFromRlp.sender()), "Transaction sender address in given RLP not matching the Transaction 'vrs' signature!");
TBOOST_CHECK_MESSAGE((txFromFields == txFromRlp), "However, txFromFields != txFromRlp!");
TBOOST_CHECK_MESSAGE((txFromFields.data() == txFromRlp.data()), testname + "Data in given RLP not matching the Transaction data!");
TBOOST_CHECK_MESSAGE((txFromFields.value() == txFromRlp.value()), testname + "Value in given RLP not matching the Transaction value!");
TBOOST_CHECK_MESSAGE((txFromFields.gasPrice() == txFromRlp.gasPrice()), testname + "GasPrice in given RLP not matching the Transaction gasPrice!");
TBOOST_CHECK_MESSAGE((txFromFields.gas() == txFromRlp.gas()), testname + "Gas in given RLP not matching the Transaction gas!");
TBOOST_CHECK_MESSAGE((txFromFields.nonce() == txFromRlp.nonce()), testname + "Nonce in given RLP not matching the Transaction nonce!");
TBOOST_CHECK_MESSAGE((txFromFields.receiveAddress() == txFromRlp.receiveAddress()), testname + "Receive address in given RLP not matching the Transaction 'to' address!");
TBOOST_CHECK_MESSAGE((txFromFields.sender() == txFromRlp.sender()), testname + "Transaction sender address in given RLP not matching the Transaction 'vrs' signature!");
TBOOST_CHECK_MESSAGE((txFromFields == txFromRlp), testname + "However, txFromFields != txFromRlp!");
TBOOST_REQUIRE ((o.count("sender") > 0));
Address addressReaded = Address(o["sender"].get_str());
TBOOST_CHECK_MESSAGE((txFromFields.sender() == addressReaded || txFromRlp.sender() == addressReaded), "Signature address of sender does not match given sender address!");
TBOOST_CHECK_MESSAGE((txFromFields.sender() == addressReaded || txFromRlp.sender() == addressReaded), testname + "Signature address of sender does not match given sender address!");
}
}//for
}//doTransactionTests

15
test/libevm/vm.cpp

@ -296,6 +296,7 @@ namespace dev { namespace test {
void doVMTests(json_spirit::mValue& v, bool _fillin)
{
string testname;
for (auto& i: v.get_obj())
{
mObject& o = i.second.get_obj();
@ -305,10 +306,12 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
continue;
}
std::cout << " " << i.first << "\n";
TBOOST_REQUIRE((o.count("env") > 0));
TBOOST_REQUIRE((o.count("pre") > 0));
TBOOST_REQUIRE((o.count("exec") > 0));
cnote << i.first;
testname = "(" + i.first + ") ";
TBOOST_REQUIRE_MESSAGE((o.count("env") > 0), testname + "env not set!");
TBOOST_REQUIRE_MESSAGE((o.count("pre") > 0), testname + "pre not set!");
TBOOST_REQUIRE_MESSAGE((o.count("exec") > 0), testname + "exec not set!");
FakeExtVM fev(eth::EnvInfo{});
fev.importEnv(o["env"].get_obj());
@ -338,7 +341,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin)
}
catch (VMException const&)
{
std::cout << " Safe VM Exception\n";
cnote << " Safe VM Exception\n";
vmExceptionOccured = true;
}
catch (Exception const& _e)
@ -535,7 +538,7 @@ BOOST_AUTO_TEST_CASE(vmRandom)
{
try
{
std::cout << "TEST " << path.filename() << "\n";
cnote << "TEST " << path.filename();
json_spirit::mValue v;
string s = asString(dev::contents(path.string()));
BOOST_REQUIRE_MESSAGE(s.length() > 0, "Content of " + path.string() + " is empty. Have you cloned the 'tests' repo branch develop and set ETHEREUM_TEST_PATH to its path?");

2
test/libevm/vm.h

@ -26,6 +26,7 @@ along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
#include <fstream>
#include <cstdint>
#include <test/TestHelper.h>
#include <boost/test/unit_test.hpp>
#include <json_spirit/json_spirit.h>
@ -38,7 +39,6 @@ along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
#include <libethereum/Transaction.h>
#include <libethereum/ExtVM.h>
#include <libethereum/State.h>
#include <test/TestHelper.h>
namespace dev { namespace test {

4
test/libp2p/capability.cpp

@ -102,7 +102,9 @@ BOOST_AUTO_TEST_CASE(capability)
if (test::Options::get().nonetwork)
return;
VerbosityHolder verbosityHolder(10);
if (g_logVerbosity != -1)
VerbosityHolder verbosityHolder(10);
cnote << "Testing Capability...";
const char* const localhost = "127.0.0.1";

10
test/libp2p/peer.cpp

@ -43,7 +43,9 @@ BOOST_AUTO_TEST_CASE(host)
if (test::Options::get().nonetwork)
return;
VerbosityHolder setTemporaryLevel(10);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(10);
NetworkPreferences host1prefs("127.0.0.1", 30321, false);
NetworkPreferences host2prefs("127.0.0.1", 30322, false);
Host host1("Test", host1prefs);
@ -88,7 +90,8 @@ BOOST_AUTO_TEST_CASE(saveNodes)
if (test::Options::get().nonetwork)
return;
VerbosityHolder reduceVerbosity(2);
if (g_logVerbosity != -1)
VerbosityHolder reduceVerbosity(2);
std::list<Host*> hosts;
unsigned const c_step = 10;
@ -152,7 +155,8 @@ BOOST_AUTO_TEST_CASE(requirePeer)
if (test::Options::get().nonetwork)
return;
VerbosityHolder temporaryLevel(10);
if (g_logVerbosity != -1)
VerbosityHolder reduceVerbosity(10);
unsigned const step = 10;
const char* const localhost = "127.0.0.1";

4
test/libsolidity/solidityExecutionFramework.h

@ -44,7 +44,9 @@ class ExecutionFramework
public:
ExecutionFramework()
{
g_logVerbosity = 0;
if (g_logVerbosity != -1)
g_logVerbosity = 0;
m_state.resetCurrent();
}
bytes const& compileAndRunWithoutCheck(

12
test/libwhisper/bloomFilter.cpp

@ -106,7 +106,9 @@ BOOST_AUTO_TEST_SUITE(bloomFilter)
BOOST_AUTO_TEST_CASE(falsePositiveRate)
{
VerbosityHolder setTemporaryLevel(10);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(10);
cnote << "Testing Bloom Filter False Positive Rate...";
TopicBloomFilterTest f;
@ -124,7 +126,9 @@ BOOST_AUTO_TEST_CASE(falsePositiveRate)
BOOST_AUTO_TEST_CASE(bloomFilterRandom)
{
VerbosityHolder setTemporaryLevel(10);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(10);
cnote << "Testing Bloom Filter matching...";
TopicBloomFilterShort f;
@ -150,7 +154,9 @@ BOOST_AUTO_TEST_CASE(bloomFilterRandom)
BOOST_AUTO_TEST_CASE(bloomFilterRaw)
{
VerbosityHolder setTemporaryLevel(10);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(10);
cnote << "Testing Raw Bloom matching...";
TopicBloomFilterShort f;

20
test/libwhisper/whisperDB.cpp

@ -41,7 +41,9 @@ BOOST_FIXTURE_TEST_SUITE(whisperDB, P2PFixture)
BOOST_AUTO_TEST_CASE(basic)
{
VerbosityHolder setTemporaryLevel(10);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(10);
cnote << "Testing Whisper DB...";
string s;
@ -86,7 +88,9 @@ BOOST_AUTO_TEST_CASE(basic)
BOOST_AUTO_TEST_CASE(persistence)
{
VerbosityHolder setTemporaryLevel(10);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(10);
cnote << "Testing persistence of Whisper DB...";
string s;
@ -135,7 +139,9 @@ BOOST_AUTO_TEST_CASE(messages)
return;
cnote << "Testing load/save Whisper messages...";
VerbosityHolder setTemporaryLevel(2);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(2);
unsigned const TestSize = 3;
map<h256, Envelope> m1;
map<h256, Envelope> preexisting;
@ -193,7 +199,9 @@ BOOST_AUTO_TEST_CASE(corruptedData)
return;
cnote << "Testing corrupted data...";
VerbosityHolder setTemporaryLevel(2);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(2);
map<h256, Envelope> m;
h256 x = h256::random();
@ -222,7 +230,9 @@ BOOST_AUTO_TEST_CASE(filters)
return;
cnote << "Testing filters saving...";
VerbosityHolder setTemporaryLevel(2);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(2);
h256 persistID(0xC0FFEE);
{

7
test/libwhisper/whisperMessage.cpp

@ -82,7 +82,9 @@ BOOST_AUTO_TEST_SUITE(whisperMessage)
BOOST_AUTO_TEST_CASE(seal)
{
VerbosityHolder setTemporaryLevel(10);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(10);
cnote << "Testing Envelope encryption...";
for (unsigned int i = 1; i < 10; ++i)
@ -91,7 +93,8 @@ BOOST_AUTO_TEST_CASE(seal)
BOOST_AUTO_TEST_CASE(work)
{
VerbosityHolder setTemporaryLevel(10);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(10);
cnote << "Testing proof of work...";
Secret zero;

8
test/libwhisper/whisperTopic.cpp

@ -47,7 +47,8 @@ BOOST_AUTO_TEST_CASE(topic)
return;
cnote << "Testing Whisper...";
VerbosityHolder setTemporaryLevel(0);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(0);
uint16_t port1 = 30311;
Host host1("Test", NetworkPreferences("127.0.0.1", port1, false));
@ -161,6 +162,7 @@ BOOST_AUTO_TEST_CASE(forwarding)
}
});
// Host must be configured not to share peers.
uint16_t port2 = 30313;
Host host2("Forwarder", NetworkPreferences("127.0.0.1", port2, false));
@ -392,7 +394,9 @@ BOOST_AUTO_TEST_CASE(selfAddressed)
if (test::Options::get().nonetwork)
return;
VerbosityHolder setTemporaryLevel(10);
if (g_logVerbosity != -1)
VerbosityHolder setTemporaryLevel(10);
cnote << "Testing self-addressed messaging with bloom filter matching...";
char const* text = "deterministic pseudorandom test";

Loading…
Cancel
Save