Commit Graph

3672 Commits

Author SHA1 Message Date
James O'Beirne
8904f17ea7
test: enable txindex in feature_init
Now that #23365 is merged.
2021-12-29 13:21:24 -05:00
James O'Beirne
93db6d8422
test: feature_init: retain debug.log and improve detection
This test sporadically fails due to the Python test missing log lines
for reasons that are poorly understood. The problem is made worse by the
fact that this test does not retain the log files from iteration to
iteration.

Change the test to do logline detection in a more robust manner (by
using `re.search` on the whole log content) in a way that is comparable
to the existing `assert_debug_log` utility, and retain all debug.log
content from case to case.
2021-12-29 13:04:36 -05:00
James O'Beirne
24fcf6e435
test: feature_init: tweak all .ldb files of a certain type
This part of the test sporadically fails on CI infrastructure. Instead
of perturbing a single .ldb file of each type, move all .ldb files of a
given type to ensure a bad startup.
2021-12-29 13:04:35 -05:00
James O'Beirne
a8ffbc01db
test: add TestNode.wait_for_debug_log 2021-12-29 13:04:34 -05:00
James O'Beirne
a2fb62b632
test: introduce TestNode.debug_log_bytes 2021-12-29 13:04:29 -05:00
Sebastian Falbesoner
d2efb66458 test: use MiniWallet for p2p_compactblocks.py
This test can now be run even with the Bitcoin Core wallet disabled.
2021-12-27 14:39:22 +01:00
Sebastian Falbesoner
e844115dea test: use MiniWallet for rpc_scantxoutset.py
This test can now be run even with the Bitcoin Core wallet disabled.
2021-12-26 15:52:45 +01:00
Sebastian Falbesoner
983ca0456c test: introduce address_to_scriptpubkey helper
Works only with legacy addresses (Base58Check) right now.
2021-12-26 12:10:56 +01:00
Sebastian Falbesoner
e704d4d26f test: introduce getnewdestination helper for generating various address types
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-12-26 12:10:52 +01:00
MarcoFalke
fafe4dea16
test: Fix pep8 of touched file
Can be reviewed with --word-diff-regex=. --ignore-all-space
2021-12-24 12:04:25 +01:00
MarcoFalke
fa0ac9d7e3
test: Fix rpc_scantxoutset intermittent issue 2021-12-24 12:03:21 +01:00
Sebastian Falbesoner
c27bba9672 test: check for invalid listtransactions RPC parameters 2021-12-22 20:44:44 +01:00
Andrew Chow
3ac38058ce
Merge bitcoin/bitcoin#23789: wallet: Strictly match tx change type to improve privacy
fada6c65d2 wallet: Strictly match tx change type to improve privacy (MarcoFalke)

Pull request description:

  Currently the change type will only match a destination by accident, making it easier to determine the change.

  Fix that by strictly matching one of the destinations.

ACKs for top commit:
  S3RK:
    Concept & Approach ACK fada6c6. Also did light code review .
  achow101:
    ACK fada6c65d2
  prayank23:
    tACK fada6c65d2
  w0xlt:
    tACK fada6c6

Tree-SHA512: 2b072c3c32debac7b0bef07a6df9a8f1a631e0f7d556b859973f18894ca490225582dc13e4588b29fa205ffbcd30fb632d5313b304d10ad17a26adc3f7684471
2021-12-20 14:48:22 -05:00
MarcoFalke
9ac064d245
Merge bitcoin/bitcoin#23796: test: check that pruneblockchain RPC fails for future block or timestamp
140a49ce5e test: check that pruneblockchain RPC fails for future block or timestamp (Sebastian Falbesoner)

Pull request description:

  This PR adds missing test coverage for the `pruneblockchain` RPC for the case that a future block or timestamp is passed:
  8c0bd871fc/src/rpc/blockchain.cpp (L1101)
  8c0bd871fc/src/rpc/blockchain.cpp (L1111)
  Note that the test method `manual_test` gets called twice, once each with `use_timestamp` set to True/False, respectively. Depending on that, the helper function `height` either converts the passed block height to the timestamp of that block, or just returns it without modification.

  The other tests for failures in this RPC are also changed to be more detailled ("Cannot prune blocks because node is not in prune mode", "Negative block height"), as I don't think there is any value in just checking a sub-string. If there is ever an error with the same sub-string is introduced, it's not clear which error is exactly checked with the test, so it makes sense to be as specific as possible.

ACKs for top commit:
  brunoerg:
    tACK 140a49ce5e

Tree-SHA512: bee3cee9f35c2a63a1839d7ec1f83e354d9d3c0c2ca32d300dca2de8b755d555f769ba2b80ac37d31df6ee7e2b8eaefb8134c4727a7144e47c0f5e34f2cc5822
2021-12-20 13:32:57 +01:00
MarcoFalke
1c41fb9181
Merge bitcoin/bitcoin#23812: test: fix intermittent failures in p2p_timeouts.py
0a1b6fa5a1 test: fix intermittent timeouts in p2p_timeouts.py (Martin Zumsande)

Pull request description:

  Fixes  #23800 by making sure that all peers are connected (i.e. `m_connected` is set) before the mocktime is bumped.
  We can't wait for verack here, but we can wait for a debug log entry ("Added connection peer=2") instead.

  In the failed CI runs (e.g. https://cirrus-ci.com/task/5600553806856192?logs=ci#L7469)  different peers were added at different mocktimes.

ACKs for top commit:
  naumenkogs:
    ACK 0a1b6fa5a1
  theStack:
    Concept and approach ACK 0a1b6fa5a1

Tree-SHA512: 1a3c8a9a79339d4adc6ecb1731eb0d0eadb2e5024ad3c6779b4696691f85d6c3304ef8689746d0332150a4cf04489ca4b2ff3eeb0bb76feec28c1e4bb9dbca19
2021-12-20 09:13:20 +01:00
MarcoFalke
70d6a09f5c
Merge bitcoin/bitcoin#17631: Expose block filters over REST
2b64fa3251 Update REST docs with new accessors (Matt Corallo)
ef7c8228fd Expose block filters over REST. (Matt Corallo)

Pull request description:

  This adds a new rest endpoint:
  /rest/blockfilter/filtertype/requesttype/blockhash (eg
  /rest/blockfilter/basic/header/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f.hex)
  which exposes either the filter "header" or the filter data itself.
  Most of the code is cribbed from the equivalent RPC.

  You can test it at 000000005b.hex

ACKs for top commit:
  dergoegge:
    ACK 2b64fa3251 - Adding blockfilters to the REST interface is analogous to serving other public data such as transactions or blocks.

Tree-SHA512: d487bc694266375c94d6fcf2e9d788a8a42a3b94e8d3290e46335a64cbcde55084ce5ea6119b79a4065888d94d7c3ae25a59a901fa46e3711f0eb296add12696
2021-12-20 09:00:34 +01:00
Martin Zumsande
0a1b6fa5a1 test: fix intermittent timeouts in p2p_timeouts.py
by checking that all nodes are added before the mocktime is bumped.
Fixes #23800
2021-12-18 11:40:55 +01:00
MarcoFalke
fada6c65d2
wallet: Strictly match tx change type to improve privacy 2021-12-17 07:59:39 +01:00
Sebastian Falbesoner
140a49ce5e test: check that pruneblockchain RPC fails for future block or timestamp 2021-12-16 16:43:27 +01:00
MarcoFalke
6b212cbbb9
Merge bitcoin/bitcoin#23720: test: Refactor addr_relay.py addr generation, increase mocktime
261dddb924 test: Combine addr generation helper functions (Martin Zumsande)
aeeccd9aa6 test: Fix intermittent issue in p2p_addr_relay.py (Martin Zumsande)

Pull request description:

  Fixes #22449 by increasing the mocktime jump (just as in 6168eb06b2), which prevents failures due to rare Poisson timer events, or at least makes them a lot more unlikely.

  The second commit combines the addr generation helper functions `setup_addr_msg` and `setup_rand_addr_msg`. It also changes the way `addr.time` is filled to random, because before, if too many addresses (>600) were created in a batch, they would stop being relayed because their timestamp would be too far in the future.

ACKs for top commit:
  josibake:
    reACK 261dddb924
  jnewbery:
    utACK 261dddb924

Tree-SHA512: d0eca887de4bc85092730284cf612193d2c12b0a3d624a2bfa5fef4a5890d3b6375c564333c5927425958e4b6ec86b8854b18b2233c7b6f1691d9ddc397948a9
2021-12-16 15:07:45 +01:00
Martin Zumsande
261dddb924 test: Combine addr generation helper functions
This combines the addr generation helper functions setup_addr_msg
and setup_rand_addr_msg.
It also changes the way addr.time is filled to random, because before,
if too many addresses (>600) were created in a batch, they would stop
being relayed because their timestamp would be too far in the future.
2021-12-16 12:43:38 +00:00
Martin Zumsande
aeeccd9aa6 test: Fix intermittent issue in p2p_addr_relay.py
by increasing the mocktime bump for m_next_addr_send, which is on a
Poisson timer, and explain why. Closes #22449
2021-12-16 12:43:38 +00:00
MarcoFalke
df6e961c41
Merge bitcoin/bitcoin#23777: doc: follow-ups from #23365 (index backwards search)
e4a8d561ed doc: add explanations for assert in index and magic numbers in test (Martin Zumsande)

Pull request description:

  This adds two explanations suggested in the review of #23365,  that I didn't manage to address before that PR was merged:

  https://github.com/bitcoin/bitcoin/pull/23365#discussion_r763981042
  https://github.com/bitcoin/bitcoin/pull/23365#discussion_r763982639

ACKs for top commit:
  jnewbery:
    ACK e4a8d561ed

Tree-SHA512: 0500c8abb37bb3e3694463ad5e74b2e1483615ccf1d7529b0d5faa694652ada17d242dc7fda6d995733766c627d54178a2c8fa21a570cdf13292f64ff5425b56
2021-12-16 08:55:06 +01:00
MarcoFalke
a30642926a
Merge bitcoin/bitcoin#23721: wallet, refactor: Move restorewallet() logic to the wallet section
62fa61fa4a refactor: remove the wallet folder if the restore fails (w0xlt)
abbb7eccef refactor: Move restorewallet() RPC logic to the wallet section (w0xlt)
4807f73f48 refactor: Implement restorewallet() logic in the wallet section (w0xlt)

Pull request description:

  Currently `restorewallet()` logic is written in the RPC layer and it can´t be reused by GUI. So it moves this to the wallet section and then, GUI can access it.

  This is necessary to implement the "Restore Wallet" menu item in the GUI (which is already implemented  in https://github.com/bitcoin-core/gui/pull/471 ).

  This commit also simplifies error handling and adds a new behavior: if the restore fails, the invalid wallet folder is removed.

ACKs for top commit:
  achow101:
    ACK 62fa61fa4a
  shaavan:
    crACK 62fa61fa4a

Tree-SHA512: 7ccfbad5943f38616ba0c2dd443c97a4b5bc1f6612dbf5a9e7a0263100aba36671fae929a2e7688442667be394645f44484af137a4802f204a33c4689eb27c39
2021-12-16 08:42:44 +01:00
MarcoFalke
98c362a4d3
Merge bitcoin/bitcoin#23782: test: include two more interruptions points
618f4d2890 test: re-organized array according to order of logs and included 2 more interruption events (seaona)
71115a5e23 test: include two more interruptions points (seaona)

Pull request description:

  This PR aims to introduce 2 more interruption points in the process of initialization, in order to make the` feature_init `testcase more complete. These are the following:

  -` Checking all blk files are present`
  -` init message: Starting network threads`

  It is a small improvement for increasing the coverage of potential interruptions, and making sure that the node can restart successfully after these interruptions.

ACKs for top commit:
  jamesob:
    ACK 618f4d2890, pending CI
  jarolrod:
    ACK 618f4d2890

Tree-SHA512: 9d709734e298e955709094bb97478ca7f18859874f1ba026f7c9014d87205aea63f6cf2093ebee600eaf82d3245adb11e77fae24a1ae48b69efefd57f3def921
2021-12-16 07:47:40 +01:00
w0xlt
62fa61fa4a refactor: remove the wallet folder if the restore fails 2021-12-15 18:41:40 -03:00
w0xlt
abbb7eccef refactor: Move restorewallet() RPC logic to the wallet section
It also simplifies restorewallet() and loadwallet() RPC error handling.
2021-12-15 18:41:40 -03:00
seaona
618f4d2890 test: re-organized array according to order of logs and included 2 more interruption events 2021-12-15 16:17:54 +01:00
seaona
71115a5e23 test: include two more interruptions points 2021-12-15 13:32:32 +01:00
MarcoFalke
60b5795133
Merge bitcoin/bitcoin#23758: net: Use type-safe mockable time for peer connection time
fad943821e scripted-diff: Rename touched member variables (MarcoFalke)
fa663a4c0d Use mockable time for peer connection time (MarcoFalke)
fad7ead146 refactor: Use type-safe std::chrono in net (MarcoFalke)

Pull request description:

  Benefits:
  * Type-safe
  * Mockable
  * Allows to revert a temporary test workaround

ACKs for top commit:
  naumenkogs:
    ACK fad943821e
  shaavan:
    ACK fad943821e

Tree-SHA512: af9bdfc695ab727b100c6810a7289d29b02b0ea9fa4fee9cc1f3eeefb52c8c465ea2734bae0c1c63b3b0d6264ba2c493268bc970ef6916570eb166de77829d82
2021-12-15 13:07:34 +01:00
Martin Zumsande
e4a8d561ed doc: add explanations for assert in index and magic numbers in test
These were suggested in review of #23365

Co-authored-by: John Newbery <john@johnnewbery.com>
2021-12-15 10:05:11 +00:00
Andrew Chow
efa115aa4a tests: Add missing assert_equal import to p2p_add_connections.py 2021-12-14 12:28:25 -05:00
MarcoFalke
9635760ce8
Merge bitcoin/bitcoin#22777: net processing: don't request tx relay on feeler connections
eaf6be0114 [net processing] Do not request transaction relay from feeler connections (John Newbery)
0220b834b1 [test] Add testing for outbound feeler connections (John Newbery)

Pull request description:

  Feelers are short-lived connections used to test the viability of peers. The bitcoind node will periodically open feeler connections to addresses in its addrman, wait for a `version` message from the peer, and then close the connection.

  Currently, we set `fRelay` to `1` in the `version` message for feeler connections, indicating that we want the peer to relay transactions to us. However, we close the connection immediately on receipt of the `version` message, and so never process any incoming transaction announcements. This PR changes that behaviour to instead set `fRelay` to `0` indicating that we do not wish to receive transaction announcements from the peer.

  This PR also extends the `addconnection` RPC to allow creating outbound feeler connections from the node to the test framework, and a test to verify that the node sets `fRelay` to `0` in the `version` message to feeler connections.

ACKs for top commit:
  naumenkogs:
    ACK eaf6be0114
  MarcoFalke:
    review ACK eaf6be0114 🏃

Tree-SHA512: 1c56837dbd0a396fe404a5e39f7459864d15f666664d6b35ad109628b13158e077e417e586bf48946a23bd5cbe63716cb4bf22cdf8781b74dfce6047b87b465a
2021-12-14 17:57:10 +01:00
MarcoFalke
5dd28e5cff
Merge bitcoin/bitcoin#23755: rpc: Quote user supplied strings in error messages
fa24a3df87 rpc: Quote user supplied strings in error messages (MarcoFalke)

Pull request description:

  I can't see a downside doing this and this fixes a fuzzing crash

  Background:

  This is a follow-up to commit 926fc2a0d4, which introduced the "starts_with-hack". Maybe an alternative to the hack would be to assign a unique error code to internal bugs? However, I think this can be done in an separate pull request and the changes here make sense even on their own.

ACKs for top commit:
  fanquake:
    ACK fa24a3df87 - to fix the fuzzers.

Tree-SHA512: d998626406a64396a037a6d1fce22fce3dadb7567c2f9638e450ebe8fb8ae77d134e15dd02555326732208f698d77b0028bc62be9ceee9c43282b61fe95fccbd
2021-12-13 17:13:42 +01:00
MarcoFalke
c8fac372c2
Merge bitcoin/bitcoin#23648: test: Use byte unit 'M' for -maxuploadtarget functional test
41b9f7d062 test: Use byte unit 'M' for -maxuploadtarget functional test (Douglas Chimento)

Pull request description:

ACKs for top commit:
  shaavan:
    ACK 41b9f7d062
  stratospher:
    ACK 41b9f7d.

Tree-SHA512: 25b46347c671e8d6fd8878e7fee40e773bb03641e53e41e8a79a286fe4a0cf71c0c0986d6d7418fcb656c07f7216cc50a7ee4366f9213c32b01ae74326031f80
2021-12-13 16:31:42 +01:00
MarcoFalke
fa24a3df87
rpc: Quote user supplied strings in error messages 2021-12-13 15:18:35 +01:00
MarcoFalke
bf66e258a8
Merge bitcoin/bitcoin#23365: index: Fix backwards search for bestblock
9600ea0145 test: Add edge case of pruning up to index height (Martin Zumsande)
698c524698 index: Fix backwards search for bestblock (Martin Zumsande)

Pull request description:

  This PR attempts to fix an intermittent Init issue encountered during the stress testing of #23289, which relates to the pruning-compatible filter reconstruction logic introduced in #15946.

  The problem would occur when the node starts with `-txindex=1` but `ThreadSync` is interrupted after it sets `m_best_block_index` to Genesis, and before it gets do any further work.
  In that case, during the next restart of the node, an Init error would be thrown because  `BaseIndex::Init()` tries to backtrack from the tip to the last block which has been successfully indexed (here: Genesis), but the backtracking logic didn't work properly in this case:
  The loop
  `while (block_to_test && block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA))` checks if a predecessor exists **before** performing the check `block_to_test == block` and then possbily setting `prune_violation = false`
  If `block_to_test` and `block` are the Genesis block this check will not be reached because `block->pprev` does not exist.

  To reproduce this bug on regtest:
  1) start a node with a fresh datadir using `-txindex=1` (or any other index)
  2) stop and restart without any index
  3) mine a block
  3) stop and restart again with the index enabled
  ->InitError `Error: txindex best block of the index goes beyond pruned data. (...)`

  Fix this by requiring that we have the data for the block of the current iteration `block` (instead of requiring it for the predecessor `block->pprev`)
  That way, the check for `block_to_test == block` is also reached when `block_to_test` is the Genesis block.
  No longer requiring the data of `block->pprev` also means that we can now prune up to `m_best_block_index` height without requiring a reindex (one block more than before). I added this edge case to `feature_blockfilterindex_prune.py`, the new version should fail on master.

ACKs for top commit:
  ryanofsky:
    Partial code review ACK 9600ea0145 for the code change, not the test changes. (Test changes are indirect and little over my head.) It seems obvious that previous code `prune_violation = true, while (block->pprev)` would incorrectly detect a prune violation at the genesis block, and the fix here make sense and looks correct.

Tree-SHA512: c717f372cee8fd49718b1b18bfe237aa6ba3ff4468588c10e1272d7a2ef3981d10af4e57de51dec295e2ca72d441bc6c2812f7990011a94d7f818775e3ff1a38
2021-12-13 13:38:02 +01:00
MarcoFalke
fa663a4c0d
Use mockable time for peer connection time
This allows to revert the temporary commit
0bfb9208df (test: fix test failures in
test/functional/p2p_timeouts.py).
2021-12-13 13:32:05 +01:00
Antoine Poinsot
a9256dc340
rpc: output all hash preimages in 'decodepsbt' 2021-12-11 18:32:17 +01:00
MarcoFalke
ac92ab6da5
Merge bitcoin/bitcoin#23113: Add warnings to createmultisig and addmultisig if using uncompressed keys
d5cab1a96d Add createmultisig and addmultisigaddress warnings release note (Samuel Dobson)
e46fc935aa Add warnings field to addmultisigaddress to warn about uncompressed keys (Samuel Dobson)
d1a9742623 Add warnings field to createmultisig to warn about uncompressed keys (Samuel Dobson)

Pull request description:

  Fixes #21368

  Currently, if there are any uncompressed keys when calling `AddAndGetMultisigDestination`, it will just default to a legacy address regardless of the chosen `address_type`. Rather than keeping this silent behaviour which may be confusing to users, we explicitly add a `warnings` field which will warn the user why their address format is different.

ACKs for top commit:
  achow101:
    ACK d5cab1a96d

Tree-SHA512: c2ac7f7689251bd4fcd8c26506f053921fbaf34c7a26a74e82ebc7f82cc0bd25407fd7954bf98365dcafa51fa45dcdbee6214320580ca69509690c3555e71cc0
2021-12-11 09:41:25 +01:00
Jon Atack
0bfb9208df test: fix test failures in test/functional/p2p_timeouts.py 2021-12-11 01:20:32 +01:00
Douglas Chimento
41b9f7d062
test: Use byte unit 'M' for -maxuploadtarget functional test 2021-12-10 20:41:34 +02:00
Andrew Chow
d8043ddf64 Add global xpub test vectors from BIP 2021-12-10 08:29:47 -05:00
Andrew Chow
94065cc6c5 Test for proprietary field 2021-12-10 08:29:47 -05:00
Andrew Chow
c3eb416b88 Implement PSBT versions 2021-12-10 08:29:26 -05:00
MarcoFalke
011d6e429b
Merge bitcoin/bitcoin#22514: psbt: Actually use SIGHASH_DEFAULT for PSBT signing
c0405ee27f rpc: Document that DEFAULT is for Taproot, ALL for everything else (Andrew Chow)
d3992669df psbt: Actually use SIGHASH_DEFAULT (Andrew Chow)
eb9a1a2c59 psbt: Make sighash_type std::optional<int> (Andrew Chow)

Pull request description:

  Make the behavior align with the help text by actually using SIGHASH_DEFAULT as the default sighash for signing PSBTs.

ACKs for top commit:
  Sjors:
    re-utACK c0405ee27f

Tree-SHA512: 5199fb41de416b2f10ac451f824e7c94b428ba11fdb9e50f0027c692e959ce5813a340c34a4e52d7aa128e12008303d80939a693eff36a869720e45442119828
2021-12-10 10:17:36 +01:00
MarcoFalke
9f7661c0c4
Merge bitcoin/bitcoin#19499: p2p: Make timeout mockable and type safe, speed up test
fadc0c80ae p2p: Make timeout mockable and type safe, speed up test (MarcoFalke)
fa6d5a238d scripted-diff: Rename m_last_send and m_last_recv (MarcoFalke)

Pull request description:

  Use type-safe time for better code readability/maintainability and mockable time for better testability. This speeds up the p2p_timeout test.

  This is also a bugfix for intermittent test issues like: https://cirrus-ci.com/task/4769904156999680?command=ci#L2836

  Fixes #20654

ACKs for top commit:
  laanwj:
    Code review ACK fadc0c80ae
  naumenkogs:
    ACK fadc0c80ae

Tree-SHA512: 28c6544c97f188c8a0fbc80411c74ab74ffd055885322c325aa3d1c404b29c3fd70a737e86083eecae58ef394db1cb56bc122d06cff63742aa89a8e868730c64
2021-12-10 10:02:12 +01:00
fanquake
09ad512369
Merge bitcoin/bitcoin#23628: Check descriptors returned by external signers
5493e92501 Check descriptors returned by external signers (sstone)

Pull request description:

  Check that descriptors returned by external signers have been parsed properly when creating a new wallet.
  See https://github.com/bitcoin/bitcoin/issues/23627 for context.

  The problem is that parsing an invalid descriptor will return `null` which is not checked for in `CWallet::SetupDescriptorScriptPubKeyMans()`.

  I'm not completely sure what the best fix is since there several strategies for dealing with errors in the current codebase but the proposed fix is very simple and consistent with other validation checks in `CWallet::SetupDescriptorScriptPubKeyMans()`.

ACKs for top commit:
  jamesob:
    Code review ACK 5493e92501
  achow101:
    ACK 5493e92501

Tree-SHA512: 63259f4aa519405a86c554b6813efdb741314bdaa18bf005b70ea8bb92a27abc6e2b65f7c584641dc257fc78a6499f42b51b5310c243e611c4663430dccf3d04
2021-12-10 09:17:35 +08:00
Sebastian Falbesoner
61fb410c0d test: add feature_coinstatsindex.py --descriptors to test_runner.py 2021-12-09 16:40:52 +01:00
Sebastian Falbesoner
50b044a88e test: fix test feature_coinstatsindex.py for descriptor wallets 2021-12-09 16:40:35 +01:00