forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
test: add Dash-specific process_message target #7171
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
Closed
thepastaclaw
wants to merge
4
commits into
dashpay:develop
from
thepastaclaw:fuzz/tracker-108-dash-p2p
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4151907
test(fuzz): add Dash-specific process_message target
thepastaclaw 63c6397
fix: add process_message_dash.cpp to non-backported.txt
thepastaclaw 9ce9728
style: apply clang-format to process_message_dash.cpp
thepastaclaw f3905eb
chore(ci): retrigger flaky multiprocess interface_zmq_dash test
thepastaclaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| // Copyright (c) 2026-present The Dash Core developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| #include <consensus/consensus.h> | ||
| #include <net.h> | ||
| #include <protocol.h> | ||
| #include <script/script.h> | ||
| #include <sync.h> | ||
| #include <test/fuzz/FuzzedDataProvider.h> | ||
| #include <test/fuzz/fuzz.h> | ||
| #include <test/fuzz/util.h> | ||
| #include <test/util/mining.h> | ||
| #include <test/util/net.h> | ||
| #include <test/util/setup_common.h> | ||
| #include <test/util/validation.h> | ||
| #include <validationinterface.h> | ||
|
|
||
| #include <array> | ||
| #include <memory> | ||
|
|
||
| namespace { | ||
| const TestingSetup* g_setup; | ||
|
|
||
| const std::array<const char*, 41> DASH_MESSAGE_TYPES{ | ||
| NetMsgType::SPORK, | ||
| NetMsgType::GETSPORKS, | ||
| NetMsgType::DSACCEPT, | ||
| NetMsgType::DSVIN, | ||
| NetMsgType::DSFINALTX, | ||
| NetMsgType::DSSIGNFINALTX, | ||
| NetMsgType::DSCOMPLETE, | ||
| NetMsgType::DSSTATUSUPDATE, | ||
| NetMsgType::DSTX, | ||
| NetMsgType::DSQUEUE, | ||
| NetMsgType::SENDDSQUEUE, | ||
| NetMsgType::SYNCSTATUSCOUNT, | ||
| NetMsgType::MNGOVERNANCESYNC, | ||
| NetMsgType::MNGOVERNANCEOBJECT, | ||
| NetMsgType::MNGOVERNANCEOBJECTVOTE, | ||
| NetMsgType::GETMNLISTDIFF, | ||
| NetMsgType::MNLISTDIFF, | ||
| NetMsgType::QSENDRECSIGS, | ||
| NetMsgType::QFCOMMITMENT, | ||
| NetMsgType::QCONTRIB, | ||
| NetMsgType::QCOMPLAINT, | ||
| NetMsgType::QJUSTIFICATION, | ||
| NetMsgType::QPCOMMITMENT, | ||
| NetMsgType::QWATCH, | ||
| NetMsgType::QSIGSESANN, | ||
| NetMsgType::QSIGSHARESINV, | ||
| NetMsgType::QGETSIGSHARES, | ||
| NetMsgType::QBSIGSHARES, | ||
| NetMsgType::QSIGREC, | ||
| NetMsgType::QSIGSHARE, | ||
| NetMsgType::QGETDATA, | ||
| NetMsgType::QDATA, | ||
| NetMsgType::CLSIG, | ||
| NetMsgType::ISDLOCK, | ||
| NetMsgType::MNAUTH, | ||
| NetMsgType::GETHEADERS2, | ||
| NetMsgType::SENDHEADERS2, | ||
| NetMsgType::HEADERS2, | ||
| NetMsgType::GETQUORUMROTATIONINFO, | ||
| NetMsgType::QUORUMROTATIONINFO, | ||
| NetMsgType::PLATFORMBAN, | ||
| }; | ||
| } // namespace | ||
|
|
||
| void initialize_process_message_dash() | ||
| { | ||
| static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>( | ||
| /*chain_name=*/CBaseChainParams::REGTEST, | ||
| /*extra_args=*/{"-txreconciliation"}); | ||
| g_setup = testing_setup.get(); | ||
| for (int i = 0; i < 2 * COINBASE_MATURITY; i++) { | ||
| MineBlock(g_setup->m_node, CScript() << OP_TRUE); | ||
| } | ||
| SyncWithValidationInterfaceQueue(); | ||
| } | ||
|
|
||
| FUZZ_TARGET(process_message_dash, .init = initialize_process_message_dash) | ||
| { | ||
| FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); | ||
|
|
||
| ConnmanTestMsg& connman = *static_cast<ConnmanTestMsg*>(g_setup->m_node.connman.get()); | ||
| TestChainState& chainstate = *static_cast<TestChainState*>(&g_setup->m_node.chainman->ActiveChainstate()); | ||
| SetMockTime(1610000000); // any time to successfully reset ibd | ||
| chainstate.ResetIbd(); | ||
|
|
||
| LOCK(NetEventsInterface::g_msgproc_mutex); | ||
|
|
||
| CNode& p2p_node = *ConsumeNodeAsUniquePtr(fuzzed_data_provider).release(); | ||
|
|
||
| connman.AddTestNode(p2p_node); | ||
| FillNode(fuzzed_data_provider, connman, p2p_node); | ||
|
|
||
| const auto mock_time = ConsumeTime(fuzzed_data_provider); | ||
| SetMockTime(mock_time); | ||
|
|
||
| CSerializedNetMsg net_msg; | ||
| net_msg.m_type = fuzzed_data_provider.PickValueInArray(DASH_MESSAGE_TYPES); | ||
| net_msg.data = ConsumeRandomLengthByteVector(fuzzed_data_provider, MAX_PROTOCOL_MESSAGE_LENGTH); | ||
|
|
||
| connman.FlushSendBuffer(p2p_node); | ||
| (void)connman.ReceiveMsgFrom(p2p_node, std::move(net_msg)); | ||
|
|
||
| bool more_work{true}; | ||
| LIMITED_WHILE(more_work, 10000) | ||
| { | ||
| p2p_node.fPauseSend = false; | ||
| try { | ||
| more_work = connman.ProcessMessagesOnce(p2p_node); | ||
| } catch (const std::ios_base::failure&) { | ||
| more_work = false; | ||
| } | ||
| g_setup->m_node.peerman->SendMessages(&p2p_node); | ||
| } | ||
| SyncWithValidationInterfaceQueue(); | ||
| g_setup->m_node.connman->StopNodes(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.