-
Notifications
You must be signed in to change notification settings - Fork 37.4k
test: Make existing functional tests compatible with --v2transport #28805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Make existing functional tests compatible with --v2transport #28805
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Concept ACK |
I presume this will fix itself, once and if v2 is enabled by default? |
tACK 6b77f9 Read through all updated code, pulled branch, compiled from source, ran:
|
After enabling v2 by default for the functional tests, we'd probably still want to run some or all of the tests with |
Ok, feel free to add it to any task, for example |
Thanks, though I won't add it to this PR. |
Nice! Concept ACK.
@mzumsande, wanted to confirm which scenario you're talking about. i tried it out in this file.
|
I was observing that multiple following tests fail on master with I think the problem is as follows:
Does this make sense? I'll try to come up with a fix for this. |
Before, a global -v2transport provided to the test would be dropped when restarting the node within a test and specifying any extra_args. Fix this by adding "v2transport=1" to args (not extra_args) based on the global parameter, and deciding for each (re)start of the node based on this default and test-specific extra_args (which take precedence over args) whether v2 should be used.
By renaming the "command" send_cli arg. The old name was unsuitable because the "addnode" RPC has its own "command" arg, leading to ambiguity when included in kwargs. Can be tested with "python3 wallet_multiwallet.py --usecli --v2transport" which fails on master because of this (python throws a TypeError).
- "transport_protocol_type" of inbound peer before version handshake is "detecting" on p2p v2 nodes (as opposed to "v1" for p2p v1) - size of a ping/pong message is 29 bytes (as opposed to 32 for p2p v1) - for the sendmsgtopeer RPC sub-test, enforce p2p v1 connection to have a peer id of zero
by skipping the part where we send a non-version message before the version - this message would be interpreted as part of the v2 handshake.
6b77f9f
to
35fb993
Compare
I changed the first commit to save the default behavior (global |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests have in common that they use self.restart_node() with changing some unrelated extra_args, which would then cause --v2transport to be dropped.
thanks for the detailed explanation! so the problem was test failures happening when unrelated extra_args
were passed during TestNode
restart!
i was also initially confused about whether we really need an extra v2transport argument in TestNode::__init()__
but #28805 (comment) makes it clear why we need to extract that information from args
for persisting global v2transport option during restarts. this information would get lost if it's passed on to extra_args
like it's done in master.
@@ -198,6 +204,8 @@ def start(self, extra_args=None, *, cwd=None, stdout=None, stderr=None, env=None | |||
if extra_args is None: | |||
extra_args = self.extra_args | |||
|
|||
self.use_v2transport = "-v2transport=1" in extra_args or (self.default_to_v2 and "-v2transport=0" not in extra_args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
68a9001: there's a behaviour difference when test is run with --v2transport
option and TestNode
(initially "v2transport=0"
) is restarted with:
extra_args
supplied =>TestNode
restarts as v2 nodeextra_args
not supplied =>TestNode
restarts as v1 node
maybe when extra_args
is None
, we could remove "v2transport"
stuff it gets from the old self.extra_args
using something like extra_args = list(filter(lambda s: not s.startswith("-v2transport="), extra_args))
?
EDIT: realised this won't work because during TestNode
initialisation, extra_args
is None
and not just during restarts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small drawback of the current way of inspecting extra_args
for the v2transport option is that it doesn't work if the argument is specified in a slightly different format with same meaning. For example, -v2transport=0
/-v2transport=1
could also be passed as -nov2transport
/-v2transport
, -nov2transport=1
/-nov2transport=0
(admittedly, no sane person would use the last one though). It might be worth it to consider that in a follow-up, e.g. by enforcing with an assertion that arguments that contain the string "v2transport" must be prefixed by "-" and suffixed by either "=0" or "=1". As far as I can see, that's the first time that the test framework needs to inspect bitcoind arguments, so that's a new problem.
@stratospher: I agree that this is a bit counter-intuitive, but it's in line with the current behavior of restart_node
(that apparently many tests rely on), i.e. "if no extra_args are passed, restart with the ones that were initially specified (self.extra_args
)", in your example -v2transport=0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"if no extra_args are passed, restart with the ones that were initially specified (self.extra_args)"
oh interesting! so #28805 (comment) is out of scope for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small drawback of the current way of inspecting
extra_args
for the v2transport option is that it doesn't work if the argument is specified in a slightly different format with same meaning.
Good point - I agree that it makes sense to leave this for a possible follow-up. I'm not sur if we want to port all of the argsmanager logic into python, but having something a bit more general so that it could be reused by other args than just -v2transport
in the future would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 35fb993
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 35fb993.
utACK 35fb993. Thanks for taking care of this. |
ACK 35fb993 |
Before, a global -v2transport provided to the test would be dropped when restarting the node within a test and specifying any extra_args. Fix this by adding "v2transport=1" to args (not extra_args) based on the global parameter, and deciding for each (re)start of the node based on this default and test-specific extra_args (which take precedence over args) whether v2 should be used. Github-Pull: bitcoin#28805 Rebased-From: 68a9001
By renaming the "command" send_cli arg. The old name was unsuitable because the "addnode" RPC has its own "command" arg, leading to ambiguity when included in kwargs. Can be tested with "python3 wallet_multiwallet.py --usecli --v2transport" which fails on master because of this (python throws a TypeError). Github-Pull: bitcoin#28805 Rebased-From: 3598a1b
Github-Pull: bitcoin#28805 Rebased-From: cc961c2
- "transport_protocol_type" of inbound peer before version handshake is "detecting" on p2p v2 nodes (as opposed to "v1" for p2p v1) - size of a ping/pong message is 29 bytes (as opposed to 32 for p2p v1) - for the sendmsgtopeer RPC sub-test, enforce p2p v1 connection to have a peer id of zero Github-Pull: bitcoin#28805 Rebased-From: 2c1669c
by skipping the part where we send a non-version message before the version - this message would be interpreted as part of the v2 handshake. Github-Pull: bitcoin#28805 Rebased-From: 35fb993
…-v2transport Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
…-v2transport Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
…-v2transport Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
…-v2transport Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com>
, bitcoin#28849, bitcoin#28805, bitcoin#28951, bitcoin#29058, bitcoin#29239, partial bitcoin#28331, bitcoin#28452 (BIP324 backports: part 2) 5dd60c4 merge bitcoin#29239: Make v2transport default for addnode RPC when enabled (Kittywhiskers Van Gogh) b2ac426 merge bitcoin#29058: use v2transport for manual/addrfetch connections, add to -netinfo (Kittywhiskers Van Gogh) 92e862a merge bitcoin#28951: damage ciphertext/aad in full byte range (Kittywhiskers Van Gogh) 4e96e26 merge bitcoin#28805: Make existing functional tests compatible with --v2transport (Kittywhiskers Van Gogh) 9371e2e merge bitcoin#28849: fix node index bug when comparing peerinfo (Kittywhiskers Van Gogh) 400c9dd merge bitcoin#28634: add check for missing garbage terminator detection (Kittywhiskers Van Gogh) 65eb194 merge bitcoin#28588: add checks for v1 prefix matching / wrong network magic detection (Kittywhiskers Van Gogh) 6074974 merge bitcoin#28577: raise V1_PREFIX_LEN from 12 to 16 (Kittywhiskers Van Gogh) ff92d1a partial bitcoin#28331: BIP324 integration (Kittywhiskers Van Gogh) f9f8805 fix: drop `CConnman::mapNodesWithDataToSend`, use transport data (UdjinM6) d39d8a4 partial bitcoin#28452: Do not use std::vector = {} to release memory (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * Dependent on #6280 * Dependent on #6276 * Dependency for #6329 * [bitcoin#28452](bitcoin#28452) was backported as the behavior it introduces is required for backports like [bitcoin#28331](bitcoin#28331). As it pre-dates earlier BIP324 backports, the `ClearShrink` usage from those backports have also been incorporated into this backport. * When backporting [bitcoin#28331](bitcoin#28331), in TestFramework's `add_nodes()`, `extra_args[i]` is not converted to a `list` like it is done upstream and avoiding duplication of `-v2transport=1` is instead done by an additional check. This is done to prevent test failures in `feature_mnehf.py`. * The local variable `args` is removed in [bitcoin#28805](bitcoin#28805) as it does nothing (the argument appending logic is removed as part of the backport) and upstream removes it anyways. Special thanks to UdjinM6 for significant contributions to this and dependent PRs! 🎉 ## Breaking Changes None expected. ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)** - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: light ACK 5dd60c4 PastaPastaPasta: utACK 5dd60c4 Tree-SHA512: 7f3d0e54e1c96fc99b2d6b1e64485110aa73aeec0e4e4245ed4e6dc0529a7608e9c39103af636d5945d289775c40d3d15d7d4a75bea82462194dbf355fca48dc
This makes the functional test suite compatible with BIP324, so that
python3 test_runner.py --v2transport
should succeed (currently, 12 tests fail for me on master).
Includes two commits by TheStack I found in an old discussion #28331 (comment)
Note that even though all tests should pass, the python
p2p.py
module will do v2 connections only after the merge of #24748, so that for now only connections between two full nodes will actually run v2.Some of the fixed tests were added with
--v2transport
to the test runner. Though after #24748 we might also want to consider running the entire suite with--v2transport
in some CI.