aboutsummaryrefslogtreecommitdiff
path: root/test/functional/p2p_filter.py
AgeCommit message (Collapse)Author
2024-02-28test: add option to speed up tx relay/mempool syncbrunoerg
when `self.noban_tx_relay=True`, the following flag `-whitelist=noban,in,out@127.0.0.1`is added to `extra_args` to speed up tx relay/mempool sync.
2023-12-06test: Extends MEMPOOL msg functional testSergi Delgado Segura
Currently, p2p_filter.py::test_msg_mempool is not testing much. This extends the tests so the interaction between sending MEMPOOL messages with a filter that does not include all transactions in the mempool reacts, plus how it interacts with INV messages
2023-09-05test: Combine sync_send_with_ping and sync_with_pingMarcoFalke
2023-05-12test: Return dict in MiniWallet::send_toMarcoFalke
2023-01-16test: add `rescan_utxos` in MiniWallet's initializationkouloumos
this simplifies usage when MiniWallet is used with a pre-mined chain.
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-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-09-27test: use MiniWallet for p2p_filter.pySebastian Falbesoner
This test can now be run even with the Bitcoin Core wallet disabled.
2021-09-02scripted-diff: Use generate* from TestFrameworkMarcoFalke
-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-04-28test: Fix intermittent issue in p2p_addr_relay.pyMarcoFalke
2021-03-23rpc: deprecate `addresses` and `reqSigs` from rpc outputsMichael Dietz
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-02-17[test] Add P2P_SERVICES to p2p.pyJohn Newbery
The messages.py module should contain code and helpers for [de]serializing p2p messages. Specific usage of those messages should be in p2p.py. Therefore specify the nServices value in the calling code, not in the messages.py module.
2021-02-17[test] Move MY_RELAY to p2p.pyJohn Newbery
messages.py is for message and primitive data structures. Specifics about the test framework's p2p implementation should be in p2p.py. Also rename to P2P_VERSION_RELAY. Also rename msg_version.nRelay to relay. In Bitcoin Core, this is referred to as fRelay, since it's a bool, so this field has always been misnamed.
2021-02-17[test] Move MY_SUBVERSION to p2p.pyJohn Newbery
The messages.py module should contain code and helpers for [de]serializing p2p messages. Specific usage of those messages should be in p2p.py. Therefore move MY_SUBVERSION to p2p.py. Also rename to P2P_SUBVERSION.
2021-02-17[test] Move MY_VERSION to p2p.pyJohn Newbery
The messages.py module should contain code and helpers for [de]serializing p2p messages. Specific usage of those messages should be in p2p.py. Therefore move MY_VERSION to p2p.py. Also rename to P2P_VERSION to distinguish it from other versioning used in Bitcoin/Bitcoin Core. Also always set the nVersion field in CBlockLocator to 0 and ignore the field in deserialized messages. The field is not currently used for anything in Bitcoin Core.
2021-02-01scripted-diff: Remove setup_clean_chain if default is not changedFabian Jahr
-BEGIN VERIFY SCRIPT- git grep -l "self.setup_clean_chain = False" test/functional/*.py | xargs sed -i "/self.setup_clean_chain = False/d"; -END VERIFY SCRIPT-
2020-09-10[refactor] clarify tests by referencing p2p objects directlygzhao408
Use object returned from add_p2p_connection to refer to p2ps. Add a test class attribute if it needs to be used across many methods. Don't use the p2p property.
2020-08-21scripted-diff: Rename mininode to p2pJohn Newbery
-BEGIN VERIFY SCRIPT- sed -i 's/\.mininode/\.p2p/g' $(git grep -l "mininode") git mv test/functional/test_framework/mininode.py test/functional/test_framework/p2p.py -END VERIFY SCRIPT-
2020-08-21scripted-diff: Rename mininode_lock to p2p_lockJohn Newbery
-BEGIN VERIFY SCRIPT- sed -i 's/mininode_lock/p2p_lock/g' $(git grep -l "mininode_lock") -END VERIFY SCRIPT-
2020-08-04test: Wait until is_connected in add_p2p_connectionMarcoFalke
2020-07-14test: Fail wait_until early if connection is lostMarcoFalke
2020-06-16[test] logging and style followups for bloomfilter testsgzhao408
-Use peer to refer to mininodes instead of node because they are not bitcoind nodes. -Use log.debug for logs that give helpful but not super necessary information. -Adhere to style guidelines (newlines, capitalization).
2020-06-10scripted-diff: rename node to peer for mininodesgzhao408
-BEGIN VERIFY SCRIPT- sed -i 's/FilterNode/P2PBloomFilter/g' test/functional/p2p_filter.py; sed -i 's/filter_node/filter_peer/g' test/functional/p2p_filter.py; -END VERIFY SCRIPT-
2020-06-10[test] fix race conditions and test in p2p_filtergzhao408
-grab mininode_lock for every access to mininode attributes, otherwise there are race conditions
2020-06-10[test] add BIP 37 test for node with fRelay=falsegzhao408
A node with fRelay=False should not receive any invs until filter is set using filterload; all other behavior should be identical.
2020-06-10[test] add mempool msg test for node with bloomfilter enabledgzhao408
-msg_mempool is currently only tested with bloomfilter disabled (node is disconnected) in p2p_mempool.py -msg_mempool should get mempool txns in response when bloomfilter is enabled -edit test that doesn't test msg_mempool as intended
2020-04-25test: check misbehavior more independently in p2p_filter.pyDanny Lee
2020-04-21test: Fix linter issueHennadii Stepanov
2020-04-20test: add further BIP37 size limit checks to p2p_filter.pySebastian Falbesoner
also unified method of detecting misbehaviour (using assert_debug_log instead of checking peer's banscore)
2020-04-20Merge #18544: net: limit BIP37 filter lifespan (active between ↵MarcoFalke
'filterload'..'filterclear') a9ecbdfcaa15499644d16e9c8ad2c63dfc45b37b test: add more inactive filter tests to p2p_filter.py (Sebastian Falbesoner) 5eae034996b340c19cebab9efb6c89d20fe051ef net: limit BIP37 filter lifespan (active between 'filterload' and 'filterclear') (Sebastian Falbesoner) Pull request description: This PR fixes https://github.com/bitcoin/bitcoin/issues/18483. On the master branch, there is currently _always_ a BIP37 filter set for every peer: if not a specific filter is set through a `filterload` message, a default match-everything filter is instanciated and pointed to via the `CBloomFilter` default constructor; that happens both initially, when the containing structure `TxRelay` is constructed: https://github.com/bitcoin/bitcoin/blob/c0b389b33516fb3eaaad7c30bd11dba768882a7e/src/net.h#L812 and after a loaded filter is removed again through a `filterclear` message: https://github.com/bitcoin/bitcoin/blob/c0b389b33516fb3eaaad7c30bd11dba768882a7e/src/net_processing.cpp#L3201 The behaviour was introduced by commit https://github.com/bitcoin/bitcoin/commit/37c6389c5a0ca63ae3573440ecdfe95d28ad8f07 (an intentional covert fix for [CVE-2013-5700](https://github.com/bitcoin/bitcoin/pull/18515), according to gmaxwell). This default match-everything filter leads to some unintended side-effects: 1. `getdata` request for filtered blocks (i.e. type `MSG_FILTERED_BLOCK`) are always responded to with `merkleblock`s, even if no filter was set by the peer, see issue #18483 (strictly speaking, this is a violation of BIP37) https://github.com/bitcoin/bitcoin/blob/c0b389b33516fb3eaaad7c30bd11dba768882a7e/src/net_processing.cpp#L1504-L1507 2. if a peer sends a `filteradd` message without having loaded a filter via `filterload` before, the intended increasing of the banscore never happens (triggered if `bad` is set to true, a few lines below) https://github.com/bitcoin/bitcoin/blob/c0b389b33516fb3eaaad7c30bd11dba768882a7e/src/net_processing.cpp#L3182-L3186 This PR basically activates the `else`-branch code paths for all checks of `pfilter` again (on the master branch, they are dead code) by limiting the pointer's lifespan: instead of always having a filter set, the `pfilter` is only pointing to a `CBloomFilter`-instance after receiving a `filterload` message and the instance is destroyed again (and the pointer nullified) after receiving a `filterclear` message. Here is a before/after comparison in behaviour: | code part / scenario | master branch | PR branch | | --------------------------------------------- | ---------------------------------- | ---------------------------------------------------- | | `getdata` processing for `MSG_FILTERED_BLOCK` | always responds with `merkleblock` | only responds if filter was set via `filterload` | | `filteradd` processing, no filter was loaded | nothing | peer's banscore increases by 100 (i.e. disconnect) | On the other code parts where `pfilter` is checked there is no change in the logic behaviour (except that `CBloomFilter::IsRelevantAndUpdate()` is unnecessarily called and immediately returned in the master branch). Note that the default constructor of `CBloomFilter` is only used for deserializing the received `filterload` message and nowhere else. The PR also contains a functional test checking that sending `getdata` for filtered blocks is ignored by the node if no bloom filter is set. ACKs for top commit: MarcoFalke: re-ACK a9ecbdfcaa, only change is in test code 🕙 Tree-SHA512: 1a656a6d74ccaf628e7fdca063ba63fbab2089e0b6d0a11be9bbd387c2ee6d3230706ff8ffc1a55711481df3d4547137dd7c9d9184d89eaa43ade4927792d0b6
2020-04-14test: add more inactive filter tests to p2p_filter.pySebastian Falbesoner
check the following expected behaviors if no filter is set: -> filtered block requests are ignored by the node -> sending a 'filteradd' message is treated as misbehavior (i.e. the peer's banscore increases by 100) also fixes a bug in the on_inv() callback method, which directly modified the type from BLOCK to FILTERED_BLOCK in the received 'inv' message rather than just for the reply Co-authored-by: MarcoFalke <falke.marco@gmail.com>
2020-04-13test: Add various low-level p2p testsMarcoFalke
2020-04-11refactor: test: improve wait_for{header,merkleblock} interfaceSebastian Falbesoner
The interfaces for the methods wait_for_header() and wait_for_merkleblock() are changed to take a hex string instead of an integer, improving type safety and removing the burden from the caller to always do the transformation via `int(...)`. As suggested by MarcoFalke in https://github.com/bitcoin/bitcoin/pull/18593#discussion_r407062253
2020-04-11test: complete impl. of msg_merkleblock and wait_for_merkleblockSebastian Falbesoner
Implements the missing initialization/serialization methods for msg_merkleblock, based on the already present class CMerkleBlock. Also changes the method wait_for_merkleblock() to be more precise by waiting for a merkleblock with a specified blockhash instead of an arbitrary one. In the BIP37 test p2p_filter.py, this new method is used to make the test of receiving merkleblock and tx if a filter is set to be more precise, by checking if they also arrive in the right order.
2020-04-03test: add BIP37 remote crash bug [CVE-2013-5700] test to p2p_filter.pySebastian Falbesoner
2020-04-01test: replace (send_message + sync_with_ping) with send_and_pingJon Atack
2020-03-31test: add BIP37 'filterclear' test to p2p_filter.pySebastian Falbesoner
2020-03-25test: Add basic test for BIP 37MarcoFalke