aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/wallet.py
AgeCommit message (Collapse)Author
2022-12-24scripted-diff: Bump copyright headersHennadii Stepanov
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: - 2021: f47dda2c58b5d8d623e0e7ff4e74bc352dfa83d7 - 2020: fa0074e2d82928016a43ca408717154a1c70a4db - 2019: aaaaad6ac95b402fe18d019d67897ced6b316ee0
2022-12-09tests: Use batched RPC in feature_fee_estimationAndrew Chow
feature_fee_estimation has a lot of loops that hit the RPC many times in succession in order to setup scenarios. Using batched requests for these can reduce the test's runtime without effecting the test's behavior.
2022-12-05Merge bitcoin/bitcoin#26414: test: Move tx creation to ↵MarcoFalke
create_self_transfer_multi 0b78110f73965fd827748107e0f3497d3352be71 test: Move tx creation to create_self_transfer_multi (kouloumos) Pull request description: Two birds with one stone: replacement of https://github.com/bitcoin/bitcoin/pull/26278 with simplification of the MiniWallet's transaction creation logic. Currently the MiniWallet creates simple txns (1 input, 1 output) with `create_self_transfer`. https://github.com/bitcoin/bitcoin/pull/24637 introduced `create_self_transfer_multi` **which uses** `create_self_transfer` to create a "transaction template" which then adjusts (copy and mutate inputs and outputs) in order to create more complex multi-input multi-output transactions. This can more easily lead to issues such as https://github.com/bitcoin/bitcoin/pull/26278 and is more of a maintenance burden. This PR simplifies the logic by going the other way around. Now `create_self_transfer` **uses** `create_self_transfer_multi`. The transaction creation logic has been moved to `create_self_transfer_multi` which is being called by `create_self_transfer` to construct the simple case of 1 input 1 output transaction. ACKs for top commit: MarcoFalke: ACK 0b78110f73965fd827748107e0f3497d3352be71 👒 Tree-SHA512: 147e577ed5444bee57865bd375b37c9b49d6539e9875c30c2667e70fcba27fe80bcb4552a4e6efb42760d34b40d5dad826883b778eaeefe29425ec081787b4bd
2022-10-28test: Move tx creation to create_self_transfer_multikouloumos
2022-10-03test: refactor `RPCPackagesTest` to use `MiniWallet`w0xlt
2022-08-03test: Target exact weight in MiniWallet _bulk_txMacroFake
Also, replace broad -acceptnonstdtxn=1 with -datacarriersize=100000
2022-08-01test: MiniWallet: add `send_self_transfer_chain` to create chain of txnsAndreas Kouloumos
With this new method, a chain of transactions can be created. This method is introduced to further simplify the mempool_package_limits.py tests.
2022-08-01test: use MiniWallet to simplify mempool_package_limits.py testsAndreas Kouloumos
Moved `bulk_transaction` into MiniWallet class as `_bulk_tx` private helper method to be used when the newly added `target_weight` option is passed to `create_self_transfer*`
2022-07-01test: Make the scriptPubKey of MiniWallet created txs mutableMacroFake
This makes individual bytes of the scriptPubKey mutable, previously it could only be re-assigned as a whole.
2022-07-01test: Allow setting sequence per input in MiniWallet create_self_transfer_multiMacroFake
Previously it was only possible to set the same sequence in all inputs
2022-07-01test: Allow amount_per_output in MiniWallet create_self_transfer_multiMacroFake
2022-07-01test: Allow absolute fee in MiniWallet create_self_transferMacroFake
2022-06-27test: Sync MiniWallet utxo state after each generate callMacroFake
2022-06-27test: Drop spent utxos in MiniWallet scan_txMacroFake
2022-06-27test: Return new_utxos from create_self_transfer_multi in MiniWalletMacroFake
2022-06-27test: Return new_utxo from create_self_transfer in MiniWalletMacroFake
2022-06-21test: Remove from_node from create_self_transfer* MiniWallet helpersMacroFake
The from_node argument is no longer used as of commit a55606c3bdbfdf660b093bc2a618d537ffae7f26
2022-06-21test: refactor: save MiniWallet mode explicitlySebastian Falbesoner
Rather than abusing the member variables self._priv_key and self._address to determine the MiniWallet mode, save it explicitly instead in the constructor to increase the readability and maintainability of the code.
2022-06-14test: implement 'bech32m' mode for `getnewdestination()` helperSebastian Falbesoner
2022-06-13test: Remove MiniWallet mempool_valid optionMacroFake
2022-06-07Merge bitcoin/bitcoin#25228: test: add BIP-125 rule 5 testcase with default ↵laanwj
mempool 687addaf136356e0f3698d6345c92d875e0a3362 test: add BIP-125 rule 5 testcase with default mempool (James O'Beirne) 6120e8e2871fecfec5ab3099c97e13951e062a4d test: allow passing sequence through create_self_transfer_multi (James O'Beirne) Pull request description: Currently, we only test rule 5 of BIP-125 (replacement transactions cannot evict more than 100 transactions) by changing default mempool parameters to allow for more descendants. The current test works on a single transaction graph that has over 100 descendants. This patch adds a test to exercise rule 5 using the default mempool parameters. The case is a little more sophisticated: instead of working on a single transaction graph, it uses a replacement transaction to "unite" several UTXOs which join independent transaction graphs. The total number of transactions in these graphs sum to more than the max allowable replacement. I think the difference in transaction topology makes this a worthwhile testcase to have, setting aside the fact that this testcase works without having to use atypical mempool params. See also: [relevant discussion from IRC](https://www.erisian.com.au/bitcoin-core-dev/log-2022-05-27.html#l-126) ACKs for top commit: laanwj: Code review ACK 687addaf136356e0f3698d6345c92d875e0a3362 LarryRuane: ACK 687addaf136356e0f3698d6345c92d875e0a3362 Tree-SHA512: e589aeaf9d6f137d546b7809f8795d6f6043d87b15e97c2efe85b42ce8b49d977ee7d79440c542ca4b0b5ca2de527488029841a1ffc0d96c5771897df4b3f324
2022-06-01test: Set maxfeerate=0 in MiniWallet sendrawtransaction()MacroFake
2022-05-27test: allow passing sequence through create_self_transfer_multiJames O'Beirne
And some little type annotation additions.
2022-05-19test: use MiniWallet for feature_dbcrash.pySebastian Falbesoner
This test can now be run even with the Bitcoin Core wallet disabled.
2022-04-22test: MiniWallet: skip mempool check if `mempool_valid=False`Sebastian Falbesoner
MiniWallet's core method for creating txs (`create_self_transfer`) right now always executes the `testmempoolaccept` RPC to check for mempool validity or invalidity. In some test cases where we use MiniWallet to create a huge number of transactions this can lead to performance issues (e.g. feature_fee_estimation.py where the execution time after MiniWallet usage almost doubled). Providing the possibility to skip the mempool checks is a mitigation for this. master branch: $ time ./test/functional/feature_fee_estimation.py real 3m20.771s user 2m52.360s sys 0m39.340s PR branch: $ time ./test/functional/feature_fee_estimation.py real 2m1.386s user 1m42.510s sys 0m22.980s
2022-04-22test: MiniWallet: always rehash after signing (P2PK mode)Sebastian Falbesoner
Also explicitly rehash in the cases where we modify a tx after signing in feature_csv_activation.py. Parts of this test relied on the fact that rehashing of transactions is done in the course of calculating a block's merkle root (`calc_merkle_root`), which only works if no hash was calculated before due to a caching mechanism. In the following commit the txid in MiniWallet is calculated via `rehash()`, i.e. this doesn't work anymore and we always have to explicitely have the right hash before we calculate the merkle root.
2022-03-24test: Rework create_self_transfer_multiMarcoFalke
* Add fallback for utxos_to_spend if none are provided * Refactor a for-loop
2022-03-24Merge bitcoin/bitcoin#24637: test: use MiniWallet for mempool_package_onemore.pyMarcoFalke
2b6dd4e75b3ad2daff553fde018fe4c8f1187878 test: use MiniWallet for mempool_package_onemore.py (Sebastian Falbesoner) eb3c5c4ef2eeb1d37d729d4487ed067a24cf81c8 test: MiniWallet: add helper methods `{send,create}_self_transfer_multi` (Sebastian Falbesoner) Pull request description: This PR enables one more of the non-wallet functional tests (mempool_package_onemore.py) to be run even with the Bitcoin Core wallet disabled by using the MiniWallet instead, as proposed in https://github.com/bitcoin/bitcoin/issues/20078. For this purpose helper methods `MiniWallet.{create,send}_self_transfer_multi` are introduced which serve as a replacement for `chain_transaction`. With this, it should be also quite straight-forward to change the larger related test `mempool_packages.py` to use MiniWallet. ACKs for top commit: MarcoFalke: ACK 2b6dd4e75b3ad2daff553fde018fe4c8f1187878 💾 Tree-SHA512: 0c97fa0519ca5eaa6df8953a04678aa8a6a66905a82db6ff40042a675d0c0682aee829a48db84e4e7983d8f766875021f0d39d65e12889342610b8861bc29cd5
2022-03-24Merge bitcoin/bitcoin#24587: test: use MiniWallet for rpc_createmultisig.pyfanquake
2726b60a3ac098b44f2970bed21147b70e12a1c2 test: use MiniWallet for rpc_createmultisig.py (Ayush Sharma) Pull request description: This PR enables one of the non-wallet functional tests (rpc_createmultisig.py) to be run even with the Bitcoin Core wallet disabled by using the MiniWallet instead, as proposed in #20078 . ACKs for top commit: danielabrozzoni: re-ACK 2726b60a3ac098b44f2970bed21147b70e12a1c2 Tree-SHA512: fb0ef22d3f1c161ca5963cb19ce76533ac3941f15102fc0aa2286ef3bec48f219e5934d504b41976f9f295fb6ca582b737e0fea896df4eb964cdaba1b2c91650
2022-03-22test: MiniWallet: add helper methods `{send,create}_self_transfer_multi`Sebastian Falbesoner
2022-03-22test: use MiniWallet for rpc_createmultisig.pyAyush Sharma
This test can now be run even with the Bitcoin Core wallet disabled.
2022-03-17Use MiniWallet in feature_coinstatsindexMarcoFalke
2022-03-17test: Refactor MiniWallet get_utxo helperMarcoFalke
2022-01-13test: use MiniWallet for mempool_accept.pySebastian Falbesoner
This test can now be run even with the Bitcoin Core wallet disabled.
2022-01-11test: MiniWallet: support default `from_node` for creating txsSebastian Falbesoner
If no `from_node` parameter is passed explicitely to the `create_self_transfer` method, the test node passed in the course of creating the MiniWallet instance is used. This seems to be the main use-case in most of the current functional tests, i.e. in many instances the calls can be shortened.
2021-12-26test: introduce `address_to_scriptpubkey` helperSebastian Falbesoner
Works only with legacy addresses (Base58Check) right now.
2021-12-26test: introduce `getnewdestination` helper for generating various address typesSebastian Falbesoner
This serves as a replacement for the getnewaddress RPC if no wallet is available. In addition to the address, it also returns the corresponding public key and output script (scriptPubKey).
2021-11-16Merge bitcoin/bitcoin#23474: test: scripted-diff cleanups after generate* ↵fanquake
changes fac23c211407a77af82bb1491c48c8d37022c8b3 scripted-diff: Bump copyright headers (MarcoFalke) fa974f1f1417a536636347072e86bcb54a4c909c scripted-diff: Remove redundant sync_all and sync_blocks (MarcoFalke) fad13991aea6463ecf07dd907de1c1b23837d7e7 test: Properly set sync_fun in NodeNetworkLimitedTest (MarcoFalke) faeff577093c4de9eec9491486a2c3766d46dae6 test: Use 4 spaces for indentation (MarcoFalke) Pull request description: Some cleanups after commit 94db963de501e4aba6e5d8150a01ceb85753dee1 ACKs for top commit: fanquake: ACK fac23c211407a77af82bb1491c48c8d37022c8b3 Tree-SHA512: 5acfd5bb9679b41969d0fc6fc85801ccadcd6530ea692bac6352668e06fc7a9b0e1db3fd6fba435e84afe983d2eb07bd0a47c8364462bb7110004bd3d102b698
2021-11-15test: Return the largest utxo in MiniWallet.get_utxoMarcoFalke
2021-11-10scripted-diff: Bump copyright headersMarcoFalke
The previous diff touched most files in ./test/, so bump the headers to avoid having to touch them again for a bump later. -BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./test/ -END VERIFY SCRIPT-
2021-11-09test: MiniWallet: add P2TR support and use it per defaultSebastian Falbesoner
2021-10-27test: MiniWallet: more deterministic coin selection for coinbase UTXOs ↵Sebastian Falbesoner
(oldest first) The coin selection strategy for MiniWallet is quite straight-forward: simply pick a single UTXO with the largest value: self._utxos = sorted(self._utxos, key=lambda k: k['value']) utxo_to_spend = utxo_to_spend or self._utxos.pop() If there are several candidates with the same value, however, it is not clear which one is taken. This can be particularly problematic for coinbase outputs with fixed block subsidy, since spending could lead to a 'bad-txns-premature-spend-of-coinbase' reject if an UTXO from a too-recent block is picked. Introduce block height as second criteria (saved in self._utxos in the methods generate(...) and rescan_utxos(...)), in order to avoid potential issues with coinbases that are not matured yet.
2021-10-18Merge bitcoin/bitcoin#23207: test: Delete generate* calls from TestNodeMarcoFalke
fac62e6ff594f03832f5c0057f9b67c9118c21f4 test: Delete generate* calls from TestNode (MarcoFalke) fac7f6102feb1eb1c47ea8cb1c75c4f4dbf2f6b0 test: Use generate* node RPC, not wallet RPC (MarcoFalke) faac1cda6e2ca1d86b1551fc90453132f249d511 test: Use generate* from TestFramework, not TestNode (MarcoFalke) Pull request description: Deleting the methods is needed for #22567 to pave the way to make it easier to implicitly call the `sync_all` member function. Without the methods being deleted, nothing prevents developers from adding calls to it. As history showed, developers *will* add calls to it. For example, see commit eb02dbba3cd9f7294cd81e268cf85a1de7a71d02 from today or the first commit in this pull request. ACKs for top commit: stratospher: Tested ACK fac62e6. brunoerg: tACK fac62e6ff594f03832f5c0057f9b67c9118c21f4 promag: Code review ACK fac62e6ff594f03832f5c0057f9b67c9118c21f4. Tree-SHA512: 6d4dea8f95ead954acfef2e6a5d98897ce0c2d02265c5b137bb149d0265543bd51d7e8403e1945b9af75df5524ca50064fe1d2a432b25c8abc71bbb28ed6ed53
2021-10-07Merge bitcoin/bitcoin#23118: test: refactor: introduce `script_util` helper ↵W. J. van der Laan
for creating P2PK scripts 429b49378ee3a3d73abe276cfd176c1ca08bf9b9 test: introduce script_util helper for creating P2PK scripts (Sebastian Falbesoner) Pull request description: This PR is a follow-up to #22363, which took use of already existing `script_util` helpers to get rid of manual CScript for the P2{PKH,SH,WPKH,WSH} output types, in order to increase readability and maintainability of the test code. Here the same is done for P2PK scripts by introducing a helper `key_to_p2pk_script` and using it. Note that the helper only accepts ECDSA pubkeys (i.e. ones with a size of 33 or 65 bytes), hence it can't be used for scripts in the form of [x-only-pubkey, OP_CHECKSIG]. ACKs for top commit: brunoerg: Code review ACK 429b49378ee3a3d73abe276cfd176c1ca08bf9b9 laanwj: Code review ACK 429b49378ee3a3d73abe276cfd176c1ca08bf9b9 rajarshimaitra: Concept + tACK https://github.com/bitcoin/bitcoin/pull/23118/commits/429b49378ee3a3d73abe276cfd176c1ca08bf9b9 Tree-SHA512: 984aea01eba5f38a328d69905d90a3a36f0a02419ca3e5baf3c8095895fb094e3780c7da16fad5851db3847bdb05ce8cda244ab09b79b8aa9602dfb3c5e0414c
2021-10-07Merge bitcoin/bitcoin#23210: test: Replace satoshi_round with int() or Decimal()MarcoFalke
fa2ac5881edf8d0d3f15c43f089f1831348dfae2 test: Replace satoshi_round with int() or Decimal() (MarcoFalke) Pull request description: satoshi_round will round down. To make the code easier to parse use Decimal() where possible, which does not round. Or use int(), which explicitly rounds down. ACKs for top commit: lsilva01: Tested ACK https://github.com/bitcoin/bitcoin/pull/23210/commits/fa2ac5881edf8d0d3f15c43f089f1831348dfae2 on Ubuntu 20.04. Tree-SHA512: 17795d906aa7652933d43e510e993cdd9cf8926da1febf1c42d463048cb38c92dc518ec08736efe29c0189ffd532b108bc7a715f32b4c2ee58b215df65352eb9
2021-10-06test: Replace satoshi_round with int() or Decimal()MarcoFalke
satoshi_round will round down. To make the code easier to parse use Decimal() where possible, which does not round. Or use int(), which explicitly rounds down.
2021-10-06test: Avoid RPC roundtrip in MiniWallet get_descriptor()MarcoFalke
2021-10-06test: Delete generate* calls from TestNodeMarcoFalke
2021-09-29test: introduce script_util helper for creating P2PK scriptsSebastian Falbesoner
2021-09-27test: introduce helper to create random P2WPKH scriptPubKeysSebastian Falbesoner