@ -3,7 +3,6 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
# include "wallet/wallet.h"
# include "wallet/wallet.h"
# include "wallet/walletdb.h"
# include "wallet/test/wallet_test_fixture.h"
# include "wallet/test/wallet_test_fixture.h"
@ -17,13 +16,13 @@ extern CWallet* pwalletMain;
BOOST_FIXTURE_TEST_SUITE ( accounting_tests , WalletTestingSetup )
BOOST_FIXTURE_TEST_SUITE ( accounting_tests , WalletTestingSetup )
static void
static void
GetResults ( CWalletDB & walletdb , std : : map < CAmount , CAccountingEntry > & results )
GetResults ( std : : map < CAmount , CAccountingEntry > & results )
{
{
std : : list < CAccountingEntry > aes ;
std : : list < CAccountingEntry > aes ;
results . clear ( ) ;
results . clear ( ) ;
BOOST_CHECK ( walletdb . ReorderTransactions ( pwalletMain ) = = DB_LOAD_OK ) ;
BOOST_CHECK ( pwalletMain - > ReorderTransactions ( ) = = DB_LOAD_OK ) ;
walletdb . ListAccountCreditDebit ( " " , aes ) ;
pwalletMain - > ListAccountCreditDebit ( " " , aes ) ;
BOOST_FOREACH ( CAccountingEntry & ae , aes )
BOOST_FOREACH ( CAccountingEntry & ae , aes )
{
{
results [ ae . nOrderPos ] = ae ;
results [ ae . nOrderPos ] = ae ;
@ -32,7 +31,6 @@ GetResults(CWalletDB& walletdb, std::map<CAmount, CAccountingEntry>& results)
BOOST_AUTO_TEST_CASE ( acc_orderupgrade )
BOOST_AUTO_TEST_CASE ( acc_orderupgrade )
{
{
CWalletDB walletdb ( pwalletMain - > strWalletFile ) ;
std : : vector < CWalletTx * > vpwtx ;
std : : vector < CWalletTx * > vpwtx ;
CWalletTx wtx ;
CWalletTx wtx ;
CAccountingEntry ae ;
CAccountingEntry ae ;
@ -45,7 +43,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
ae . nTime = 1333333333 ;
ae . nTime = 1333333333 ;
ae . strOtherAccount = " b " ;
ae . strOtherAccount = " b " ;
ae . strComment = " " ;
ae . strComment = " " ;
pwalletMain - > AddAccountingEntry ( ae , walletdb ) ;
pwalletMain - > AddAccountingEntry ( ae ) ;
wtx . mapValue [ " comment " ] = " z " ;
wtx . mapValue [ " comment " ] = " z " ;
pwalletMain - > AddToWallet ( wtx ) ;
pwalletMain - > AddToWallet ( wtx ) ;
@ -55,9 +53,9 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
ae . nTime = 1333333336 ;
ae . nTime = 1333333336 ;
ae . strOtherAccount = " c " ;
ae . strOtherAccount = " c " ;
pwalletMain - > AddAccountingEntry ( ae , walletdb ) ;
pwalletMain - > AddAccountingEntry ( ae ) ;
GetResults ( walletdb , results ) ;
GetResults ( results ) ;
BOOST_CHECK ( pwalletMain - > nOrderPosNext = = 3 ) ;
BOOST_CHECK ( pwalletMain - > nOrderPosNext = = 3 ) ;
BOOST_CHECK ( 2 = = results . size ( ) ) ;
BOOST_CHECK ( 2 = = results . size ( ) ) ;
@ -71,9 +69,9 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
ae . nTime = 1333333330 ;
ae . nTime = 1333333330 ;
ae . strOtherAccount = " d " ;
ae . strOtherAccount = " d " ;
ae . nOrderPos = pwalletMain - > IncOrderPosNext ( ) ;
ae . nOrderPos = pwalletMain - > IncOrderPosNext ( ) ;
pwalletMain - > AddAccountingEntry ( ae , walletdb ) ;
pwalletMain - > AddAccountingEntry ( ae ) ;
GetResults ( walletdb , results ) ;
GetResults ( results ) ;
BOOST_CHECK ( results . size ( ) = = 3 ) ;
BOOST_CHECK ( results . size ( ) = = 3 ) ;
BOOST_CHECK ( pwalletMain - > nOrderPosNext = = 4 ) ;
BOOST_CHECK ( pwalletMain - > nOrderPosNext = = 4 ) ;
@ -105,7 +103,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 ( walletdb , results ) ;
GetResults ( results ) ;
BOOST_CHECK ( results . size ( ) = = 3 ) ;
BOOST_CHECK ( results . size ( ) = = 3 ) ;
BOOST_CHECK ( pwalletMain - > nOrderPosNext = = 6 ) ;
BOOST_CHECK ( pwalletMain - > nOrderPosNext = = 6 ) ;
@ -121,9 +119,9 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
ae . nTime = 1333333334 ;
ae . nTime = 1333333334 ;
ae . strOtherAccount = " e " ;
ae . strOtherAccount = " e " ;
ae . nOrderPos = - 1 ;
ae . nOrderPos = - 1 ;
pwalletMain - > AddAccountingEntry ( ae , walletdb ) ;
pwalletMain - > AddAccountingEntry ( ae ) ;
GetResults ( walletdb , results ) ;
GetResults ( results ) ;
BOOST_CHECK ( results . size ( ) = = 4 ) ;
BOOST_CHECK ( results . size ( ) = = 4 ) ;
BOOST_CHECK ( pwalletMain - > nOrderPosNext = = 7 ) ;
BOOST_CHECK ( pwalletMain - > nOrderPosNext = = 7 ) ;