aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/test/wallet_tests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Correct build and test net seedRoss Nicoll2019-04-281-1/+1
| | | | | * Correct the test case from 100 blocks to 240 * Remove incorrect ", true" in testnet seed configuration
* Replace test data with Dogecoin valuesRoss Nicoll2019-04-031-12/+15
| | | | | | | | | | | | | | | | | | | | Replace test data with Dogecoin equivalents in the folowing tests: * base58 * bip32 * keys * miner * pow * wallet Replace RPC and deterministic signatures in unit tests with Dogecoin values. While conventionally I'd use an alternative implementation for these, as RFC 6979 compliant signature generation isn't terribly common, and there's no reason to suspect we've modified this code, I'm going to assert that it's good enough to test that the code doesn't provide different values. Disabled Bitcoin PoW tests, but left code in place to simplify later merges. These are replaced by the Dogecoin PoW tests.
* CreateTransaction: Assume minimum p2sh-p2wpkh spend size for unknown changeGregory Sanders2018-11-301-0/+44
|
* Update copyright headers to 2018DrahtBot2018-07-271-1/+1
|
* Merge #9662: Add createwallet "disableprivatekeys" option: a sane mode for ↵Wladimir J. van der Laan2018-07-201-0/+9
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | watchonly-wallets a3fa4d6a6acf19d640a1d5879a00aa1f059e2380 QA: Fix bug in -usecli logic that converts booleans to non-lowercase strings (Jonas Schnelli) 4704e5f074e57782d058404a594a7313cf170cf0 [QA] add createwallet disableprivatekey test (Jonas Schnelli) c7b8f343e99d9d53ea353ddce9a977f1886caf30 [Qt] Disable creating receive addresses when private keys are disabled (Jonas Schnelli) 2f15c2bc20d583b4c1788da78c9c635c36e03ed0 Add disable privatekeys option to createwallet (Jonas Schnelli) cebefba0855cee7fbcb9474b34e6779369e8e9ce Add option to disable private keys during internal wallet creation (Jonas Schnelli) 9995a602a639b64a749545b7c3bafbf67f97324f Add facility to store wallet flags (64 bits) (Jonas Schnelli) Pull request description: This mode ('createwallet {"disableprivatekeys": true}') is intended for a sane pure watch-only mode, ideal for a use-case where one likes to use Bitcoin-Core in conjunction with a hardware-wallet or another solutions for cold-storage. Since we have support for custom change addresses in `fundrawtransaction`, pure watch-only wallets including coin-selection are possible and do make sense for some use cases. This new mode disables all forms of private key generation and ensure that no mix between hot and cold keys are possible. Tree-SHA512: 3ebe7e8d54c4d4e5f790c348d4c292d456f573960a5b04d69ca5ef43a9217c7e7671761c6968cdc56f9a8bc235f3badd358576651af9f10855a0eb731f3fc508
| * [QA] add createwallet disableprivatekey testJonas Schnelli2018-07-121-0/+9
| |
* | Use common SetDataDir method to create temp directory in tests.winder2018-07-111-2/+4
|/
* wallet: Use shared pointer to retain wallet instanceJoão Barbosa2018-05-221-15/+15
|
* wallet: Add AddWallet, RemoveWallet, GetWallet and GetWalletsJoão Barbosa2018-04-181-6/+6
| | | | | With these new functions all vpwallets usage are removed and vpwallets is now a static variable (no external linkage).
* Merge #13007: test: Fix dangling wallet pointer in vpwalletsWladimir J. van der Laan2018-04-181-2/+3
|\ | | | | | | | | | | | | | | d41a420 test: Fix dangling wallet pointer in vpwallets (João Barbosa) Pull request description: Tree-SHA512: 83e4ec571f1675b3dab6f7606f29d6fae495d998b4e5794ff14315943783d4518cfa66eba4113293e349eb74aa22a024b21272fdb29c212477edb4c09aec9fa7
| * test: Fix dangling wallet pointer in vpwalletsJoão Barbosa2018-04-171-2/+3
| |
* | tests: Avoid copies of CTransactionMarcoFalke2018-04-111-7/+7
|/
* Merge #12920: test: Fix sign for expected valuesWladimir J. van der Laan2018-04-111-11/+11
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | c55aa4f test: Fix sign for expected values (Karl-Johan Alm) Pull request description: A number of `BOOST_CHECK_EQUAL` calls would result in warnings about signs. This PR fixes signedness for all expectation values, sometimes resulting in `int` → `unsigned int`. No other code changes besides adding/removing `U` to/from values. Running `make &> make_output_...` on master versus on this PR: ``` $ wc make_output_* 1464 5925 90357 make_output_master 613 1469 28370 make_output_signfixed ``` More than halves the output lines from compiling. Tree-SHA512: b06c9fb81704fd32a6a61fe7b2ceb5f1bb381e9873d79e13d7e4d26bbd9b67c9725a84e6fb2903bcda775aea2a792e544b0799d36735c19f5d1c7225e8c6d14e
| * test: Fix sign for expected valuesKarl-Johan Alm2018-04-111-11/+11
| | | | | | | | A number of BOOST_CHECK_EQUAL calls would result in warnings about signs.
* | scripted-diff: Rename wallet database classesRussell Yanofsky2018-04-071-7/+7
|/ | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- sed -i 's/\<CWalletDBWrapper\>/BerkeleyDatabase/g' src/wallet/db.h src/wallet/db.cpp sed -i '/statuses/i/** Backend-agnostic database type. */\nusing WalletDatabase = BerkeleyDatabase\;\n' src/wallet/walletdb.h ren() { git grep -l "\<$1\>" 'src/*.cpp' 'src/*.h' ':(exclude)*dbwrapper*' test | xargs sed -i "s:\<$1\>:$2:g"; } ren CDBEnv BerkeleyEnvironment ren CDB BerkeleyBatch ren CWalletDBWrapper WalletDatabase ren CWalletDB WalletBatch ren dbw database ren m_dbw m_database ren walletdb batch ren pwalletdb batch ren pwalletdbIn batch_in ren wallet/batch.h wallet/walletdb.h ren pwalletdbEncryption encrypted_batch -END VERIFY SCRIPT-
* Merge #12859: Bugfix: Include <memory> for std::unique_ptrWladimir J. van der Laan2018-04-051-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | a5bca13 Bugfix: Include <memory> for std::unique_ptr (Luke Dashjr) Pull request description: Not sure why all these includes were missing, but it's breaking builds for some users: https://bugs.gentoo.org/show_bug.cgi?id=652142 (Added to all files with a reference to `std::unique_ptr`) Tree-SHA512: 8a2c67513ca07b9bb52c34e8a20b15e56f8af2530310d9ee9b0a69694dd05e02e7a3683f14101a2685d457672b56addec591a0bb83900a0eb8e2a43d43200509
| * Bugfix: Include <memory> for std::unique_ptrLuke Dashjr2018-04-021-0/+1
| |
* | wallet: Change output type globals to membersMarcoFalke2018-03-171-5/+0
| |
* | Merge #10637: Coin Selection with Murch's algorithmWladimir J. van der Laan2018-03-141-337/+0
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 73b5bf2cb Add a test to make sure that negative effective values are filtered (Andrew Chow) 76d2f068a Benchmark BnB in the worst case where it exhausts (Andrew Chow) 6a34ff533 Have SelectCoinsMinConf and SelectCoins use BnB or Knapsack and use it (Andrew Chow) fab04887c Add a GetMinimumFeeRate function which is wrapped by GetMinimumFee (Andrew Chow) cd927ff32 Move original knapsack solver tests to coinselector_tests.cpp (Andrew Chow) fb716f7b2 Move current coin selection algorithm to coinselection.{cpp,h} (Andrew Chow) 4566ab75f Add tests for the Branch and Bound algorithm (Andrew Chow) 4b2716da4 Remove coinselection.h -> wallet.h circular dependency (Andrew Chow) 7d77eb1a5 Use a struct for output eligibility (Andrew Chow) ce7435cf1 Move output eligibility to a separate function (Andrew Chow) 0185939be Implement Branch and Bound coin selection in a new file (Andrew Chow) f84fed8eb Store effective value, fee, and long term fee in CInputCoin (Andrew Chow) 12ec29d3b Calculate and store the number of bytes required to spend an input (Andrew Chow) Pull request description: This is an implementation of the [Branch and Bound coin selection algorithm written by Murch](http://murch.one/wp-content/uploads/2016/11/erhardt2016coinselection.pdf) (@xekyo). I have it set so this algorithm will run first and if it fails, it will fall back to the current coin selection algorithm. The coin selection algorithms and tests have been refactored to separate files instead of having them all in wallet.cpp. I have added some tests for the new algorithm and a test for all of coin selection in general. However, more tests may be needed, but I will need help with coming up with more test cases. This PR uses some code borrowed from #10360 to use effective values when selecting coins. Tree-SHA512: b0500f406bf671e74984fae78e2d0fbc5e321ddf4f06182c5855e9d1984c4ef2764c7586d03e16fa4b578c340b21710324926f9ca472d5447a0d1ed43eb4357e
| * | Move original knapsack solver tests to coinselector_tests.cppAndrew Chow2018-03-131-341/+0
| | |
| * | Use a struct for output eligibilityAndrew Chow2018-03-131-37/+41
| | | | | | | | | | | | | | | Instead of specifying 3 parameters, use a struct for those parameters in order to reduce the number of arguments to SelectCoinsMinConf.
* | | Merge #9680: Unify CWalletTx constructionPieter Wuille2018-03-131-5/+5
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | b4bc32a451 [wallet] Get rid of CWalletTx default constructor (Russell Yanofsky) a128bdc9e1 [wallet] Construct CWalletTx objects in CommitTransaction (Russell Yanofsky) Pull request description: Two commits: - `Construct CWalletTx objects in CommitTransaction` moves a bunch of CWalletTx initialization into CWallet::CommitTransaction to dedup some code and avoid future inconsistencies in how wallet transactions are created. - `Get rid of CWalletTx default constructor` does what is described and eliminates the possibility of empty transaction entries being inadvertently created by mapWallet[hash] accesses. Both of these changes were originally part of #9381 Tree-SHA512: af3841c4f0539e0662d81b33c5369fc70aa06ddde1c59cb00fb21c9e4c7d9ff47f1edc5040cb463af1333838802c56b3ef875b939e2b804ee45b8e0294a4371c
| * | | [wallet] Construct CWalletTx objects in CommitTransactionRussell Yanofsky2018-03-071-5/+5
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Construct CWalletTx objects in CWallet::CommitTransaction, instead of having callers do it. This ensures CWalletTx objects are constructed in a uniform way and all fields are set. This also makes it possible to avoid confusing and wasteful CWalletTx copies in https://github.com/bitcoin/bitcoin/pull/9381 There is no change in behavior.
* / / Fix ComputeTimeSmart test failure with -DDEBUG_LOCKORDERRussell Yanofsky2018-03-131-1/+4
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Failure looks like: Entering test case "ComputeTimeSmart" test_bitcoin: sync.cpp:100: void potential_deadlock_detected(const std::pair<void*, void*>&, const LockStack&, const LockStack&): Assertion `false' failed. unknown location(0): fatal error in "ComputeTimeSmart": signal: SIGABRT (application abort requested) wallet/test/wallet_tests.cpp(566): last checkpoint Reproducible with: ./configure --enable-debug make -C src test/test_bitcoin && src/test/test_bitcoin --log_level=test_suite --run_test=wallet_tests/ComputeTimeSmart Happens due to "92fabcd443 Add LookupBlockIndex function" which acquires cs_main from inside CWallet::ComputeTimeSmart.
* | Allow wallet files in multiple directoriesRussell Yanofsky2018-03-031-24/+19
| | | | | | | | | | | | | | | | | | Remove requirement that two wallet files can only be opened at the same time if they are contained in the same directory. This change mostly consists of updates to function signatures (updating functions to take fs::path arguments, instead of combinations of strings, fs::path, and CDBEnv / CWalletDBWrapper arguments).
* | Fix rescan test failure due to unset g_address_type, g_change_typeRussell Yanofsky2018-02-131-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New global variables were introduced in #11403 and not setting them causes: test_bitcoin: wallet/wallet.cpp:4259: CTxDestination GetDestinationForKey(const CPubKey&, OutputType): Assertion `false' failed. unknown location(0): fatal error in "importwallet_rescan": signal: SIGABRT (application abort requested) It's possible to reproduce the failure reliably by running: src/test/test_bitcoin --log_level=test_suite --run_test=wallet_tests/importwallet_rescan Failures happen nondeterministically because boost test framework doesn't run tests in a specified order, and tests that run previously can set the global variables and mask the bug.
* | [wallet] Make CWallet::ListCoins atomicJoão Barbosa2018-02-081-6/+12
| |
* | Fix typospracticalswift2018-01-281-1/+1
|/
* Make sure WalletRescanReserver has successfully reserved the rescanJonas Schnelli2018-01-231-3/+9
|
* Fix ListCoins test failure due to unset g_address_type, g_change_typeRussell Yanofsky2018-01-111-0/+2
| | | | | | | | | | | | | | | New global variables were introduced in #11403 and not setting them causes: test_bitcoin: wallet/wallet.cpp:4199: CTxDestination GetDestinationForKey(const CPubKey&, OutputType): Assertion `false' failed. unknown location(0): fatal error in "ListCoins": signal: SIGABRT (application abort requested) It's possible to reproduce the failure reliably by running: src/test/test_bitcoin --log_level=test_suite --run_test=wallet_tests/ListCoins Failures happen nondeterministically because boost test framework doesn't run tests in a specified order, and tests that run previously can set the global variables and mask the bug.
* Increment MIT Licence copyright header year on files modified in 2017Akira Takizawa2018-01-031-1/+1
|
* Require no cs_main lock for ProcessNewBlock/ActivateBestChainMatt Corallo2017-12-261-6/+11
| | | | | | This requires the removal of some very liberal (incorrect) cs_mains sprinkled in some tests. It adds some chainActive.Tip() races, but the tests are all single-threaded anyway.
* tests: move pwalletMain to wallet test fixtureWladimir J. van der Laan2017-11-181-2/+0
| | | | | | | Scope the variable instead of using an external global; this is how test fixtures are intended to be used. Followup to #11713.
* Fix for mismatched extern definition in wallet test classes which was ↵Aaron Clauson2017-11-181-1/+1
| | | | breaking msvc linking.
* scripted-diff: Replace #include "" with #include <> (ryanofsky)MeshCollider2017-11-161-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
* tests: Add missing locks to testspracticalswift2017-11-101-0/+5
| | | | | | Add missing locks to tests to satisfy lock requirements (such as EXCLUSIVE_LOCKS_REQUIRED(...) (Clang Thread Safety Analysis), AssertLockHeld(...) and implicit lock assumptions).
* [Wallet] add rescanblockchain <start_height> <stop_height> RPC commandJonas Schnelli2017-10-121-3/+3
|
* Acquire cs_main lock before cs_wallet during wallet initializationRussell Yanofsky2017-08-241-7/+10
| | | | | | | | | | | | | | | | | CWallet::MarkConflicted may acquire the cs_main lock after CWalletDB::LoadWallet acquires the cs_wallet lock during wallet initialization. (CWalletDB::LoadWallet calls ReadKeyValue which calls CWallet::LoadToWallet which calls CWallet::MarkConflicted). This is the opposite order that cs_main and cs_wallet locks are acquired in the rest of the code, and so leads to POTENTIAL DEADLOCK DETECTED errors if bitcoin is built with -DDEBUG_LOCKORDER. This commit changes CWallet::LoadWallet (which calls CWalletDB::LoadWallet) to acquire both locks in the standard order. It also fixes some tests that were acquiring wallet and main locks out of order and failed with the new locking in CWallet::LoadWallet. Error was reported by Luke Dashjr <[email protected]> in https://botbot.me/freenode/bitcoin-core-dev/msg/90244330/
* test: Make sure wallet.backup is created in temp pathWladimir J. van der Laan2017-07-251-2/+2
| | | | | | | | | This assures that we don't overwrite a random file called `wallet.backup` that happens to be in the current directory. It also assures that the temporary file will be cleaned up. Noticed by Evan Klitzke, came up in discussion here: https://github.com/bitcoin/bitcoin/pull/10880#discussion_r128460722
* Make CoinControl a required argument to CreateTransactionAlex Morcos2017-07-141-1/+3
|
* Merge #8694: Basic multiwallet supportWladimir J. van der Laan2017-06-121-7/+7
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | c237bd7 wallet: Update formatting (Luke Dashjr) 9cbe8c8 wallet: Forbid -salvagewallet, -zapwallettxes, and -upgradewallet with multiple wallets (Luke Dashjr) a2a5f3f wallet: Base backup filenames on original wallet filename (Luke Dashjr) b823a4c wallet: Include actual backup filename in recovery warning message (Luke Dashjr) 84dcb45 Bugfix: wallet: Fix warningStr, errorStr argument order (Luke Dashjr) 008c360 Wallet: Move multiwallet sanity checks to CWallet::Verify, and do other checks on all wallets (Luke Dashjr) 0f08575 Wallet: Support loading multiple wallets if -wallet used more than once (Luke Dashjr) b124cf0 Wallet: Replace pwalletMain with a vector of wallet pointers (Luke Dashjr) 19b3648 CWalletDB: Store the update counter per wallet (Luke Dashjr) 74e8738 Bugfix: ForceSetArg should replace entr(ies) in mapMultiArgs, not append (Luke Dashjr) 23fb9ad wallet: Move nAccountingEntryNumber from static/global to CWallet (Luke Dashjr) 9d15d55 Bugfix: wallet: Increment "update counter" when modifying account stuff (Luke Dashjr) f28eb80 Bugfix: wallet: Increment "update counter" only after actually making the applicable db changes to avoid potential races (Luke Dashjr) Tree-SHA512: 23f5dda58477307bc07997010740f1dc729164cdddefd2f9a2c9c7a877111eb1516d3e2ad4f9b104621f0b7f17369c69fcef13d28b85cb6c01d35f09a8845f23
| * Wallet: Replace pwalletMain with a vector of wallet pointersLuke Dashjr2017-06-061-7/+7
| |
* | Remove unused Boost includespracticalswift2017-06-091-1/+0
|/
* Merge #10403: Fix importmulti failure to return rescan errorsWladimir J. van der Laan2017-06-051-15/+13
|\ | | | | | | | | | | 4d2d604 Fix importmulti failure to return rescan errors (Russell Yanofsky) Tree-SHA512: e5e6d6c5a2bb7230e1bcac1903a4b766cd57bf781fade50c6c9cd5713cd3e768db0987cfda9699b57a53d3a0a60951b96dce5283b3d3ec1f954162c439bc932b
| * Fix importmulti failure to return rescan errorsRussell Yanofsky2017-05-151-15/+13
| | | | | | | | | | | | | | | | An off-by-one-block bug in importmulti rescan logic could cause it to return success in an edge case even when a rescan was not successful. The case where this would happen is if there were multiple blocks in a row with the same GetBlockTimeMax() value, and the last block was scanned successfully, but one or more of the earlier blocks was not readable.
* | Merge #10295: [qt] Move some WalletModel functions into CWalletWladimir J. van der Laan2017-05-231-0/+101
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | 108f04f Add missing LOCK2 in CWallet::GetAvailableBalance (Russell Yanofsky) 429aa9e [test] Move some tests from qt -> wallet (Russell Yanofsky) d944bd7 [qt] Move some WalletModel functions into CWallet (Russell Yanofsky) ef8ca17 [test] Add tests for some walletmodel functions (Russell Yanofsky) Tree-SHA512: f6384d9f2ff3f7fb173d414588c3e7dc8c311b8ed2ce2b0979fb824a0ed83a7302890ccd3d83197f07f6fdcb6b1ca151584d90ea1961d88dfe8956c87087cde8
| * | [test] Move some tests from qt -> walletRussell Yanofsky2017-05-171-0/+101
| |/ | | | | | | After previous refactoring, the tests make more sense here.
* / Fix importwallet edge case rescan bugRussell Yanofsky2017-05-161-0/+62
|/ | | | | | | | Start importwallet rescans at the first block with timestamp greater or equal to the wallet birthday instead of the last block with timestamp less or equal. This fixes an edge case bug where importwallet could fail to start the rescan early enough if there are blocks with decreasing timestamps or multiple blocks with the same timestamp.
* Merge #9827: Improve ScanForWalletTransactions return valueWladimir J. van der Laan2017-04-191-0/+11
|\ | | | | | | | | | | 30abce7 Improve ScanForWalletTransactions return value (Russell Yanofsky) Tree-SHA512: 195028553b103052a842b6a37e67410118a20c32475b80f7fd22d6d8622f92eca1c2d84f291d1092bef2161d3187d91052799b533e1e265b7613d51955490b8d
| * Improve ScanForWalletTransactions return valueRussell Yanofsky2017-03-011-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change ScanForWalletTransactions return value so it is possible to distinguish scans that skip reading every block (due to the nTimeFirstKey optimization) from scans that fail while reading the chainActive.Tip() block. Return value is now non-null in the non-failing case. This change doesn't affect any user-visible behavior, it is only an internal API improvement. The only code currently using the ScanForWalletTransactions return value is in importmulti, and importmulti always calls ScanForWalletTransactions with a pindex pointing to the first block in chainActive whose block time is >= (nLowestTimestamp - 7200), while ScanForWalletTransactions would only return null without reading blocks when pindex and every block after it had a block time < (nTimeFirstKey - 7200). These conditions could never happen at the same time because nTimeFirstKey <= nLowestTimestamp. I'm planning to make a more substantial API improvement in the future (making ScanForWalletTransactions private and exposing a higher level rescan method to RPC code), but Matt Corallo <[email protected]> pointed out this odd behavior introduced by e2e2f4c "Return errors from importmulti if complete rescans are not successful" yesterday, so I'm following up now to get rid of badness introduced by that merge.