aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_dogecoin.cpp
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2014-03-29 23:54:34 +0000
committerRoss Nicoll <[email protected]>2014-03-31 18:41:38 +0100
commite4be2ac7e7d83c1f3ca701d3a2bca0361e5aefed (patch)
tree4416e2510d30eb11e2c35bfd70b27dff5b05619c /src/test/test_dogecoin.cpp
parentRemoved scrypt.cpp from server library, as it's already present in the common... (diff)
downloaddiscoin-e4be2ac7e7d83c1f3ca701d3a2bca0361e5aefed.tar.xz
discoin-e4be2ac7e7d83c1f3ca701d3a2bca0361e5aefed.zip
Added new libbitcoin_server_wallet to hold code which depends on
the server code, and which in turn is depended upon by the wallet. Renamed bitcoin tests to dogecoin.
Diffstat (limited to 'src/test/test_dogecoin.cpp')
-rw-r--r--src/test/test_dogecoin.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/test/test_dogecoin.cpp b/src/test/test_dogecoin.cpp
new file mode 100644
index 000000000..96d071240
--- /dev/null
+++ b/src/test/test_dogecoin.cpp
@@ -0,0 +1,82 @@
+#define BOOST_TEST_MODULE Bitcoin Test Suite
+
+
+
+#include "main.h"
+#include "txdb.h"
+#include "ui_interface.h"
+#include "util.h"
+#ifdef ENABLE_WALLET
+#include "db.h"
+#include "wallet.h"
+#endif
+
+#include <boost/filesystem.hpp>
+#include <boost/test/unit_test.hpp>
+
+
+CWallet* pwalletMain;
+
+extern bool fPrintToConsole;
+extern void noui_connect();
+
+struct TestingSetup {
+ CCoinsViewDB *pcoinsdbview;
+ boost::filesystem::path pathTemp;
+ boost::thread_group threadGroup;
+
+ TestingSetup() {
+ fPrintToDebugLog = false; // don't want to write to debug.log file
+ noui_connect();
+#ifdef ENABLE_WALLET
+ bitdb.MakeMock();
+#endif
+ pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
+ boost::filesystem::create_directories(pathTemp);
+ mapArgs["-datadir"] = pathTemp.string();
+ pblocktree = new CBlockTreeDB(1 << 20, true);
+ pcoinsdbview = new CCoinsViewDB(1 << 23, true);
+ pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
+ InitBlockIndex();
+#ifdef ENABLE_WALLET
+ bool fFirstRun;
+ pwalletMain = new CWallet("wallet.dat");
+ pwalletMain->LoadWallet(fFirstRun);
+ RegisterWallet(pwalletMain);
+#endif
+ nScriptCheckThreads = 3;
+ for (int i=0; i < nScriptCheckThreads-1; i++)
+ threadGroup.create_thread(&ThreadScriptCheck);
+ RegisterNodeSignals(GetNodeSignals());
+ }
+ ~TestingSetup()
+ {
+ threadGroup.interrupt_all();
+ threadGroup.join_all();
+ UnregisterNodeSignals(GetNodeSignals());
+#ifdef ENABLE_WALLET
+ delete pwalletMain;
+ pwalletMain = NULL;
+#endif
+ delete pcoinsTip;
+ delete pcoinsdbview;
+ delete pblocktree;
+#ifdef ENABLE_WALLET
+ bitdb.Flush(true);
+#endif
+ boost::filesystem::remove_all(pathTemp);
+ }
+};
+
+BOOST_GLOBAL_FIXTURE(TestingSetup);
+
+void Shutdown(void* parg)
+{
+ exit(0);
+}
+
+void StartShutdown()
+{
+ exit(0);
+}
+