]> Git Repo - VerusCoin.git/blobdiff - src/test/alert_tests.cpp
Cleanup code using forward declarations.
[VerusCoin.git] / src / test / alert_tests.cpp
index f7a11376d34e68c9702c2ffc873a80e65eaa0fd1..adfbec9decaa1b0f02677f92acfdcadf72d2aaf3 100644 (file)
@@ -2,13 +2,18 @@
 // Unit tests for alert system
 //
 
-#include <boost/foreach.hpp>
-#include <boost/test/unit_test.hpp>
-#include <fstream>
-
 #include "alert.h"
+#include "data/alertTests.raw.h"
+
 #include "serialize.h"
 #include "util.h"
+#include "version.h"
+
+#include <fstream>
+
+#include <boost/filesystem/operations.hpp>
+#include <boost/foreach.hpp>
+#include <boost/test/unit_test.hpp>
 
 #if 0
 //
@@ -71,27 +76,13 @@ struct ReadAlerts
 {
     ReadAlerts()
     {
-        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;
-
+        std::vector<unsigned char> vch(alert_tests::alertTests, alert_tests::alertTests + sizeof(alert_tests::alertTests));
+        CDataStream stream(vch, SER_DISK, CLIENT_VERSION);
         try {
-            while (!feof(filein))
+            while (stream.good())
             {
                 CAlert alert;
-                filein >> alert;
+                stream >> alert;
                 alerts.push_back(alert);
             }
         }
@@ -125,6 +116,9 @@ BOOST_AUTO_TEST_CASE(AlertApplies)
     {
         BOOST_CHECK(alert.CheckSignature());
     }
+
+    BOOST_CHECK(alerts.size() >= 3);
+
     // Matches:
     BOOST_CHECK(alerts[0].AppliesTo(1, ""));
     BOOST_CHECK(alerts[0].AppliesTo(70001, ""));
This page took 0.021084 seconds and 4 git commands to generate.