aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
AgeCommit message (Collapse)Author
2022-07-19refactor: move helper `random_bytes` to util librarySebastian Falbesoner
Can be easily reviewed with `--color-moved=dimmed-zebra`.
2022-07-19test: add constants for PSBT key types (BIP 174)Sebastian Falbesoner
Also take use of the constants in the signet miner to get rid of magic numbers and increase readability and maintainability.
2022-07-19refactor: move PSBT(Map) helpers from signet miner to test frameworkSebastian Falbesoner
Can be easily reviewed with `--color-moved=dimmed-zebra`.
2022-07-19refactor: move `from_binary` helper from signet miner to test frameworkSebastian Falbesoner
Can be easily reviewed with `--color-moved=dimmed-zebra`.
2022-07-12scripted-diff: [test] Rename BIP125_SEQUENCE_NUMBER to MAX_BIP125_RBF_SEQUENCEMacroFake
-BEGIN VERIFY SCRIPT- sed -i 's:BIP125_SEQUENCE_NUMBER:MAX_BIP125_RBF_SEQUENCE:g' $(git grep -l BIP125_SEQUENCE_NUMBER ./test) -END VERIFY SCRIPT-
2022-07-10test: refactor: pass absolute fee in `create_lots_of_big_transactions` helperSebastian Falbesoner
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-30Merge bitcoin/bitcoin#25364: test: remove wallet dependency from ↵MacroFake
feature_nulldummy.py 50ba6697f33b44e475ed65137f7ff0444f6c4ca9 remove unused functions (Ayush Sharma) eec23dad1ec471641dcc74f6679e5c0eda44da94 test: remove wallet dependency from feature_nulldummy.py (Ayush Sharma) Pull request description: This PR enables one of the non-wallet functional tests (`feature_nulldummy.py`) to be run even with the Bitcoin Core wallet disabled. Commit 1: removes wallet dependency and `test_runner.py` is edited to make sure the test only runs once. Commit 2: the functions `create_transaction()` and `create_raw_transaction()` in `blocktools.py` are no longer needed and hence removed. ACKs for top commit: kouloumos: re-ACK 50ba6697f33b44e475ed65137f7ff0444f6c4ca9, all comments have been addressed. Tree-SHA512: 3bc3d2766e53dba3d56a03f2c476442608ac693f51d84f4632a22a2cf169bc02c10bf92b676f7d57acb4f0ad86f307d37ab63f936b44b3585ee3c9d08cd0335f
2022-06-29test: let `gen_return_txouts` create a single large OP_RETURN outputSebastian Falbesoner
Transactions with more than one datacarrier (OP_RETURN) output are never considered standard, i.e. this change is necessary in order to to get rid of the `acceptnonstdtxn` option for some tests.
2022-06-29test: assert serialized txouts size of `gen_return_txouts` helperSebastian Falbesoner
This assures that changing the internals of the helper function still leads to the expected outcome sizewise (preparation for the next commit).
2022-06-27test: Test signing psbts without explicitly having scriptsAndrew Chow
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-24remove unused functionsAyush Sharma
the functions `create_transaction()` and `create_raw_transaction()` were no longer used hence removed.
2022-06-22test: Fail if connect_nodes failsMacroFake
Also replace the use of wait_until_helper, which is not allowed to be called directly. Otherwise, --timeout-factor will not be honoured.
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-17Merge bitcoin/bitcoin#25289: test: implement 'bech32m' mode for ↵laanwj
`getnewdestination()` helper dcf36fe8e3e1fc1e865072232281b72889586e40 test: implement 'bech32m' mode for `getnewdestination()` helper (Sebastian Falbesoner) 1999dcfa40ddedb6cf15f9d66b90fa0f537b4842 test: add helpers for creating P2TR scripts/addresses from output key (Sebastian Falbesoner) Pull request description: This PR adds the missing 'bech32m' mode for the `getnewdestination()` helper and sets it as default, i.e. the function returns a tuple (output x-only-pubkey, scriptPubKey, taproot address) now if not specified otherwise. In a preparation commit, the helpers `output_key_to_p2tr{_script}` are introduced. Note that in contrast to all other common script output types, there are usually _two_ keys involved in creating a taproot output (internal key and output key), hence the prefix `output_` is used to clarify that the output key is expected and the helpers don't do any key tweaking. Thanks to michaelfolkson (for pointing out this TODO that I forgot about) and sipa (for patiently explaining basic things about BIP341). ACKs for top commit: michaelfolkson: ACK dcf36fe8e3e1fc1e865072232281b72889586e40 w0xlt: reACK https://github.com/bitcoin/bitcoin/pull/25289/commits/dcf36fe8e3e1fc1e865072232281b72889586e40 Tree-SHA512: 5bb8d5fd96c63092ede10c3f022ffb2e13c14e333c4aa73348d95deb70cbf0a74745218dc4a7c419eb846793dd69e8217a7b4332a13ae2b2758e100b51fb1a9f
2022-06-15test: remove unused `create_confirmed_utxos` helperSebastian Falbesoner
Confirmed UTXOs in functional tests can simply be created by using MiniWallet's `send_self_transfer_multi` method with a subsequent `generate` call to mine a block.
2022-06-14test: implement 'bech32m' mode for `getnewdestination()` helperSebastian Falbesoner
2022-06-14test: add helpers for creating P2TR scripts/addresses from output keySebastian Falbesoner
2022-06-13test: Remove MiniWallet mempool_valid optionMacroFake
2022-06-13Merge bitcoin/bitcoin#24839: test: use MiniWallet for ↵MacroFake
mining_prioritisetransaction.py b167e536d0f5ae4c86d0c3da4a63337f9f0448ba test: refactor: use `create_lots_of_big_transactions` to dedup where possible (Sebastian Falbesoner) 8973eeb4124112a8cb7bb3d486780ac668b3e7bd test: use MiniWallet for mining_prioritisetransaction.py (Sebastian Falbesoner) Pull request description: This PR enables one more of the non-wallet functional tests (mining_prioritisetransaction.py) to be run even with the Bitcoin Code wallet by using the MiniWallet instead, as proposed in #20078. Note that the adapted helper function `create_lots_of_big_transactions` is currently only used in this test, i.e. there was no need to change any others. ACKs for top commit: ayush933: tACK b167e53 danielabrozzoni: tACK b167e536d0f5ae4c86d0c3da4a63337f9f0448ba kouloumos: ACK b167e536d0f5ae4c86d0c3da4a63337f9f0448ba furszy: ACK b167e536 Tree-SHA512: ccae20d7d414a720efdeea9c2ae399aa53a3a0e7db72bff8d0cb75d90621a7ae7c019ba68d24f9d06f7b111f87ff33bb9d8e5aa08b763e606cf10268780e205c
2022-06-08[test_framework] Set PortSeed.n directly after initialising paramsdergoegge
This allows us to use `p2p_port()` with `set_test_params()`.
2022-06-08Merge bitcoin/bitcoin#25294: test: Fix wait_for_debug_log UnicodeDecodeErrorMacroFake
fa74b63c01db412f6a4378cb669d89496a89d02e test: Fix wait_for_debug_log UnicodeDecodeError (MacroFake) Pull request description: Fix the intermittent `UnicodeDecodeError` when the debug log is truncated on an (multi-byte) unicode character by treating everything as bytes. Also, remove the `ignore_case` option and the`re.search+re.escape` wrap. All of this is unused and doesn't exist on raw byte strings. Fixes https://github.com/bitcoin/bitcoin/issues/24575 ACKs for top commit: jonatack: ACK fa74b63c01db412f6a4378cb669d89496a89d02e brunoerg: ACK fa74b63c01db412f6a4378cb669d89496a89d02e Tree-SHA512: c67c9355073e784fa8d9d48b8e79ff0c98f5ae9cd4d704ad12a76d2604733946054bc74b8ab346aa2184db23d740b85c8c13eb892d76cba92e42ebfd73f2f1bf
2022-06-07test: Fix wait_for_debug_log UnicodeDecodeErrorMacroFake
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-06-01Merge bitcoin/bitcoin#25087: test: use MiniWallet for feature_dbcrash.pyMacroFake
1da5e45725a49a867f7ce16fb37b138ad329d132 test: use MiniWallet for feature_dbcrash.py (Sebastian Falbesoner) Pull request description: This PR enables one more of the non-wallet functional tests (feature_dbcrash.py) to be run even with the Bitcoin Code wallet by using the MiniWallet instead, as proposed in https://github.com/bitcoin/bitcoin/issues/20078. ACKs for top commit: laanwj: Code review ACK 1da5e45725a49a867f7ce16fb37b138ad329d132 brunoerg: crACK 1da5e45725a49a867f7ce16fb37b138ad329d132 Tree-SHA512: 75ee9a32fd1451254004797d695d18032bd0fcb66ebd88cf737e147e43812525f6e884ec05fcc4f76f566dc71174c8ed7347bcdce16567db6511746ae64cead0
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-05-19Merge bitcoin/bitcoin#25161: rpc: Put undocumented JSON failure mode behind ↵MacroFake
a runtime flag b953ea6cc691ba61bf08eb186e76e7e8b7ba8120 rpc: Put undocumented JSON failure mode behind a runtime flag (Suhail Saqan) Pull request description: Fixes #24695 (Put undocumented JSON failure mode behind a runtime flag) ACKs for top commit: luke-jr: utACK b953ea6cc691ba61bf08eb186e76e7e8b7ba8120 vincenzopalazzo: ACK https://github.com/bitcoin/bitcoin/pull/25161/commits/b953ea6cc691ba61bf08eb186e76e7e8b7ba8120 Tree-SHA512: 2005ee1b1f3b637918390b2ecd4166f2fd8c86e3c59fba3da8a0cbd5b1dffd03190c92f6dca3c489ecce4276eaf3108b2edcf9cd6224b713adb52f5bb848163b
2022-05-18rpc: Put undocumented JSON failure mode behind a runtime flagSuhail Saqan
rpc: Put undocumented JSON failure mode behind a runtime flag
2022-05-13test: make BIP157 messages default-constructible (MESSAGEMAP compatibility)Sebastian Falbesoner
In order to deserialize received or read messages via lookup in MESSAGEMAP (e.g.: `t = MESSAGEMAP[msgtype]()`), the messages must have a default constructor, i.e. there needs to be the possibility to initialize them with zero arguments.
2022-05-13test: p2p: add missing BIP157 message types to MESSAGEMAPSebastian Falbesoner
2022-05-03Merge bitcoin/bitcoin#24941: test: MiniWallet: support skipping mempool ↵MacroFake
checks (feature_fee_estimation.py performance fix) a498acce4514d83d8dafcebaad522a89b6dc70fa test: MiniWallet: skip mempool check if `mempool_valid=False` (Sebastian Falbesoner) 01552e8f677b710944a0c41406253bc3102db332 test: MiniWallet: always rehash after signing (P2PK mode) (Sebastian Falbesoner) Pull request description: 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, in particular feature_fee_estimation.py where the execution time after MiniWallet usage (PR #24817) doubled, see https://github.com/bitcoin/bitcoin/issues/24828#issuecomment-1100058100, https://github.com/bitcoin/bitcoin/issues/24828#issuecomment-1100301980. This PR mitigates this by skipping the mempool check if the parameter `mempool_valid` is set to `False`. As a preparatory commit, the test feature_csv_activation.py has to be adapted w.r.t. to rehashing of transactions, as we now hash all transactions immediately in `create_self_transfer` in order to get the txid (before we relied on the result of `testmempoolaccept`). On my machine, this decreases the execution time quite noticably: 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 ``` Partly fixes #24828 (hopefully). ACKs for top commit: danielabrozzoni: tACK a498acce4514d83d8dafcebaad522a89b6dc70fa Tree-SHA512: f20c358ba42b2ded86175f46ff3ff9eaefb84175cbd1c2624f44904c8d8888e67ce64d6dcbb26aabbf07906e6f5bdea40353eba9ae668618cadcfc517ef7201b
2022-04-29test: stop node before calling assert_start_raises_init_errorMartin Zumsande
...in feature_coinstatsindex and feature_pruning. Also add an assert to assert_start_raises_init_error that the node is not already running.
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-04-16test: refactor: use `create_lots_of_big_transactions` to dedup where possibleSebastian Falbesoner
2022-04-16test: use MiniWallet for mining_prioritisetransaction.pySebastian Falbesoner
This test can now be run even with the Bitcoin Core wallet disabled.
2022-04-11test: add `is_bitcoin_util_compiled` helperSebastian Falbesoner
2022-04-11test: determine path to `bitcoin-util` in test frameworkSebastian Falbesoner
The path is stored in `self.options.bitcoinutil`, points to `src/bitcoin-util` by default and can be overrided with the `BITCOINUTIL` environment variable.
2022-04-06Merge bitcoin/bitcoin#24576: contrib: testgen: remove redundant base58 ↵fanquake
implementation 65c49ac750ba39801b349d0a59c27471dfa9868e test: throw `ValueError` for invalid base58 checksum (Sebastian Falbesoner) 219d2c7ee1d35a353a96c55d4c411d43fe39548a contrib: testgen: use base58 methods from test framework (Sebastian Falbesoner) 605fecfb66ba51467b35a3f269116ec786aedd05 scripted-diff: rename `chars` to `b58chars` in test_framework.address (Sebastian Falbesoner) 11c63e374d058d3bde64a725068d29c874950b45 contrib: testgen: import OP_* constants from test framework (Sebastian Falbesoner) 7d755bb31cd58099cd97b604e04a6a4bb99cd2a9 contrib: testgen: avoid need for manually setting PYTHONPATH (Sebastian Falbesoner) Pull request description: This PR removes the redundant base58 implementation [contrib/testgen/base58.py](https://github.com/bitcoin/bitcoin/blob/master/contrib/testgen/base58.py) for the test generation script `gen_key_io_test_vectors.py` and uses the one from the test framework instead. Additionally, three other cleanups/improvements are done: - import script operator constants `OP_*` from test framework instead of manually defining them - add Python path to test framework directly in the script (via `sys.path.append(...)`) instead of needing the caller to specify `PYTHONPATH=...` on the command line (the same approach is done for the signet miner and the message capture scripts) - rename `chars` to `b58chars` in the test_framework.address module (is more explicit and makes the diff for the base58 replacement smaller) ACKs for top commit: laanwj: Code review ACK 65c49ac750ba39801b349d0a59c27471dfa9868e Tree-SHA512: 92e1534cc320cd56262bf455de7231c6ec821bfcd0ed58aa5718271ecec1a89df7951bf31527a2306db6398e7f2664d2ff8508200c28163c0b164d3f5aaf8b0e
2022-04-06Merge bitcoin/bitcoin#24358: test: USDT tracepoint interface testslaanwj
76c60d7b31ccc50b226cdbc5e38be0bd67603408 test: validation:block_connected tracepoint test (0xb10c) 260e28ece87ba2e732ff8d8a379c4b27e77e3c0d test: utxocache:* tracepoint tests (0xb10c) 34b27bac684f2f373c5e1d90697d6bc8a014f45a test: net:in/out_message tracepoint tests (0xb10c) c934087b627f7d368458781944f990b0eb479634 test: checks for tracepoint tests (0xb10c) Pull request description: This adds functional tests for the USDT tracepoints added in https://github.com/bitcoin/bitcoin/pull/22006 and https://github.com/bitcoin/bitcoin/pull/22902. This partially fixes #23296. The tests **are probably skipped** on most systems as these tests require: - a Linux system with a kernel that supports BPF (and available kernel headers) - that Bitcoin Core is compiled with tracepoints for USDT support (default when compiled with depends) - [bcc](https://github.com/iovisor/bcc) installed - the tests are run with a privileged user that is able to e.g. do BPF syscalls and load BPF maps The tests are not yet run in our CI as the CirrusCI containers lack the required permissions (see https://github.com/bitcoin/bitcoin/issues/23296#issuecomment-1024920845). Running the tests in a VM in the CI could work, but I haven't experimented with this yet. The priority was to get the actual tests done first to ensure the tracepoints work as intended for the v23.0 release. Running the tracepoint tests in the CI is planned as the next step to finish #23296. The tests can, however, be run against e.g. release candidates by hand. Additionally, they provide a starting point for tests for future tracepoints. PRs adding new tracepoint should include tests. This makes reviewing these PRs easier. The tests require privileges to execute BPF sycalls (`CAP_SYS_ADMIN` before Linux kernel 5.8 and `CAP_BPF` and `CAP_PERFMON` on 5.8+) and permissions to `/sys/kernel/debug/tracing/`. It's currently recommended to run the tests in a virtual machine (or on a VPS) where it's sensible to use the `root` user to gain these privileges. Never run python scripts you haven't carefully reviewed with `root` permissions! It's unclear if a non-root user can even gain the required privileges. This needs more experimenting. The goal here is to test the tracepoint interface to make sure the [documented interface](https://github.com/bitcoin/bitcoin/blob/master/doc/tracing.md#tracepoint-documentation) does not break by accident. The tracepoints expose implementation details. This means we also need to rely on implementation details of Bitcoin Core in these functional tests to trigger the tracepoints. An example is the test of the `utxocache:flush` tracepoint: On Bitcoin Core shutdown, the UTXO cache is flushed twice. The corresponding tracepoint test expects two flushes, too - if not, the test fails. Changing implementation details could cause these tests to fail and the tracepoint API to break. However, we purposefully treat the tracepoints only as [**semi-stable**](https://github.com/bitcoin/bitcoin/blob/master/doc/tracing.md#semi-stable-api). The tracepoints should not block refactors or changes to other internals. ACKs for top commit: jb55: tACK 76c60d7b31ccc50b226cdbc5e38be0bd67603408 laanwj: Tested ACK 76c60d7b31ccc50b226cdbc5e38be0bd67603408 Tree-SHA512: 9a63d945c68102e59d751bd8d2805ddd7b37185408fa831d28a9cb6641b701961389b55f216c475df7d4771154e735625067ee957fc74f454ad7a7921255364c