Commit Graph

78 Commits

Author SHA1 Message Date
Hennadii Stepanov
a0473442d1
scripted-diff: Add __file__ argument to BitcoinTestFramework.init()
-BEGIN VERIFY SCRIPT-
sed -i -e 's/\s*().main\s*()/(__file__).main()/' $(git ls-files test/functional/*.py)
sed -i -e 's/def __init__(self)/def __init__(self, test_file)/' test/functional/test_framework/test_framework.py
-END VERIFY SCRIPT-
2024-07-16 22:06:47 +01:00
MarcoFalke
fa46cc22bc
Remove deprecated -rpcserialversion 2023-12-11 18:22:13 +01:00
Anthony Towns
971bae9174 rpc: Deprecate rpcserialversion=0 2023-09-11 17:21:53 +10:00
Anthony Towns
1b09cc5959 Make post-p2sh consensus rules mandatory for tx relay 2023-08-18 00:59:27 +10:00
Hennadii Stepanov
306ccd4927
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-

Commits of previous years:
- 2021: f47dda2c58
- 2020: fa0074e2d8
- 2019: aaaaad6ac9
2022-12-24 23:49:50 +00:00
MacroFake
555519d082
test: Remove wallet option from non-wallet tests
Review note: The changes are complete, because self.options.descriptors
is set to None in parse_args (test_framework.py).

A value of None implies -disablewallet, see the previous commit.

So if a call to add_wallet_options is missing, it will lead to a test
failure when the wallet is compiled in.
2022-11-10 17:19:13 +01:00
brunoerg
155344960b test: negative/unknown rpcserialversion should throw an init error 2022-08-01 10:55:05 -03:00
MarcoFalke
fa8593f898
test: Fix generate calls and comments in feature_segwit 2022-03-18 16:23:43 +01:00
DrahtBot
d6b24e14d2 test: Fix intermittent failure in feature_segwit 2022-03-16 19:56:31 +01:00
glozow
40e871d9b4 [miner] always assume we can create witness blocks
Given the low possibility of a reorg reverting the segwit soft fork,
there is no need to check whether segwit is active here. Also,
TestBlockValidity is run on the block template after it has been
created.
2022-02-23 10:55:05 +00:00
MarcoFalke
fac23c2114
scripted-diff: Bump copyright headers
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-10 11:10:24 +01:00
MarcoFalke
fa974f1f14
scripted-diff: Remove redundant sync_all and sync_blocks
The sync calls are redundant after a call to generate, because generate
already syncs itself.

-BEGIN VERIFY SCRIPT-
perl -0777 -pi -e 's/(generate[^\n]*\)[^\n]*)(\n|\s)+self.sync_(all|blocks)\([^\)]*\)\n/\1\n/g' $(git grep -l generate ./test)
-END VERIFY SCRIPT-
2021-11-10 11:10:15 +01:00
Sebastian Falbesoner
4718897ce3 test: add script_util helper for creating bare multisig scripts 2021-10-26 14:51:18 +02:00
Andrew Chow
ae6cbcc909 tests: restrict feature_segwit legacy wallet import tests
A portion of feature_segwit deals with the legacy wallet IsMine and
import behavior. This is now hidden behind --legacy-wallet
2021-10-19 18:41:46 -04:00
Andrew Chow
1d13c44a4c tests: Use descriptors for feature_segwit multisig setup
When setting up the multisig addresses in feature_segwit.py, use
descriptors rather than addmultisigaddress.
2021-10-19 18:41:05 -04:00
Sebastian Falbesoner
429b49378e test: introduce script_util helper for creating P2PK scripts 2021-09-29 14:09:14 +02:00
Samuel Dobson
b207971465 Fix feature_segwit failure due to witness 2021-09-29 17:41:35 +13:00
MarcoFalke
fa8f3ba131
test: pep-8 2021-09-28 10:52:33 +02:00
MarcoFalke
fac5708afc
test: Use assert_equal over assert for easier debugging 2021-09-28 10:48:51 +02:00
MarcoFalke
faad1e5ffd
Introduce -testactivationheight=name@height setting 2021-09-16 18:52:59 +02:00
MarcoFalke
fa0b916971
scripted-diff: Use generate* from TestFramework
-BEGIN VERIFY SCRIPT-
 sed --regexp-extended -i \
     's/((self\.)?(nodes\[[^]]+\]|[a-z_]*(wallet|node)[0-9a-z_]*))\.(generate(|toaddress|block|todescriptor)(\(|, ))/self.\5\1, /g' \
     $(git grep -l generate ./test | grep -v 'test_framework/' | grep -v 'feature_rbf')
-END VERIFY SCRIPT-
2021-09-02 10:34:35 +02:00
fanquake
31bdb33dcb
test: use f-strings in feature_segwit.py 2021-08-18 12:39:20 +08:00
MarcoFalke
b620b2d58a
Merge bitcoin/bitcoin#22378: test: remove confusing MAX_BLOCK_BASE_SIZE
607076d01b test: remove confusing `MAX_BLOCK_BASE_SIZE` (Sebastian Falbesoner)
4af97c74ed test: introduce `get_weight()` helper for CBlock (Sebastian Falbesoner)
a084ebe133 test: introduce `get_weight()` helper for CTransaction (Sebastian Falbesoner)

Pull request description:

  This is a very late follow-up PR to #10618, which removed the constant `MAX_BLOCK_BASE_SIZE` from the core implementation about four years ago (see also #10608 in why it was considered confusing and superfluous).
  Since there is also no point in still keeping it in the functional test framework, the PR switches to weight-based accounting on the relevant test code parts and use `MAX_BLOCK_WEIGHT` instead for the block limit checks. To prepare that, the first two commits introduce `get_weight()` helpers for the classes CTransaction and CBlock, respectively.

ACKs for top commit:
  MarcoFalke:
    review ACK 607076d01b 🚴

Tree-SHA512: d59aa0b6b3dfd0a849b8063e66de275d252f705f99e25cd3bf6daec028b47d946777ee5b42a060f5283cb18e917ac073119c2c0e11bbc21211f69ef0a6ed335a
2021-08-02 15:51:48 +02:00
Sebastian Falbesoner
ca6c154ef1 test: refactor: remove hex_str_to_bytes helper
Use the built-in class method bytes.fromhex() instead,
which is available since Python 3.0.
2021-08-01 19:26:51 +02:00
Sebastian Falbesoner
905d672b74 test: use script_util helpers for creating P2W{PKH,SH} scripts 2021-07-05 20:40:52 +02:00
Sebastian Falbesoner
285a65ccfd test: use script_util helpers for creating P2SH scripts 2021-07-05 20:40:47 +02:00
Sebastian Falbesoner
a084ebe133 test: introduce get_weight() helper for CTransaction 2021-07-01 02:32:25 +02:00
Sebastian Falbesoner
b57b633b94 test: use script_util helpers for creating P2PKH scripts 2021-06-28 20:14:07 +02:00
Sebastian Falbesoner
a79396fe5f test: remove ToHex helper, use .serialize().hex() instead 2021-06-21 14:30:03 +02:00
Sebastian Falbesoner
2ce7b47958 test: introduce tx_from_hex helper for tx deserialization
`FromHex` is mostly used for transactions, so we introduce a
shortcut `tx_from_hex` for `FromHex(CTransaction, hex_str)`.
2021-06-21 14:28:05 +02:00
Michael Dietz
085b3a7299
rpc: deprecate addresses and reqSigs from rpc outputs
1) add a new sane "address" field (for outputs that have an
   identifiable address, which doesn't include bare multisig)
2) with -deprecatedrpc: leave "reqSigs" and "addresses" intact
   (with all weird/wrong behavior they have now)
3) without -deprecatedrpc: drop "reqSigs" and "addresses" entirely,
   always.
2021-03-23 10:51:43 -04:00
Prayank
4b16c61461 scripted-diff: test: Replace uses of (dis)?connect_nodes global
-BEGIN VERIFY SCRIPT-

 # max-depth=0 excludes test/functional/test_framework/...
 FILES=$(git grep -l --max-depth 0 "connect_nodes" test/functional)

 # Replace (dis)?connect_nodes(self.nodes[a], b) with self.(dis)?connect_nodes(a, b)
 sed -i 's/\b\(dis\)\?connect_nodes(self\.nodes\[\(.*\)\]/self.\1connect_nodes(\2/g' $FILES

 # Remove imports in the middle of a line
 sed -i 's/\(dis\)\?connect_nodes, //g' $FILES
 sed -i 's/, \(dis\)\?connect_nodes//g' $FILES

 # Remove imports on a line by themselves
 sed -i '/^\s*\(dis\)\?connect_nodes,\?$/d' $FILES
 sed -i '/^from test_framework\.util import connect_nodes$/d' $FILES

-END VERIFY SCRIPT-

Co-authored-by: Elliott Jin <elliott.jin@gmail.com>
2020-10-20 00:42:00 -07:00
MarcoFalke
cb21d864c5
Merge #19401: QA: Use GBT to get block versions correct
d438d609cd QA: Use GBT to get block versions correct (Luke Dashjr)
1df2cd1c8f 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 d438d609cd
  benthecarman:
    ACK d438d60

Tree-SHA512: 523b1cd4dac8d65c88432e126ce7f60df96ca4b94f7ecc8e83ba4ffbade23e2afe7055fdf586ce3c195a533f2004e63fff83add4267b39473a581c9f1c6d5340
2020-10-16 11:43:21 +02:00
Luke Dashjr
d438d609cd QA: Use GBT to get block versions correct 2020-09-12 18:24:26 +00:00
Sebastian Falbesoner
dac7a111bd refactor: test: use _ variable for unused loop counters
substitutes "for x in range(N):" by "for _ in range(N):"
indicates to the reader that a block is just repeated N times, and
that the loop counter is not used in the body
2020-08-06 18:39:33 +02:00
Christopher Coverdale
20b6e95944
test: refactor functional tests to use restart_node 2020-06-22 12:58:14 +01:00
MarcoFalke
297466b49f
Merge #18826: Expose txinwitness for coinbase in JSON form from RPC
34645c4dd0 Test txinwitness is accessible on coinbase vin (Rod Vagg)
3e4421070a Expose txinwitness for coinbase in JSON form (Rod Vagg)

Pull request description:

  ## Rationale

  The CLI can provide you with everything about transactions and blocks that you need to reconstruct the block structure and raw block itself **except** for the witness commitment nonce which is stored in the `scriptWitness` of the coinbase and is not printed. You could manually parse the raw `"hex"` fields for transactions if you really wanted to, but this seems to defeat the point of having a JSONification of the raw block/transaction data.

  Without the nonce you can't:

  1. calculate and validate the witness commitment yourself, you can generate the witness tx merkle root but you don't have the nonce to combine it with
  2. reconstruct the raw block form because you don't have `scriptWitness` stack associated with the coinbase (although you know how big it will be and can guess the common case of `[0x000...000]`)

  I'm building some archiving tooling for block data and being able to do a validated two-way conversion is very helpful.

  ## What

  This PR simply makes the `txinwitness` field not dependent on whether we are working with the coinbase or not. So you get it for the coinbase as well as the rest.

  ## Examples

  Common case of a `[0x000...000]` nonce: 00000000000000000000140a7289f3aada855dfd23b0bb13bb5502b0ca60cdd7

  ```json
        "vin": [
          {
            "coinbase": "0368890904c1fe8d5e2f706f6f6c696e2e636f6d2ffabe6d6d5565843a681160cf7b08b1b74ac90a719e6d6ab28c16d336b924f0dc2fcabdc6010000000000000051bf2ad74af345dbe642154b2658931612a70d195e007add0100ffffffff",
            "txinwitness": [
              "0000000000000000000000000000000000000000000000000000000000000000"
            ],
            "sequence": 4294967295
          }
        ],
  ...
  ```

  Novel nonce value: 000000000000000000008c31945b2012258366cc600a3e9a3ee0598e8f797731

  ```json
        "vin": [
          {
            "coinbase": "031862082cfabe6d6d80c099b5e21f4c186d54eb292e17026932e52b1b807fa1380574c5adc1c843450200000000000000",
            "txinwitness": [
              "5b5032506f6f6c5d5b5032506f6f6c5d5b5032506f6f6c5d5b5032506f6f6c5d"
            ],
            "sequence": 4294967295
          }
        ],
  ...
  ```

  ## Alternatives

  This field could be renamed for the coinbase, `"witnessnonce"` perhaps. It could also be omitted when null/zero (`0x000...000`).

  ## Tests

  This didn't break any tests and I couldn't find an obvious way to include a test for this. If this is desired I'd apreicate some pointers.

ACKs for top commit:
  MarcoFalke:
    ACK 34645c4dd0

Tree-SHA512: b192facc1dfd210a5ec3f0d5d1ac6d0cae81eb35be15eaa71f60009a538dd6a79ab396f218434e7e998563f7f0df2c396cc925cb91619f6841c5a67806148c85
2020-06-08 10:18:42 -04:00
MarcoFalke
aa8d76806c
Merge #17946: Fix GBT: Restore "!segwit" and "csv" to "rules" key
412d5fe879 QA: feature_segwit: Check that template "rules" includes "!segwit" as appropriate (Luke Dashjr)
2abe8cc3b7 Bugfix: Include "csv","!segwit" in "rules" (Luke Dashjr)

Pull request description:

  #16060 removed CSV & segwit from versionbits, breaking the "rules" key returned by GBT.

  Without this, miners don't know they're mining segwit blocks, and should fall back to pre-segwit block creation.

ACKs for top commit:
  sipa:
    ACK 412d5fe879
  jnewbery:
    Tested ACK 412d5fe879.

Tree-SHA512: 825d72e257dc0dd4941f2fe498d8d4f4f2a21b9505cd21a8f9eb7fb5d6d7dd9219347928cf90bb57a777920ce24295859763e64fa8a22ebb58fc2380f80f5615
2020-05-19 08:54:23 -04:00
Rod Vagg
34645c4dd0
Test txinwitness is accessible on coinbase vin 2020-05-08 12:19:34 +10:00
MarcoFalke
b6a5dc90bf
Merge #18384: [test] more specific feature_segwit test error messages and fixing incorrect comments
3c21db7b78 [test] add 8 error messages to feature_segwit and change version to type (Gloria Zhao)

Pull request description:

  Followup to [this](https://github.com/bitcoin/bitcoin/pull/15169/files#r303673472) comment on functional test feature_segwit.py verifying that unsigned witness transactions are invalid.

  (1) Changes 8 error messages from "mandatory-script-verify-flag" to "non-mandatory-script-verify-flag" and with more specific error messages.
  (2) Edits comments that incorrectly describe the test, namely that the `v` variable corresponds to using P2WSH versus P2WPKH, not witness versions.

ACKs for top commit:
  MarcoFalke:
    ACK 3c21db7b78 🍾

Tree-SHA512: 3734ea3762667636c4fb20f5285634ab94d6b3527b7390fcc5e41b4582829dfe0099beabeaed42098613d168ede3385a6ffcd73989d1fa9dbd18004f5e9cf083
2020-04-21 13:42:21 -04:00
Gloria Zhao
3c21db7b78 [test] add 8 error messages to feature_segwit and change version to type
P2WPKH witness program without signature -> throws "hash mismatch" error
P2WSH witness program without signature -> throws "empty witness" error
same errors for P2SH_P2WPKH and P2SH_P2WSH respectively when passed redeemScript but no signature
P2SH_P2WPKH and P2SH_P2WSH with no signature fail with "Operation not valid with current stack size" when not signed due to missing input
change VER to TYPE and constants WIT_V0 to P2WPKH=0 and WIT_V1 to P2WSH=1
2020-04-21 08:17:42 -07:00
MarcoFalke
fa488f131f
scripted-diff: Bump copyright headers
-BEGIN VERIFY SCRIPT-
./contrib/devtools/copyright_header.py update ./
-END VERIFY SCRIPT-
2020-04-16 13:33:09 -04:00
MarcoFalke
4444edc2e6
ci: Enable all functional tests in valgrind 2020-03-10 18:38:42 -04:00
Luke Dashjr
412d5fe879 QA: feature_segwit: Check that template "rules" includes "!segwit" as appropriate 2020-01-17 05:28:48 +00:00
fanquake
b6f9e3576a
test: re-enable CLI test support by using EncodeDecimal in json.dumps()
As mentioned in
https://github.com/bitcoin/bitcoin/pull/17675#issuecomment-563188648
2019-12-09 15:14:20 -05:00
practicalswift
993e38a4e2 tests: Mark functional tests not supporting bitcoin-cli (--usecli) as such 2019-12-06 14:40:28 +00:00
John Newbery
0053e16714 [logging] Don't log REJECT code when transaction is rejected
Remove the BIP61 REJECT code from error messages and logs when a
transaction is rejected.

BIP61 support was removed from Bitcoin Core in
fa25f43ac5. The REJECT codes will be
removed from the codebase entirely in the following commit.
2019-10-10 11:19:42 -04:00
Jon Atack
6659810e2f
test: use named args for sendrawtransaction calls
involving more than one argument.
2019-09-22 12:27:28 +02:00
Wladimir J. van der Laan
0ee0474234
Merge #16521: rpc: Use the default maxfeerate value as BTC/kB
2dfd6834ef test: Add test for default maxfeerate in sendrawtransaction (Joonmo Yang)
261843e4be wallet/rpc: Use the default maxfeerate value as BTC/kB (Joonmo Yang)

Pull request description:

  Fixes https://github.com/bitcoin/bitcoin/issues/16382

  This patch tries to treat `maxfeerate` in sendrawtransaction/testmempoolaccept RPC as a rate(BTC/kB) instead of an absolute value(BTC).
  The included test case checks if the new behavior works correctly, by using the transaction with an absolute fee of ~0.02BTC, where the fee rate is ~0.2BTC/kB.
  This test should be failing if the default `maxfeerate` is 0.1BTC, but pass if the default value is 0.1BTC/kB

ACKs for top commit:
  laanwj:
    ACK 2dfd6834ef (ACKs by Sjors and MarcoFalke above for trivially different code)

Tree-SHA512: a1795bffe8a182acef8844797955db1f60bb0c0ded97148f3572dc265234d5219271a3a7aa0b6418a43f73b2b2720ef7412ba169c99bb1cdcac52051f537d6af
2019-09-18 16:49:18 +02:00
Daniel Edgecumbe
9c9cc2bd20
qa: Add RPC tests for weight in mempool entry 2019-08-19 11:45:19 +08:00