-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: Remove duplicate NodeContext hacks #19098
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
Conversation
src/qt/test/apptests.cpp
Outdated
@@ -63,6 +64,7 @@ void AppTests::appTests() | |||
#endif | |||
|
|||
BasicTestingSetup test{CBaseChainParams::REGTEST}; // Create a temp data directory to backup the gui settings to |
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.
Duplicate testing setups are illegal anyway. Have you seen fa5f7fa which is a massively smaller diff, potentially fixing the issue you ran into.
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.
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.
re: #19098 (comment)
Duplicate testing setups are illegal anyway. Have you seen fa5f7fa which is a massively smaller diff, potentially fixing the issue you ran into.
Acked other PR, and this PR overlaps a little bit with another part of it, but this PR is solving a different problem: not duplicate test setups but duplicate NodeContext (and WalletContext) instances inside a single test setup and confusion and fragility created by this. I added more motivation to PR description above.
Also, the diff isn't very big here, it's mostly just replacing .
with ->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. 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. |
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.
Updated 09569ff -> 8569817 (pr/qtx.1
-> pr/qtx.2
, compare) with fix for address book asan error https://travis-ci.org/github/bitcoin/bitcoin/jobs/692330030#L4304
Updated 8569817 -> 934a8ae (pr/qtx.2
-> pr/qtx.3
, compare) fixing pedantic asan null reference error https://travis-ci.org/github/bitcoin/bitcoin/jobs/692528901#L4294
Rebased 934a8ae -> d2c9cd7 (pr/qtx.3
-> pr/qtx.4
, compare) due to conflict with #19176
Rebased d2c9cd7 -> ab1736c (pr/qtx.4
-> pr/qtx.5
, compare) due to conflict with #19310
src/qt/test/apptests.cpp
Outdated
@@ -63,6 +64,7 @@ void AppTests::appTests() | |||
#endif | |||
|
|||
BasicTestingSetup test{CBaseChainParams::REGTEST}; // Create a temp data directory to backup the gui settings to |
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.
re: #19098 (comment)
Duplicate testing setups are illegal anyway. Have you seen fa5f7fa which is a massively smaller diff, potentially fixing the issue you ran into.
Acked other PR, and this PR overlaps a little bit with another part of it, but this PR is solving a different problem: not duplicate test setups but duplicate NodeContext (and WalletContext) instances inside a single test setup and confusion and fragility created by this. I added more motivation to PR description above.
Also, the diff isn't very big here, it's mostly just replacing .
with ->
good approach, I tried this (dont wanna break whole top node interface): test.m_node.chain = interfaces::MakeChain(test.m_node); btw: walletlocation is empty, but the wallettest run thru, even if u use QApplication app(argc, argv) & comment all other tests out. |
re: tarboss #19098 (comment)
It sounds like you tried this and got expected result, but let me know if I'm misunderstanding. Thanks for the feedback |
fa522f9
to
12135dd
Compare
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.
Qt tests currently are currently using two NodeContext structs at the same time, one in interfaces::NodeImpl::m_context, and the other in BasicTestingSetup::m_node, and the tests have hacks transferring state between them. Fix this by getting rid of the NodeImpl::m_context struct and making it a pointer. This way a common BitcoinApplication object can be used for all qt tests, but they can still have their own testing setups. Non-test code is changing but non-test behavior is still the same as before. Motivation for this PR is to be able to remove the "std::move(test.m_node.connman)" and mempool hacks for swapping individual NodeContext members in Qt tests, because followup PR bitcoin#19099 adds yet another member (wallet_client) that needs to be swapped. After this change, the whole NodeContext struct can be swapped instead of individual members, so the workarounds are less fragile and invasive.
src/test/util/setup_common.cpp
Outdated
@@ -10,6 +10,7 @@ | |||
#include <consensus/params.h> | |||
#include <consensus/validation.h> | |||
#include <crypto/sha256.h> | |||
#include <interfaces/chain.h> |
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.
nit, sort 🙊 🏃
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.
src/qt/bitcoin.h
Outdated
@@ -90,6 +90,8 @@ class BitcoinApplication: public QApplication | |||
/// Setup platform style | |||
void setupPlatformStyle(); | |||
|
|||
interfaces::Node& node() { return m_node; } |
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.
Add only when needed?
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.
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.
src/qt/bitcoin.h
Outdated
@@ -90,6 +90,8 @@ class BitcoinApplication: public QApplication | |||
/// Setup platform style | |||
void setupPlatformStyle(); | |||
|
|||
interfaces::Node& node() { return m_node; } |
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.
src/test/util/setup_common.cpp
Outdated
@@ -10,6 +10,7 @@ | |||
#include <consensus/params.h> | |||
#include <consensus/validation.h> | |||
#include <crypto/sha256.h> | |||
#include <interfaces/chain.h> |
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.
crACK edc3160 🌮 Show signature and timestampSignature:
Timestamp of file with hash |
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 edc3160.
edc3160 test: Remove duplicate NodeContext hacks (Russell Yanofsky) Pull request description: Qt tests currently are currently using two NodeContext structs at the same time, one in interfaces::NodeImpl::m_context, and the other in BasicTestingSetup::m_node, and the tests have hacks transferring state between them. Fix this by getting rid of the NodeImpl::m_context struct and making it a pointer. This way a common BitcoinApplication object can be used for all qt tests, but they can still have their own testing setups. Non-test code is changing but non-test behavior is still the same as before. Motivation for this PR is to be able to remove the "std::move(test.m_node.connman)" and mempool hacks for swapping individual NodeContext members in Qt tests, because followup PR bitcoin#19099 adds yet another member (wallet_client) that needs to be swapped. After this change, the whole NodeContext struct can be swapped instead of individual members, so the workarounds are less fragile and invasive. ACKs for top commit: MarcoFalke: crACK edc3160 🌮 promag: ACK edc3160. Tree-SHA512: c1650e4127f43a4020304ca7c13b5d9122fb5723aacd8fa1cf855d03c6052fcfb7685810aa2a5ef708561015f0022fecaacbad479295104ca45d2c17579466a4
Summary: ``` Qt tests currently are currently using two NodeContext structs at the same time, one in interfaces::NodeImpl::m_context, and the other in BasicTestingSetup::m_node, and the tests have hacks transferring state between them. Fix this by getting rid of the NodeImpl::m_context struct and making it a pointer. This way a common BitcoinApplication object can be used for all qt tests, but they can still have their own testing setups. Non-test code is changing but non-test behavior is still the same as before. Motivation for this PR is to be able to remove the "std::move(test.m_node.connman)" and mempool hacks for swapping individual NodeContext members in Qt tests, because followup PR #19099 adds yet another member (wallet_client) that needs to be swapped. After this change, the whole NodeContext struct can be swapped instead of individual members, so the workarounds are less fragile and invasive. ``` Backport of core [[bitcoin/bitcoin#19098 | PR19098]]. Depends on D7992. Test Plan: ninja all check-all ./contrib/teamcity/build-configurations.py build-ubsan Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Subscribers: deadalnix Differential Revision: https://reviews.bitcoinabc.org/D7993
These calls are no longer needed after edc3160 from bitcoin#19098 which started instantiating BasicTestingSetup.m_node.chain Patch from MarcoFalke <falke.marco@gmail.com> in bitcoin#19425 (comment) Co-authored-by: MarcoFalke <falke.marco@gmail.com>
Qt tests currently are currently using two NodeContext structs at the same time, one in interfaces::NodeImpl::m_context, and the other in BasicTestingSetup::m_node, and the tests have hacks transferring state between them.
Fix this by getting rid of the NodeImpl::m_context struct and making it a pointer. This way a common BitcoinApplication object can be used for all qt tests, but they can still have their own testing setups.
Non-test code is changing but non-test behavior is still the same as before.
Motivation for this PR is to be able to remove the "std::move(test.m_node.connman)" and mempool hacks for swapping individual NodeContext members in Qt tests, because followup PR #19099 adds yet another member (wallet_client) that needs to be swapped. After this change, the whole NodeContext struct can be swapped instead of individual members, so the workarounds are less fragile and invasive.