forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoin#14023: Remove accounts rpcs
bb08423 [doc] Add release notes for 'account' API removal (John Newbery) 1f4b865 [wallet] Re-sort wallet RPC commands (John Newbery) f0dc850 [wallet] Remove wallet account RPCs (John Newbery) c410f41 [tests] Remove wallet accounts test (John Newbery) Pull request description: This is the first part of bitcoin#13825. It simply removes the RPC methods and tests. bitcoin#13825 touches lots of files and will require frequent rebasing. Breaking it down for easier reviewing and fewer rebases. Tree-SHA512: d29af8e7a035e4484e6b9bb56cb86592be0ec112d8ba4ce19c15d15366ff3086e89e99fca26b90c9d66f6d3e06894486d0f29948df0bb7dcb1e2c49c6887a85a
- Loading branch information
Showing
8 changed files
with
105 additions
and
1,014 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,137 +0,0 @@ | ||
// Copyright (c) 2012-2015 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include <wallet/wallet.h> | ||
#include <validation.h> // for cs_main because of AddToWallet | ||
|
||
#include <wallet/test/wallet_test_fixture.h> | ||
|
||
#include <stdint.h> | ||
|
||
#include <boost/test/unit_test.hpp> | ||
|
||
BOOST_FIXTURE_TEST_SUITE(accounting_tests, WalletTestingSetup) | ||
|
||
static void | ||
GetResults(CWallet& wallet, std::map<CAmount, CAccountingEntry>& results) | ||
{ | ||
std::list<CAccountingEntry> aes; | ||
|
||
results.clear(); | ||
BOOST_CHECK(wallet.ReorderTransactions() == DBErrors::LOAD_OK); | ||
wallet.ListAccountCreditDebit("", aes); | ||
for (CAccountingEntry& ae : aes) | ||
{ | ||
results[ae.nOrderPos] = ae; | ||
} | ||
} | ||
|
||
BOOST_AUTO_TEST_CASE(acc_orderupgrade) | ||
{ | ||
std::vector<CWalletTx*> vpwtx; | ||
CWalletTx wtx(nullptr /* pwallet */, MakeTransactionRef()); | ||
CAccountingEntry ae; | ||
std::map<CAmount, CAccountingEntry> results; | ||
|
||
LOCK2(cs_main, m_wallet.cs_wallet); | ||
|
||
ae.strAccount = ""; | ||
ae.nCreditDebit = 1; | ||
ae.nTime = 1333333333; | ||
ae.strOtherAccount = "b"; | ||
ae.strComment = ""; | ||
m_wallet.AddAccountingEntry(ae); | ||
|
||
wtx.mapValue["comment"] = "z"; | ||
m_wallet.AddToWallet(wtx); | ||
vpwtx.push_back(&m_wallet.mapWallet.at(wtx.GetHash())); | ||
vpwtx[0]->nTimeReceived = (unsigned int)1333333335; | ||
vpwtx[0]->nOrderPos = -1; | ||
|
||
ae.nTime = 1333333336; | ||
ae.strOtherAccount = "c"; | ||
m_wallet.AddAccountingEntry(ae); | ||
|
||
GetResults(m_wallet, results); | ||
|
||
BOOST_CHECK(m_wallet.nOrderPosNext == 3); | ||
BOOST_CHECK(2 == results.size()); | ||
BOOST_CHECK(results[0].nTime == 1333333333); | ||
BOOST_CHECK(results[0].strComment.empty()); | ||
BOOST_CHECK(1 == vpwtx[0]->nOrderPos); | ||
BOOST_CHECK(results[2].nTime == 1333333336); | ||
BOOST_CHECK(results[2].strOtherAccount == "c"); | ||
|
||
|
||
ae.nTime = 1333333330; | ||
ae.strOtherAccount = "d"; | ||
ae.nOrderPos = m_wallet.IncOrderPosNext(); | ||
m_wallet.AddAccountingEntry(ae); | ||
|
||
GetResults(m_wallet, results); | ||
|
||
BOOST_CHECK(results.size() == 3); | ||
BOOST_CHECK(m_wallet.nOrderPosNext == 4); | ||
BOOST_CHECK(results[0].nTime == 1333333333); | ||
BOOST_CHECK(1 == vpwtx[0]->nOrderPos); | ||
BOOST_CHECK(results[2].nTime == 1333333336); | ||
BOOST_CHECK(results[3].nTime == 1333333330); | ||
BOOST_CHECK(results[3].strComment.empty()); | ||
|
||
|
||
wtx.mapValue["comment"] = "y"; | ||
{ | ||
CMutableTransaction tx(*wtx.tx); | ||
++tx.nLockTime; // Just to change the hash :) | ||
wtx.SetTx(MakeTransactionRef(std::move(tx))); | ||
} | ||
m_wallet.AddToWallet(wtx); | ||
vpwtx.push_back(&m_wallet.mapWallet.at(wtx.GetHash())); | ||
vpwtx[1]->nTimeReceived = (unsigned int)1333333336; | ||
|
||
wtx.mapValue["comment"] = "x"; | ||
{ | ||
CMutableTransaction tx(*wtx.tx); | ||
++tx.nLockTime; // Just to change the hash :) | ||
wtx.SetTx(MakeTransactionRef(std::move(tx))); | ||
} | ||
m_wallet.AddToWallet(wtx); | ||
vpwtx.push_back(&m_wallet.mapWallet.at(wtx.GetHash())); | ||
vpwtx[2]->nTimeReceived = (unsigned int)1333333329; | ||
vpwtx[2]->nOrderPos = -1; | ||
|
||
GetResults(m_wallet, results); | ||
|
||
BOOST_CHECK(results.size() == 3); | ||
BOOST_CHECK(m_wallet.nOrderPosNext == 6); | ||
BOOST_CHECK(0 == vpwtx[2]->nOrderPos); | ||
BOOST_CHECK(results[1].nTime == 1333333333); | ||
BOOST_CHECK(2 == vpwtx[0]->nOrderPos); | ||
BOOST_CHECK(results[3].nTime == 1333333336); | ||
BOOST_CHECK(results[4].nTime == 1333333330); | ||
BOOST_CHECK(results[4].strComment.empty()); | ||
BOOST_CHECK(5 == vpwtx[1]->nOrderPos); | ||
|
||
|
||
ae.nTime = 1333333334; | ||
ae.strOtherAccount = "e"; | ||
ae.nOrderPos = -1; | ||
m_wallet.AddAccountingEntry(ae); | ||
|
||
GetResults(m_wallet, results); | ||
|
||
BOOST_CHECK(results.size() == 4); | ||
BOOST_CHECK(m_wallet.nOrderPosNext == 7); | ||
BOOST_CHECK(0 == vpwtx[2]->nOrderPos); | ||
BOOST_CHECK(results[1].nTime == 1333333333); | ||
BOOST_CHECK(2 == vpwtx[0]->nOrderPos); | ||
BOOST_CHECK(results[3].nTime == 1333333336); | ||
BOOST_CHECK(results[3].strComment.empty()); | ||
BOOST_CHECK(results[4].nTime == 1333333330); | ||
BOOST_CHECK(results[4].strComment.empty()); | ||
BOOST_CHECK(results[5].nTime == 1333333334); | ||
BOOST_CHECK(6 == vpwtx[1]->nOrderPos); | ||
} | ||
|
||
BOOST_AUTO_TEST_SUITE_END() | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.