-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_runner.cpp
More file actions
99 lines (80 loc) · 1.74 KB
/
test_runner.cpp
File metadata and controls
99 lines (80 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#define BOOST_TEST_MODULE DNotes Test Suite
#include <boost/test/unit_test.hpp>
#include <test/test_runner.h>
#include "chainparams.h"
#include "util.h"
#include "miner.h"
#include "txdb.h"
#include <fs.h>
fs::path pathTest;
CWallet* ptestWallet;
void CreateTestFolders()
{
pathTest = fs::temp_directory_path() / strprintf("test_bitcoin_%lu", (unsigned long)GetTime());
fs::create_directories(pathTest);
SoftSetArg("-datadir", pathTest.string());
}
void DeleteTestFolders()
{
fs::remove_all(pathTest);
}
void SetupDatabase()
{
bitdb.Open(GetDataDir());
CTxDB txdb("cr");
LoadBlockIndex();
}
void CleanupDatabase()
{
}
void SetupWallet()
{
std::string strWalletFileName = "wallet.dat";
ptestWallet = new CWallet(strWalletFileName);
RegisterWallet(ptestWallet);
}
void CleanupWallet()
{
UnregisterWallet(ptestWallet);
bitdb.Flush(true);
delete ptestWallet;
ptestWallet = NULL;
}
struct TestingSetup {
TestingSetup() {
SelectParams(CChainParams::REGTEST);
CreateTestFolders();
SetupDatabase();
SetupWallet();
//fPrintToConsole = true;
}
~TestingSetup()
{
CleanupDatabase();
CleanupWallet();
DeleteTestFolders();
}
};
BOOST_GLOBAL_FIXTURE(TestingSetup);
void Shutdown(void* parg)
{
exit(0);
}
std::string string_to_hex(const std::string& input)
{
static const char* const lut = "0123456789ABCDEF";
size_t len = input.length();
std::string output;
output.reserve(2 * len);
for (size_t i = 0; i < len; ++i)
{
const unsigned char c = input[i];
output.push_back(lut[c >> 4]);
output.push_back(lut[c & 15]);
}
return "0x" + output;
}
//void StartShutdown()
//{
// exit(0);
//}