|
|
@ -10,18 +10,16 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include <boost/test/unit_test.hpp> |
|
|
|
#include <boost/test/unit_test.hpp> |
|
|
|
|
|
|
|
|
|
|
|
extern std::unique_ptr<CWallet> pwalletMain; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_FIXTURE_TEST_SUITE(accounting_tests, WalletTestingSetup) |
|
|
|
BOOST_FIXTURE_TEST_SUITE(accounting_tests, WalletTestingSetup) |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
static void |
|
|
|
GetResults(std::map<CAmount, CAccountingEntry>& results) |
|
|
|
GetResults(CWallet *wallet, std::map<CAmount, CAccountingEntry>& results) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::list<CAccountingEntry> aes; |
|
|
|
std::list<CAccountingEntry> aes; |
|
|
|
|
|
|
|
|
|
|
|
results.clear(); |
|
|
|
results.clear(); |
|
|
|
BOOST_CHECK(pwalletMain->ReorderTransactions() == DB_LOAD_OK); |
|
|
|
BOOST_CHECK(wallet->ReorderTransactions() == DB_LOAD_OK); |
|
|
|
pwalletMain->ListAccountCreditDebit("", aes); |
|
|
|
wallet->ListAccountCreditDebit("", aes); |
|
|
|
for (CAccountingEntry& ae : aes) |
|
|
|
for (CAccountingEntry& ae : aes) |
|
|
|
{ |
|
|
|
{ |
|
|
|
results[ae.nOrderPos] = ae; |
|
|
|
results[ae.nOrderPos] = ae; |
|
|
@ -54,7 +52,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade) |
|
|
|
ae.strOtherAccount = "c"; |
|
|
|
ae.strOtherAccount = "c"; |
|
|
|
pwalletMain->AddAccountingEntry(ae); |
|
|
|
pwalletMain->AddAccountingEntry(ae); |
|
|
|
|
|
|
|
|
|
|
|
GetResults(results); |
|
|
|
GetResults(pwalletMain.get(), results); |
|
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK(pwalletMain->nOrderPosNext == 3); |
|
|
|
BOOST_CHECK(pwalletMain->nOrderPosNext == 3); |
|
|
|
BOOST_CHECK(2 == results.size()); |
|
|
|
BOOST_CHECK(2 == results.size()); |
|
|
@ -70,7 +68,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade) |
|
|
|
ae.nOrderPos = pwalletMain->IncOrderPosNext(); |
|
|
|
ae.nOrderPos = pwalletMain->IncOrderPosNext(); |
|
|
|
pwalletMain->AddAccountingEntry(ae); |
|
|
|
pwalletMain->AddAccountingEntry(ae); |
|
|
|
|
|
|
|
|
|
|
|
GetResults(results); |
|
|
|
GetResults(pwalletMain.get(), results); |
|
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK(results.size() == 3); |
|
|
|
BOOST_CHECK(results.size() == 3); |
|
|
|
BOOST_CHECK(pwalletMain->nOrderPosNext == 4); |
|
|
|
BOOST_CHECK(pwalletMain->nOrderPosNext == 4); |
|
|
@ -102,7 +100,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade) |
|
|
|
vpwtx[2]->nTimeReceived = (unsigned int)1333333329; |
|
|
|
vpwtx[2]->nTimeReceived = (unsigned int)1333333329; |
|
|
|
vpwtx[2]->nOrderPos = -1; |
|
|
|
vpwtx[2]->nOrderPos = -1; |
|
|
|
|
|
|
|
|
|
|
|
GetResults(results); |
|
|
|
GetResults(pwalletMain.get(), results); |
|
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK(results.size() == 3); |
|
|
|
BOOST_CHECK(results.size() == 3); |
|
|
|
BOOST_CHECK(pwalletMain->nOrderPosNext == 6); |
|
|
|
BOOST_CHECK(pwalletMain->nOrderPosNext == 6); |
|
|
@ -120,7 +118,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade) |
|
|
|
ae.nOrderPos = -1; |
|
|
|
ae.nOrderPos = -1; |
|
|
|
pwalletMain->AddAccountingEntry(ae); |
|
|
|
pwalletMain->AddAccountingEntry(ae); |
|
|
|
|
|
|
|
|
|
|
|
GetResults(results); |
|
|
|
GetResults(pwalletMain.get(), results); |
|
|
|
|
|
|
|
|
|
|
|
BOOST_CHECK(results.size() == 4); |
|
|
|
BOOST_CHECK(results.size() == 4); |
|
|
|
BOOST_CHECK(pwalletMain->nOrderPosNext == 7); |
|
|
|
BOOST_CHECK(pwalletMain->nOrderPosNext == 7); |
|
|
|