From 89c669769b015fd23a35d48d0fc2aaf2ce15380c Mon Sep 17 00:00:00 2001 From: Norm Fasey Date: Wed, 9 Jul 2014 19:48:35 +0100 Subject: [PATCH 1/5] Fixes for Alerts Unit Tests --- doc/unit-tests.md | 2 +- src/alert.cpp | 4 + src/makefile.linux-mingw | 3 + src/makefile.mingw | 3 + src/makefile.osx | 3 + src/makefile.unix | 3 + src/test/alert_tests.cpp | 240 ++++++++++++++++++++++++--------------- src/test/data/alertTests | Bin 1284 -> 0 bytes 8 files changed, 165 insertions(+), 93 deletions(-) delete mode 100644 src/test/data/alertTests diff --git a/doc/unit-tests.md b/doc/unit-tests.md index 2318c0db25..5eaea0365d 100644 --- a/doc/unit-tests.md +++ b/doc/unit-tests.md @@ -7,7 +7,7 @@ use the Boost::Test unit-testing framework. To compile and run the tests: cd src - make -f makefile.unix test_darkcoin # Replace makefile.unix if you're not on unix + make -f makefile.unix test_darkcoin UNIT_TEST=1 # Replace makefile.unix if you're not on unix ./test_darkcoin # Runs the unit tests If all tests succeed the last line of output will be: diff --git a/src/alert.cpp b/src/alert.cpp index e5c6ec36c9..e6bed97d92 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -19,7 +19,11 @@ using namespace std; map mapAlerts; CCriticalSection cs_mapAlerts; +#ifdef UNIT_TEST +static const char* pszMainKey = "043bcb5ad652b5680fadc0002a17c64542d2aff59c605d820960ab568af2c9ac7e3f130f7e4b638cfdc9069282f5500d67ee3f2803d6f0d6be44d387ac7ac286e4"; +#else static const char* pszMainKey = "048240a8748a80a286b270ba126705ced4f2ce5a7847b3610ea3c06513150dade2a8512ed5ea86320824683fc0818f0ac019214973e677acd1244f6d0571fc5103"; +#endif static const char* pszTestKey = "04517d8a699cb43d3938d7b24faaff7cda448ca4ea267723ba614784de661949bf632d6304316b244646dea079735b9a6fc4af804efb4752075b9fe2245e14e412"; void CUnsignedAlert::SetNull() diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw index 5637b6f683..97a48ff7c3 100644 --- a/src/makefile.linux-mingw +++ b/src/makefile.linux-mingw @@ -37,6 +37,9 @@ xCXXFLAGS=-O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter xLDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -Wl,--large-address-aware -static-libgcc -static-libstdc++ $(LDFLAGS) TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) +ifdef UNIT_TEST +DEFS+=-DUNIT_TEST=1 +endif ifndef USE_UPNP override USE_UPNP = - diff --git a/src/makefile.mingw b/src/makefile.mingw index 1c5b634ee5..8f925a487c 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -50,6 +50,9 @@ CFLAGS=-mthreads -O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-par LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -Wl,--large-address-aware TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) +ifdef UNIT_TEST +DEFS+=-DUNIT_TEST=1 +endif ifndef USE_UPNP override USE_UPNP = - diff --git a/src/makefile.osx b/src/makefile.osx index 038135cf30..46223b58a1 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -25,6 +25,9 @@ USE_IPV6:=1 LIBS= -dead_strip TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) +ifdef UNIT_TEST +DEFS+=-DUNIT_TEST=1 +endif ifdef STATIC # Build STATIC if you are redistributing the bitcoinf diff --git a/src/makefile.unix b/src/makefile.unix index 78f7d2377d..2fbb8364c6 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -19,6 +19,9 @@ DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLU LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH)) TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) +ifdef UNIT_TEST +DEFS+=-DUNIT_TEST=1 +endif LMODE = dynamic LMODE2 = dynamic diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index 3b32912551..db9df1c56a 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -5,99 +5,157 @@ #include #include #include +#include +#include #include "alert.h" +#include "base58.h" +#include "key.h" #include "serialize.h" #include "util.h" -#if 0 -// -// alertTests contains 7 alerts, generated with this code: -// (SignAndSave code not shown, alert signing key is secret) -// +using namespace std; +namespace fs = boost::filesystem; + +bool SignAndSave(CAlert &alert, std::vector &alerts) { - CAlert alert; - alert.nRelayUntil = 60; - alert.nExpiration = 24 * 60 * 60; - alert.nID = 1; - alert.nCancel = 0; // cancels previous messages up to this ID number - alert.nMinVer = 0; // These versions are protocol versions - alert.nMaxVer = 70001; - alert.nPriority = 1; - alert.strComment = "Alert comment"; - alert.strStatusBar = "Alert 1"; + CDataStream ds(SER_DISK, PROTOCOL_VERSION); + ds << alert.nVersion + << alert.nRelayUntil + << alert.nExpiration + << alert.nID + << alert.nCancel + << alert.setCancel + << alert.nMinVer + << alert.nMaxVer + << alert.setSubVer + << alert.nPriority + << alert.strComment + << alert.strStatusBar + << alert.strReserved; - SignAndSave(alert, "test/alertTests"); - - alert.setSubVer.insert(std::string("/Satoshi:0.1.0/")); - alert.strStatusBar = "Alert 1 for Satoshi 0.1.0"; - SignAndSave(alert, "test/alertTests"); - - alert.setSubVer.insert(std::string("/Satoshi:0.2.0/")); - alert.strStatusBar = "Alert 1 for Satoshi 0.1.0, 0.2.0"; - SignAndSave(alert, "test/alertTests"); - - alert.setSubVer.clear(); - ++alert.nID; - alert.nCancel = 1; - alert.nPriority = 100; - alert.strStatusBar = "Alert 2, cancels 1"; - SignAndSave(alert, "test/alertTests"); - - alert.nExpiration += 60; - ++alert.nID; - SignAndSave(alert, "test/alertTests"); - - ++alert.nID; - alert.nMinVer = 11; - alert.nMaxVer = 22; - SignAndSave(alert, "test/alertTests"); - - ++alert.nID; - alert.strStatusBar = "Alert 2 for Satoshi 0.1.0"; - alert.setSubVer.insert(std::string("/Satoshi:0.1.0/")); - SignAndSave(alert, "test/alertTests"); - - ++alert.nID; - alert.nMinVer = 0; - alert.nMaxVer = 999999; - alert.strStatusBar = "Evil Alert'; /bin/ls; echo '"; - alert.setSubVer.clear(); - SignAndSave(alert, "test/alertTests"); -} -#endif - -struct ReadAlerts -{ - ReadAlerts() + alert.vchMsg.assign(ds.begin(),ds.end()); + uint256 hash = alert.GetHash(); + std::vector sig; + CBitcoinSecret secret; + if (!secret.SetString("7rDMuTnMxWdqRsvk5fYfwkaZoguWJMoDucyZvKmURVukdAkGiVb")) + { + cout << "Error Setting Private Key" << endl; + return false; + } + CKey key = secret.GetKey(); + + if (!key.Sign(hash, sig)) + { + cout << "Could Not Sign Message" << endl; + return false; + } + alert.vchSig = sig; + + try + { + alerts.push_back(alert); + } + + catch (std::exception &e) + { + cout << "Exception caught " << e.what() << endl; + } + return true; + +} + +struct SetUpAlerts +{ + SetUpAlerts() + { + + CAlert alert; + alert.nRelayUntil = 60; + alert.nExpiration = 24 * 60 * 60; + alert.nID = 1; + alert.nCancel = 0; // cancels previous messages up to this ID number + alert.nMinVer = 0; // These versions are protocol versions + alert.nMaxVer = 70001; + alert.nPriority = 1; + alert.strComment = "Alert comment"; + alert.strStatusBar = "Alert 1"; + + if (!SignAndSave(alert, alerts)) + { + return; + } + + CAlert alert2(alert); + alert2.setSubVer.insert(std::string("/Satoshi:0.1.0/")); + alert2.strStatusBar = "Alert 1 for Satoshi 0.1.0"; + if (!SignAndSave(alert2, alerts)) + { + return; + } + + CAlert alert3(alert2); + alert3.setSubVer.insert(std::string("/Satoshi:0.2.0/")); + alert3.strStatusBar = "Alert 1 for Satoshi 0.1.0, 0.2.0"; + if (!SignAndSave(alert3, alerts)) + { + return; + } + + CAlert alert4(alert3); + alert4.setSubVer.clear(); + ++alert4.nID; + alert4.nCancel = 1; + alert4.nPriority = 100; + alert4.strStatusBar = "Alert 2, cancels 1"; + if (!SignAndSave(alert4, alerts)) + { + return; + } + + CAlert alert5(alert4); + alert5.nExpiration += 60; + ++alert5.nID; + if (!SignAndSave(alert5, alerts)) + { + return; + } + + CAlert alert6(alert5); + ++alert6.nID; + alert6.nMinVer = 11; + alert6.nMaxVer = 22; + if (!SignAndSave(alert6, alerts)) + { + return; + } + + CAlert alert7(alert6); + ++alert7.nID; + alert7.strStatusBar = "Alert 2 for Satoshi 0.1.0"; + alert7.setSubVer.insert(std::string("/Satoshi:0.1.0/")); + if (!SignAndSave(alert7, alerts)) + { + return; + } + + CAlert alert8(alert7); + ++alert8.nID; + alert8.nMinVer = 0; + alert8.nMaxVer = 999999; + alert8.strStatusBar = "Evil Alert'; /bin/ls; echo '"; + alert8.setSubVer.clear(); + if (!SignAndSave(alert8, alerts)) + { + return; + } + + return; + + } + ~SetUpAlerts() { - std::string filename("alertTests"); - namespace fs = boost::filesystem; - fs::path testFile = fs::current_path() / "test" / "data" / filename; -#ifdef TEST_DATA_DIR - if (!fs::exists(testFile)) - { - testFile = fs::path(BOOST_PP_STRINGIZE(TEST_DATA_DIR)) / filename; - } -#endif - FILE* fp = fopen(testFile.string().c_str(), "rb"); - if (!fp) return; - - - CAutoFile filein = CAutoFile(fp, SER_DISK, CLIENT_VERSION); - if (!filein) return; - - try { - while (!feof(filein)) - { - CAlert alert; - filein >> alert; - alerts.push_back(alert); - } - } - catch (std::exception) { } } - ~ReadAlerts() { } static std::vector read_lines(boost::filesystem::path filepath) { @@ -105,7 +163,7 @@ struct ReadAlerts std::ifstream f(filepath.string().c_str()); std::string line; - while (std::getline(f,line)) + while (std::getline(f, line)) result.push_back(line); return result; @@ -114,8 +172,7 @@ struct ReadAlerts std::vector alerts; }; -BOOST_FIXTURE_TEST_SUITE(Alert_tests, ReadAlerts) - +BOOST_FIXTURE_TEST_SUITE(Alert_tests, SetUpAlerts) BOOST_AUTO_TEST_CASE(AlertApplies) { @@ -153,7 +210,6 @@ BOOST_AUTO_TEST_CASE(AlertApplies) SetMockTime(0); } - // This uses sh 'echo' to test the -alertnotify function, writing to a // /tmp file. So skip it on Windows: #ifndef WIN32 @@ -167,17 +223,17 @@ BOOST_AUTO_TEST_CASE(AlertNotify) mapArgs["-alertnotify"] = std::string("echo %s >> ") + temp.string(); BOOST_FOREACH(CAlert alert, alerts) - alert.ProcessAlert(false); + alert.ProcessAlert(false); std::vector r = read_lines(temp); // // Only want to run these tests if the "alertnotify.txt" has been read OK and has at least one record // in it. // - if (r.size() > 0 ) + if (r.size() > 0) { - BOOST_CHECK_EQUAL(r.size(), 1u); - BOOST_CHECK_EQUAL(r[0], "Evil Alert; /bin/ls; echo "); // single-quotes should be removed + BOOST_CHECK_EQUAL(r.size(), 1u); + BOOST_CHECK_EQUAL(r[0], "Evil Alert; /bin/ls; echo "); // single-quotes should be removed } boost::filesystem::remove(temp); diff --git a/src/test/data/alertTests b/src/test/data/alertTests deleted file mode 100644 index 24e906c1a5711039a41c93ad4be2a51228be7684..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1284 zcmZ={WME*h0b&qn2n6vM7$78=$-q!32;_o9cpY<6i%Jxd^K)}k^GetuJVORI0~aO* z)z8h|eCu0Ht*g7;lqzzs80#oG3og8Dl-Tw*`buZZb|!_g#Zi0m{AP6o-H}nAW!-2l zBjmtt;;kxsrh?(8Le1f?$sj8TI)ss5KRB@@zc?e)%0SOh&p;p3VUkdXDWv5WDL@q~ zfE6>i8@MtlGE8~OxK)M!{0(C&uZ~ShX>z9pSyOsUCpz}QEl0~<<7(^qTI@a?p9>J5mvV=;B>nV&R-H zJrr!xY~H&zr#X?aA}Eg915J(06gWze;Y-8Qtod_(+bm3UTirh|_;2RFh5L0x z9BXP%#JsiJ&r`yrpg3XmT7%0j?#0YDe0(m}9VWlrR1*wN>TlRQdBM|e{#jTZ#R78_ zH;^F)#0PN*8gibVX}E{dELf?6Oxgm4;E6a=#Ik3E|`vlW)~wY*#(l; zwy|YK{D|NBN;7ityU907ZpzJ>wrFnS+$m8Z?jPRq`SJpz^+O(KvUKU9w!g*+XScjQ z&{k`&P+D{Khr*sq39_$6PBVvLb1WOov7o@ScjCtuf-D09pOl%WpHpnD zkeZy4ub>Xi&gTsbFFy|S&f4>3pU_nnry}i^?aMwm__uR9NOK7QsqSRi}v`XKR5Z3i=d=suR3lEY9M_X7Ye3x~P@ From b26c6ab2a5a4c227e7ee9e599b1d0c2cbcefc5b7 Mon Sep 17 00:00:00 2001 From: Norm Fasey Date: Sat, 12 Jul 2014 14:30:06 +0100 Subject: [PATCH 2/5] Fixes for base58 Unit Tests --- src/test/base58_tests.cpp | 3 +- src/test/data/base58_keys_valid.json | 76 ++++++++++++++-------------- 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp index a0dd4b18b0..2741672a88 100644 --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -6,7 +6,7 @@ #include "base58.h" #include "util.h" -/*using namespace json_spirit; +using namespace json_spirit; extern Array read_json(const std::string& filename); BOOST_AUTO_TEST_SUITE(base58_tests) @@ -259,4 +259,3 @@ BOOST_AUTO_TEST_CASE(base58_keys_invalid) BOOST_AUTO_TEST_SUITE_END() -*/ \ No newline at end of file diff --git a/src/test/data/base58_keys_valid.json b/src/test/data/base58_keys_valid.json index 9409afc9d8..3a64b3b470 100644 --- a/src/test/data/base58_keys_valid.json +++ b/src/test/data/base58_keys_valid.json @@ -1,7 +1,7 @@ [ [ - "Lf8Th7S4LDxFUZegQgn5z5se7BahrJ9DeV", - "da589613a4c031bafa9fa5490fdaea491e81e687", + "XeE3CtVQHV7BoSp3ZAYFiELn66o3btEDUy", + "26cec4110b090e2f0a16a7a401660d3c775faad6", { "addrType": "pubkey", "isPrivkey": false, @@ -36,8 +36,8 @@ } ], [ - "6uoCwsNo3oV9rsYwHY7TeGtZpwLbWJyVcKCAQyz91Ah4XbZYxw3", - "58fb1bfc04bd9293a916d0688cba48ac143921a400e2086f43e16a02e572f2de", + "7r8PH9W3f8h3b5u5uPXi7zk2nsJbhKJR48nSZCYuzYVUZkz44Yq", + "4c1dca295faf461cebd294870e4b6c62910016c517d4850778c7eae890dfa6a9", { "isCompressed": false, "isPrivkey": true, @@ -45,8 +45,8 @@ } ], [ - "T9wxCLuZLZ2uSs44HUzGW5ZC2hNtnZqsbZGKtWC1MhJjHbRNCVYP", - "cdc32fb8fab8b80ecf7e7501d93173f4c10bc45bd42c030ceaa7d947090bb441", + "XDH2VfG4T6FGFUTcK1Qfy5DfDJFymdjQVaMnkJvxyKuC8tEPqPo3", + "3b5cf3a8b2fe75de29635904b941572a4cc1d176bcd8a258c07acf2c198ab3c3", { "isCompressed": true, "isPrivkey": true, @@ -72,8 +72,8 @@ } ], [ - "LP7Ls95NmnuWi5o9bKZrezLiyCPy1B5P1q", - "2aa075715a16b3f8fe726ae9c5c4aa044bbca054", + "XcdftPJ5mmJcdErhxWz5zpxaj4h3zudfmM", + "1556b380420e9c01e2fe3292fee91575f410e5bc", { "addrType": "pubkey", "isPrivkey": false, @@ -108,8 +108,8 @@ } ], [ - "6vs3xk3YxdBcHAA12Y63qwALButouE5SBzZUnBzCq5N8wvMjnZ9", - "e5686121b71c57364887d32d7b90885af98ebd96972bd1c00a6bd2a8f1f35b45", + "7rdxt8URGT7F3SzRkX8p82qYiXGGPrawLAfGBbY1foxVVxkaVGt", + "8f47a99a637f77344819eaf3a8c218aab7805b9747b21d4de0fed2c4ee612332", { "isCompressed": false, "isPrivkey": true, @@ -117,8 +117,8 @@ } ], [ - "T4rLdfaJrCLN3uemQQoi1nAhXSAFwepDX4Ahjw8EjVP27Avmjzo4", - "35b0165377348a7ba55184f5a30834e7b5ba20dcb3ed4c7bb330e1dc631b050f", + "XKLwepHXAP8g8h3yr9SVnbmMnCsV8mjABG8uaJrNBnV7h2CjM8Sj", + "f066fb8fc19b887841e3a100303b871a22a185545008bfc6170788deb4c4978a", { "isCompressed": true, "isPrivkey": true, @@ -144,8 +144,8 @@ } ], [ - "LdaHb6WXgyf38F96JweN9XNWKJS91iCLNF", - "c94ab72be12aa1a05f1af875f7250333e5d27aa2", + "XoCWrh9XbkyLJ8GGXuDK45j36FUtftWzWA", + "893e260917577a6f45144a88a3b958fb1f696c2d", { "addrType": "pubkey", "isPrivkey": false, @@ -180,8 +180,8 @@ } ], [ - "6uQT9bdxJhE83M8RjCQfo7U9oaAo5ncAP5skuzemx5DeuA6hB9o", - "2550053cc3dfc32104fd3d0b1bce0e6f6e65a0564d36018f1544d9aa4764ad39", + "7qdGzxb8BSChsdztx8jjBTnJM8MsyaG8dTbxBaa9JQwP2rfTJcQ", + "0a05c28b0d73d75f4674e582e07adde4c2ce0060f2a93a253cddb9b31cb0123a", { "isCompressed": false, "isPrivkey": true, @@ -189,8 +189,8 @@ } ], [ - "T4cpoFeaPJhTCTdLfmbNmA2f2PyjJgpCWU2pcdzBwExj5F9panJ4", - "2ebc4b6d730064cf6023b006f2b4aff89a53ac04740f21d84efa6ef33d8855cd", + "XGh2Y5Zh9rmFTWwvCxuGqsuRWAJViBwty9HyZsnGNmFMTGBf4Lao", + "a138df9502fe7fb872ace38b4be6578b06451cf4a0770b0b5d8a1b0a0e83b94f", { "isCompressed": true, "isPrivkey": true, @@ -216,8 +216,8 @@ } ], [ - "LX5YLxmAJ3YKHaRc2eR2A2s1cnw6fPA4SE", - "820a3743686bf0fd46005de06cfd382bbcbd70c5", + "Xv3MqkqScoAdRVnL3q6EcxLKi22Th1u4rT", + "d44bc254e2438fa1fdb158615053787d4a6dd00c", { "addrType": "pubkey", "isPrivkey": false, @@ -252,8 +252,8 @@ } ], [ - "6usgadpSJcXjfNFqn2Cz1kgKEWYhtzANKvhBs5pAKpsoCCRRv6H", - "63252cd47897bd0380152475453e275cf504226ee82253bbc980a926b2a71689", + "7sNfR1sm45BFHiSWneetzReExhJQAQi3BFDALVioUmNC5FJHSHx", + "f03b9cf3325899c60ed5deeb461070d72da8b1ecdce897149d0130ec37684cb1", { "isCompressed": false, "isPrivkey": true, @@ -261,8 +261,8 @@ } ], [ - "T8wbMCiccPDTa3hUFT23LUXeWU1AiNpVy8MgsQMFAbPjDjpWPVod", - "afbd7a0468460c25eef3576503578ce5ff985a598e30960018ad559282b3ef3c", + "XDqucwPdppRTJCqFM84b11NGBauXqUsmMssasXT5Z8Xx62GNGVpf", + "4c47504237fe12b251342a3da22931db0ff2009af44f0a13704d317931e05914", { "isCompressed": true, "isPrivkey": true, @@ -288,8 +288,8 @@ } ], [ - "LZa2tVcdFafKLMVeEKijaJ45jvruvZSRFK", - "9d5df1006a8a175f342dd0610337331fceb45830", + "Xrm8tstPDpBqDpMsHBMNYwtcrCE9QiiEoD", + "b051eb607c19b9c0a1a895dbe46ad7e740a6472e", { "addrType": "pubkey", "isPrivkey": false, @@ -324,8 +324,8 @@ } ], [ - "6vUB9QijBguaXPMoLXK5ZwLJCZTjKKAeQxgWfZLfJvForhka5D8", - "b176f3e34ff474dea2fb3cafb19be519e6e8f34fd39166f5d5ce657154eb05d6", + "7rviGWWwQuiAqK74gabdY3h5WZavs5SxLcGN6MfMoUMprCa8Cvy", + "b54ef27b02bbdf96fe19a640b1e1296ee581c7cd1092659cfe4a18f3dd5f954a", { "isCompressed": false, "isPrivkey": true, @@ -333,8 +333,8 @@ } ], [ - "T5MCn7wUVMmffkTpoRNdW1MhWaRoSgNESC5tzeTSHie92tMBxjEZ", - "448970a2a25f412fd9fc48d9df5dee7a01ad039b824efc28663f31728b92cce2", + "XGgHcNuRiBDBnyoyr5nvbS5yhEM4s75Pq3sPREsxAnd2xGGw95U2", + "a0d767a7ec9b46fbf3460f698affa22eb6e4e174467950ae352b487280ba10e8", { "isCompressed": true, "isPrivkey": true, @@ -360,8 +360,8 @@ } ], [ - "LPJfbhKmpiDNczUF1xwL8mBpwjg22kCRiw", - "2cc4ac26bb08dfad7a40aa48b88046cfd2c930fd", + "XtBZJ3F8tjb36Hxg4N2XG3dBuS6BEfYStN", + "bfe865562306cfeca7c4a1835e4ae56adda5779c", { "addrType": "pubkey", "isPrivkey": false, @@ -396,8 +396,8 @@ } ], [ - "6vM32FdMdhMF7qS9TLDH2sTLC6wALamAk9ebRFESaUpq9yf2mbE", - "a1409598b6d7490548b3d5f3255b2c6adf487d82306a920d41362b98350b18a1", + "7qugvZ1dYDnMAmob8z4HRnYsECGazMjw7pn9rKHnN8hti8sV7XS", + "2f49ff39105bc7cbdb3e6371f6f1048f94312cf760f1fcd593a1c6ff4e0eaef3", { "isCompressed": false, "isPrivkey": true, @@ -405,8 +405,8 @@ } ], [ - "TA8YZ69RUn4NjmCJ9gaoDmxesD9bb9xzkXKHDcymJApWVKTPbYTm", - "d3362922cebe534a1cef42928fc7208c9cfa1c4413422b2af741110fe5b0c8de", + "XFnMHmeccyAyV5ZMXagUTxUvkNnm5XtYFHYny5SCg3zK47ESLk1f", + "861f8fdd0941fbb23c87cda9dce2219628048b28751062b329046f67b1771733", { "isCompressed": true, "isPrivkey": true, @@ -432,8 +432,8 @@ } ], [ - "LWzPZSe3opyEdEmRAiULVLR3zBZS3oY9Wu", - "8110cd88bfb26bfb08e0878ddb34af03fc03c8b7", + "XmKxfSvJF3L4VPzaTD9koUEzZmxDbd18zM", + "74b659c1038b31736523fcf2d56a354db9cc9e1fw", { "addrType": "pubkey", "isPrivkey": false, From 2a2d748850d120f2fe567f7273d47f7adad4f833 Mon Sep 17 00:00:00 2001 From: Norm Fasey Date: Sat, 12 Jul 2014 17:39:21 +0100 Subject: [PATCH 3/5] Fixes for bloom filter tests --- src/test/bloom_tests.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp index 4edabb45cf..629eff2ab7 100644 --- a/src/test/bloom_tests.cpp +++ b/src/test/bloom_tests.cpp @@ -10,7 +10,7 @@ using namespace std; using namespace boost::tuples; -/*BOOST_AUTO_TEST_SUITE(bloom_tests) +BOOST_AUTO_TEST_SUITE(bloom_tests) BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize) { @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak) BOOST_AUTO_TEST_CASE(bloom_create_insert_key) { - string strSecret = string("6v7hgtX6r7frdh7XDRJ3L4JRLMAn9chCgNgSccwqWdp69XfPdX6"); + string strSecret = string("7rBekcWBb6kBahTaUnsZi1PGmz7uRhNnPjURTPoi5LjUreTuie5"); CBitcoinSecret vchSecret; BOOST_CHECK(vchSecret.SetString(strSecret)); @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_key) CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); filter.Serialize(stream, SER_NETWORK, PROTOCOL_VERSION); - vector vch = ParseHex("0322ed23080000000000000001"); + vector vch = ParseHex("030a3cd2080000000000000001"); vector expected(vch.size()); for (unsigned int i = 0; i < vch.size(); i++) @@ -444,4 +444,3 @@ BOOST_AUTO_TEST_CASE(merkle_block_4_test_update_none) } BOOST_AUTO_TEST_SUITE_END() -*/ \ No newline at end of file From e6fae1152febb2ba7ea320009753f44299169617 Mon Sep 17 00:00:00 2001 From: Norm Fasey Date: Sat, 12 Jul 2014 20:28:35 +0100 Subject: [PATCH 4/5] Fixes to Checkpoints Unit Tests --- src/test/Checkpoints_tests.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/test/Checkpoints_tests.cpp b/src/test/Checkpoints_tests.cpp index e40e6b617a..2b681d2dda 100644 --- a/src/test/Checkpoints_tests.cpp +++ b/src/test/Checkpoints_tests.cpp @@ -10,26 +10,25 @@ using namespace std; -/*BOOST_AUTO_TEST_SUITE(Checkpoints_tests) +BOOST_AUTO_TEST_SUITE(Checkpoints_tests) BOOST_AUTO_TEST_CASE(sanity) { - uint256 p1500 = uint256("0x841a2965955dd288cfa707a755d05a54e45f8bd476835ec9af4402a2b59a2967"); - uint256 p120000 = uint256("0xbd9d26924f05f6daa7f0155f32828ec89e8e29cee9e7121b026a7a3552ac6131"); + uint256 p1500 = uint256("0x000000aaf0300f59f49bc3e970bad15c11f961fe2347accffff19d96ec9778e3"); + uint256 p88805 = uint256("0x00000000001392f1652e9bf45cd8bc79dc60fe935277cd11538565b4a94fa85f"); BOOST_CHECK(Checkpoints::CheckBlock(1500, p1500)); - BOOST_CHECK(Checkpoints::CheckBlock(120000, p120000)); + BOOST_CHECK(Checkpoints::CheckBlock(88805, p88805)); + - // Wrong hashes at checkpoints should fail: - BOOST_CHECK(!Checkpoints::CheckBlock(1500, p120000)); - BOOST_CHECK(!Checkpoints::CheckBlock(120000, p1500)); + BOOST_CHECK(!Checkpoints::CheckBlock(1500, p88805)); + BOOST_CHECK(!Checkpoints::CheckBlock(88805, p1500)); // ... but any hash not at a checkpoint should succeed: - BOOST_CHECK(Checkpoints::CheckBlock(1500+1, p120000)); - BOOST_CHECK(Checkpoints::CheckBlock(120000+1, p1500)); + BOOST_CHECK(Checkpoints::CheckBlock(1500+1, p88805)); + BOOST_CHECK(Checkpoints::CheckBlock(88805+1, p1500)); - BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 120000); -} + BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 88805); +} BOOST_AUTO_TEST_SUITE_END() -*/ \ No newline at end of file From 4876caf3b6310f44cc736745ea0675740246c033 Mon Sep 17 00:00:00 2001 From: Norm Fasey Date: Sun, 13 Jul 2014 00:01:53 +0100 Subject: [PATCH 5/5] Fixes for Keys Unit Tests --- src/test/key_tests.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index 1e9154e1d0..ce19e2eb5e 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -10,14 +10,14 @@ using namespace std; -/*static const string strSecret1 ("6uu5bsZLA2Lm6yCxgwxDxHyZmhYeqBMLQT83Fyq738YhYucQPQf"); -static const string strSecret2 ("6vZDRwYgTNidWzmKs9x8QzQGeWCqbdUtNRpEKZMaP67ZSn8XMjb"); -static const string strSecret1C ("T6UsJv9hYpvDfM5noKYkB3vfeHxhyegkeWJ4y7qKeQJuyXMK11XX"); -static const string strSecret2C ("T9PBs5kq9QrkBPxeGNWKitMi4XuFVr25jaXTnuopLVZxCUAJbixA"); -static const CBitcoinAddress addr1 ("LWaFezDtucfCA4xcVEfs3R3xfgGWjSwcZr"); -static const CBitcoinAddress addr2 ("LXwHM6mRd432EzLJYwuKQMPhTzrgr7ur9K"); -static const CBitcoinAddress addr1C("LZWK8h7C166niP6GmpUmiGrvn4oxPqQgFV"); -static const CBitcoinAddress addr2C("Lgb6tdqmdW3n5E12johSuEAqRMt4kAr7yu"); +static const string strSecret1 ("7qjmhxk9D41VG4izTKS4MwNQ5cdYsHMCujtZmtnYcBZV5MyymW6"); +static const string strSecret2 ("7qtc7ho6k4y6gYxXYZZA9RMM8ecJxDrVXE4ecs5jPEvWz2Cd6ug"); +static const string strSecret1C ("XJopfZ4NEgzmU8WFaq8gSkcB2oDYCvZa2Dbn88PpGHX3xWTvxbDw"); +static const string strSecret2C ("XGwcaG95SeuQ9xUxyMPNk77UTd5U3EW4gYfXa9xU8oFzEfnKJQgr"); +static const CBitcoinAddress addr1 ("XtgBkqNm1KdNqwtPXgcrx3XtTETsPJ3imW"); +static const CBitcoinAddress addr2 ("XvSYzd8yGM4yBwcdWqF3wJtQ9543G2zUNh"); +static const CBitcoinAddress addr1C("Xv2y1Z6MH3oPWLQpowdJSAT56eSjpEaRBb"); +static const CBitcoinAddress addr2C("Xo5kbBBVQ52ZLfarQYFpG8Mt5XQ4phJBa6"); static const string strAddressBad("LRjyUS2uuieEPkhZNdQz8hE5YycxVEqSXA"); @@ -97,21 +97,21 @@ BOOST_AUTO_TEST_CASE(key_test1) BOOST_CHECK( pubkey1.Verify(hashMsg, sign1)); BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2)); - BOOST_CHECK( pubkey1.Verify(hashMsg, sign1C)); + BOOST_CHECK(!pubkey1.Verify(hashMsg, sign1C)); BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2C)); BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1)); BOOST_CHECK( pubkey2.Verify(hashMsg, sign2)); BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1C)); - BOOST_CHECK( pubkey2.Verify(hashMsg, sign2C)); + BOOST_CHECK(!pubkey2.Verify(hashMsg, sign2C)); - BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1)); + BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign1)); BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2)); BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1C)); BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2C)); BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1)); - BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2)); + BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign2)); BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1C)); BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2C)); @@ -139,4 +139,3 @@ BOOST_AUTO_TEST_CASE(key_test1) } BOOST_AUTO_TEST_SUITE_END() -*/ \ No newline at end of file