aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/blocktools.py
AgeCommit message (Collapse)Author
2022-06-24remove unused functionsAyush Sharma
the functions `create_transaction()` and `create_raw_transaction()` were no longer used hence removed.
2022-01-11test: refactor: add constant for sequence number `SEQUENCE_FINAL`Sebastian Falbesoner
2021-11-30Remove GetAdjustedTime from init.cppMarcoFalke
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-10-26test: add script_util helper for creating bare multisig scriptsSebastian Falbesoner
2021-09-29test: introduce script_util helper for creating P2PK scriptsSebastian Falbesoner
2021-09-16test: Activate all regtest softforks at height 1, unless overriddenMarcoFalke
2021-08-26Set regtest.BIP65Height = 111 to speed up testsMarcoFalke
2021-08-10Merge bitcoin/bitcoin#22632: test: Set regtest.BIP66Height = 102 to speed up ↵W. J. van der Laan
tests fafe896a0b870d85250927bd5374caf73d379468 test: Set regtest.BIP66Height = 102 to speed up tests (MarcoFalke) Pull request description: No need to waste time by forcing creation of more than 1000 blocks to get the benefits of being able to test BIP 66. Also, reducing the height makes it more likely that (third-party) tests are conforming to BIP 66, which is enforced on mainnet for all new blocks. ACKs for top commit: GeneFerneau: Concept + code review ACK [fafe896](https://github.com/bitcoin/bitcoin/pull/22632/commits/fafe896a0b870d85250927bd5374caf73d379468) 0xB10C: crACK fafe896a0b870d85250927bd5374caf73d379468 laanwj: ACK fafe896a0b870d85250927bd5374caf73d379468 Zero-1729: tACK fafe896 kristapsk: ACK fafe896a0b870d85250927bd5374caf73d379468. Full functional test suite showed few second speed incrase on my laptop (although I didn't do proper benchmarking with multiple runs, just single `time ./test/functional/test_runner.py` on current master vs this PR). theStack: Tested ACK fafe896a0b870d85250927bd5374caf73d379468 hg333: tACK https://github.com/bitcoin/bitcoin/commit/fafe896a0b870d85250927bd5374caf73d379468 Tree-SHA512: 4bbee3c8587d612e74a59fde49b6439c1296f2fc27d3a7cf59a35e920f729fdd581c930290bd04def618f81412236676ddb99b4ceb4d80dfb9fd610b128a04b1
2021-08-05Merge bitcoin/bitcoin#22619: test: refactor: use consistent bytes <-> ↵MarcoFalke
hex-string conversion in functional test framework 5a1bef60a03b57de708a1a751bd90b8245fd8b83 test: refactor: remove binascii from test_framework (Zero-1729) Pull request description: This PR continues the work started in PR #22593, regarding using the `bytes` built-in module. In this PR specifically, instances of `binascii`'s methods `hexlify`, `unhexlify`, and `a2b_hex` have been replaced with the build-in `bytes` module's `hex` and `fromhex` methods where appropriate to make bytes <-> hex-string conversions consistent across the functional test files and test_framework. Additionally, certain changes made are based on the following assumption: ``` bytes.hex(data) == binascii.hexlify(data).decode() bytes.hex(data).encode() == binascii.hexlify(data) ``` Ran the functional tests to ensure behaviour is still consistent and changes didn't break existing tests. closes #22605 ACKs for top commit: theStack: Code-review ACK 5a1bef60a03b57de708a1a751bd90b8245fd8b83 🔢 Tree-SHA512: 8f28076cf0580a0d02a156f3e1e94c9badd3d41c3fbdfb2b87cd8a761dde2c94faa5f4c448d6747b1ccc9111c3ef1a1d7b42a11c806b241fa0410b7529e2445f
2021-08-05test: Set regtest.BIP66Height = 102 to speed up testsMarcoFalke
2021-08-04test: refactor: remove binascii from test_frameworkZero-1729
2021-08-03Merge bitcoin/bitcoin#16333: test: Set BIP34Height = 2 for regtestMarcoFalke
222290f54388270937cb6c174195717e2214ec0d test: Set BIP34Height = 2 for regtest (MarcoFalke) fac90c55be478f0323eafa1d560ea2c56f04fb23 test: Create all blocks with version 4 or higher (MarcoFalke) Pull request description: BIP34 is active on the current tip of mainnet, so all miners must obey it. It would be nice if it also was active in fresh regtest instances from the earliest time possible. I changed the BIP34 height to `2`, so that the block at height=1 may be used to mine a duplicate coinbase. (Needed to test mainnet behaviour) This pull is done in two commits: * test: Create all blocks with version 4 or higher: Now that BIP34 is activated earlier, we need to create blocks with a higher version number. Just bump it to 4 instead of 2 to avoid having to bump it again later. * test: Set BIP34Height = 2 for regtest: This fixes the BIP34 implementation in the tests (to match the one of the Core codebase) and updates the tests where needed ACKs for top commit: ajtowns: ACK 222290f54388270937cb6c174195717e2214ec0d jonatack: ACK 222290f54388270937cb6c174195717e2214ec0d tested and reviewed rebased to current master 5e213822f86d theStack: Tested ACK 222290f54388270937cb6c174195717e2214ec0d Tree-SHA512: d69c637a62a64b8e87de8c7f0b305823d8f4d115c1852514b923625dbbcf9a4854b5bb3771ff41702ebf47c4c182a4442c6d7c0b9f282c95a34b83e56a73939b
2021-08-01test: refactor: remove `hex_str_to_bytes` helperSebastian Falbesoner
Use the built-in class method bytes.fromhex() instead, which is available since Python 3.0.
2021-08-01Merge bitcoin/bitcoin#22429: test: refactor: fix segwit terminology ↵MarcoFalke
(s/witness_program/witness_script/) 8a2b58db9ee6a14d36b5d8e430b35f18e7c7b0c5 test: fix segwit terminology (s/witness_program/witness_script/) (Sebastian Falbesoner) Pull request description: This PR fixes wrong uses of the term "witness program", which according to [BIP141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#Witness_program) is defined as follows: > A scriptPubKey (or redeemScript as defined in BIP16/P2SH) that consists of a 1-byte push opcode (for 0 to 16) followed by a data push between 2 and 40 bytes gets a new special meaning. The value of the first push is called the "version byte". **The following byte vector pushed is called the "witness program".** In most cases where "witness program" is used in tests (concerns comments, variable names and in one instance even a function name) what we really want to denote is the "witness script". Thanks to [MarcoFalke for pointing this out in a review comment](https://github.com/bitcoin/bitcoin/pull/22363#discussion_r666794261)! Some historical background: At the time when the P2P segwit tests were first introduced (commit 330b0f31ee5719d94f9e52dfc83c5d82168241f9, PR #8149), the term "witness program" was not used consistently in BIP141: https://bitcoin.stackexchange.com/questions/46451/what-is-the-precise-definition-of-witness-program This was fixed in PR https://github.com/bitcoin/bips/pull/416 later. So in some way, this PR can be seen as a very late follow-up to the BIP141 fix that also reflects these changes in the tests. ACKs for top commit: josibake: tACK https://github.com/bitcoin/bitcoin/pull/22429/commits/8a2b58db9ee6a14d36b5d8e430b35f18e7c7b0c5 Tree-SHA512: f36bb9e53d1b54b86bfa87ec12f33e3ebca64b5f59d97e9662fe35ba12c25e1c9a4f93a5425d0eaa3879dce9e50368d345555b927bfab76945511f873396892b
2021-07-27test: use constants for CSV/CLTV activation heights in rpc_signrawtransactionSebastian Falbesoner
2021-07-11test: fix segwit terminology (s/witness_program/witness_script/)Sebastian Falbesoner
2021-07-05test: use script_util helpers for creating P2W{PKH,SH} scriptsSebastian Falbesoner
2021-06-24Merge bitcoin/bitcoin#22257: test: refactor: various (de)serialization ↵MarcoFalke
helpers cleanups/improvements bdb8b9a347e68f80a2e8d44ce5590a2e8214b6bb test: doc: improve doc for `from_hex` helper (mention `to_hex` alternative) (Sebastian Falbesoner) 191405420815d49ab50184513717a303fc2744d6 scripted-diff: test: rename `FromHex` to `from_hex` (Sebastian Falbesoner) a79396fe5f8f81c78cf84117a87074c6ff6c9d95 test: remove `ToHex` helper, use .serialize().hex() instead (Sebastian Falbesoner) 2ce7b47958c4a10ba20dc86c011d71cda4b070a5 test: introduce `tx_from_hex` helper for tx deserialization (Sebastian Falbesoner) Pull request description: There are still many functional tests that perform conversions from a hex-string to a message object (deserialization) manually. This PR identifies all those instances and replaces them with a newly introduced helper `tx_from_hex`. Instances were found via * `git grep "deserialize.*BytesIO"` and some of them manually, when it were not one-liners. Further, the helper `ToHex` was removed and simply replaced by `.serialize().hex()`, since now both variants are in use (sometimes even within the same test) and using the helper doesn't really have an advantage in readability. (see discussion https://github.com/bitcoin/bitcoin/pull/22257#discussion_r652404782) ACKs for top commit: MarcoFalke: review re-ACK bdb8b9a347e68f80a2e8d44ce5590a2e8214b6bb 😁 Tree-SHA512: e25d7dc85918de1d6755a5cea65471b07a743204c20ad1c2f71ff07ef48cc1b9ad3fe5f515c1efaba2b2e3d89384e7980380c5d81895f9826e2046808cd3266e
2021-06-22Revert "test: Add temporary logging to debug #20975"MarcoFalke
This reverts commit faa94961d6e38392ba068381726ed4e033367b03.
2021-06-21test: remove `ToHex` helper, use .serialize().hex() insteadSebastian Falbesoner
2021-06-21test: introduce `tx_from_hex` helper for tx deserializationSebastian Falbesoner
`FromHex` is mostly used for transactions, so we introduce a shortcut `tx_from_hex` for `FromHex(CTransaction, hex_str)`.
2021-06-18test: Create all blocks with version 4 or higherMarcoFalke
2021-06-04test: Add temporary logging to debug #20975MarcoFalke
2021-05-21Move COINBASE_MATURITY from `feature_nulldummy` test to `blocktools`.Kiminuo
2021-04-19test: Add tests for block_info in gettxoutsetinfoFabian Jahr
This additional data will automatically be returned if the coinstats index is used.
2020-12-31scripted-diff: Bump copyright headersMarcoFalke
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT-
2020-11-03test: Fix deser issue in create_blockMarcoFalke
Without the fix a hex-string can not be parsed: File "./test/functional/test_framework/blocktools.py", line 82, in create_block txo.deserialize(io.BytesIO(tx)) TypeError: a bytes-like object is required, not 'str' Also, remove io import and repace it with our FromHex() helper
2020-11-01Use separate watchonly wallet for multisig in feature_nulldummy.pyAndrew Chow
Create and import the multisig into a separate watchonly wallet so that feature_nulldummy.py works with descriptor wallets. blocktools.create_raw_transaction is also updated to use multiple nodes and wallets and to use PSBT so that this test passes.
2020-10-16Merge #19401: QA: Use GBT to get block versions correctMarcoFalke
d438d609cd64fe532d94e45000495de93ef99aa6 QA: Use GBT to get block versions correct (Luke Dashjr) 1df2cd1c8f468bd7a5b1335a46ccea28fbddaacb QA: blocktools: Accept block template to create_block (Luke Dashjr) Pull request description: The goal here is to decouple unrelated tests from the details of block versions. Currently, these tests are forcing specific versions of blocks for no real reason. ACKs for top commit: fjahr: re-ACK d438d609cd64fe532d94e45000495de93ef99aa6 benthecarman: ACK d438d60 Tree-SHA512: 523b1cd4dac8d65c88432e126ce7f60df96ca4b94f7ecc8e83ba4ffbade23e2afe7055fdf586ce3c195a533f2004e63fff83add4267b39473a581c9f1c6d5340
2020-10-12tests: functional tests for Schnorr/Taproot/TapscriptPieter Wuille
A large functional test is added that automatically generates random transactions which exercise various aspects of the new rules, and verifies they are accepted into the mempool (when appropriate), and correctly accepted/rejected in (Python-constructed) blocks. Includes sighashing code and many tests by Johnson Lau. Includes a test by Matthew Zipkin. Includes several tests and improvements by Greg Sanders.
2020-09-12QA: blocktools: Accept block template to create_blockLuke Dashjr
2020-06-03[test] CScriptNum Decode Check as Unit TestsGillian Chu
Migrates the CScriptNum decode tests into a unit test, and moved some changes made in #14816. Made possible by the integration of test_framework unit testing in #18576. Further extends the original test with larger ints, similar to the scriptnum_tests.cpp file. Adds test to blocktools.py testing fn create_coinbase() with CScriptNum decode.
2019-07-09test: Properly serialize BIP34 coinbase heightMarcoFalke
2019-03-02scripted-diff: test: Remove brackets after assertMarcoFalke
-BEGIN VERIFY SCRIPT- sed -i --regexp-extended -e 's/assert ?\((.+)\)(( )*)?(#.*)?$/assert \1\3\3\4/g' $(git grep -l --extended-regexp 'assert ?\(' test) -END VERIFY SCRIPT-
2019-03-02scripted-diff: test: Use py3.5 bytes::hex() methodMarcoFalke
-BEGIN VERIFY SCRIPT- sed -i -e "s/def bytes_to_hex_str/def b_2_x/g" $(git grep -l bytes_to_hex_str) export RE_B_0="[^()]*" # match no bracket export RE_B_1="${RE_B_0}\(${RE_B_0}\)${RE_B_0}" # match exactly one () export RE_B_2="${RE_B_0}\(${RE_B_1}\)${RE_B_0}" # match wrapped (()) export RE_M="(b2x|bytes_to_hex_str)\(((${RE_B_0}|${RE_B_1}|${RE_B_2})*)\)" sed -i --regexp-extended -e "s/${RE_M}/\2.hex()/g" $(git grep -l -E '(b2x|bytes_to_hex_str)') sed -i --regexp-extended -e "/ +bytes_to_hex_str( as b2x)?,/d" $(git grep -l bytes_to_hex_str) sed -i --regexp-extended -e "s/ +bytes_to_hex_str( as b2x)?,//g" $(git grep -l bytes_to_hex_str) sed -i --regexp-extended -e "s/, bytes_to_hex_str( as b2x)?//g" $(git grep -l bytes_to_hex_str) export RE_M="(binascii\.)?hexlify\(((${RE_B_0}|${RE_B_1}|${RE_B_2})*)\).decode\(${RE_B_0}\)" sed -i --regexp-extended -e "s/${RE_M}/\2.hex()/g" $(git grep -l hexlify -- ':(exclude)share') sed -i --regexp-extended -e "/from binascii import hexlify$/d" $(git grep -l hexlify -- ':(exclude)share') sed -i --regexp-extended -e "s/(from binascii import) .*hexlify/\1 unhexlify/g" $(git grep -l hexlify -- ':(exclude)share') sed -i -e 's/ignore-names "/ignore-names "b_2_x,/g' ./test/lint/lint-python-dead-code.sh -END VERIFY SCRIPT-
2019-02-12[rpc] mining: Omit uninitialized currentblockweight, currentblocktxMarcoFalke
2019-01-08Merge #15059: test: Add basic test for BIP34Wladimir J. van der Laan
fab17e8272f5f70213f186809479ee7a75898b1d test: Add basic test for BIP34 (MarcoFalke) Pull request description: BIP34 was disabled for testing, which explains why it had no test. Fix that by enabling it and adding a test. Tree-SHA512: 9cb5702d474117ce6420226eb93ee09d6fb5fc856fabc8b67abe56a088cd727674e0e5462000e1afa83b911374036f90abdbdde56a8c236a75572ed47e10a00f
2018-12-29test: Add basic test for BIP34MarcoFalke
2018-11-27test: add invalid tx templates for use in functional testsJames O'Beirne
Add templates for easily constructing different kinds of invalid transactions and use them in feature_block and p2p_invalid_tx.
2018-10-25Fix typo in test_framework/blocktoolsMeshCollider
2018-09-04Fix typos reported by codespellpracticalswift
2018-08-09qa: blocktools enforce named args for amountMarcoFalke
2018-08-09[Tests] Cleanup extra instances of create_transactionConor Scott
2018-08-09[Tests] Rename create_tx and move to blocktools.pyConor Scott
2018-07-27Update copyright headers to 2018DrahtBot
2018-04-20[tests] tidy up blocktools.pyJohn Newbery
Moves function comments to docstrings, and moves the module-level constant to the top of the file.
2018-04-20[tests] Fix flake8 warnings in blocktools.pyJohn Newbery
2018-04-20[doc][trivial] no retargeting in regtest modeJesse Cohen
2018-02-17scripted-diff: change signrawtransaction to signrawtransactionwithwallet in ↵Andrew Chow
tests -BEGIN VERIFY SCRIPT- sed -i 's/\<signrawtransaction\>/signrawtransactionwithwallet/g' test/functional/*.py sed -i 's/\<signrawtransaction\>/signrawtransactionwithwallet/g' test/functional/test_framework/*.py -END VERIFY SCRIPT-