dash/test/lint/lint-circular-dependencies.sh
Wladimir J. van der Laan f659d98cc6
Merge #16294: qt: test: Create at most one testing setup
faa1e0fb1712b1f94334e42794163f79988270fd qt: test: Create at most one testing setup (MarcoFalke)

Pull request description:

  It is assumed that ideally only one BasicTestingSetup exists at any point in time for each process (due to use of globals).

  This assumption is violated in the GUI tests, as a testing setup is created as the first step of the `main` function and then (sometimes) another one for the following test cases.

  So, the gui tests create two testing setups:
  * `BasicTestingSetup` in `main` (added in fa4a04a5a942d582c62773d815c7e1e9897975d0)
  * a testing setup for individual test cases

  Avoid that by destructing the testing setup in main after creation and then move the explicit `ECC_Stop` to the only places where it is needed (before and after `apptests`).

ACKs for top commit:
  laanwj:
    code review ACK faa1e0fb1712b1f94334e42794163f79988270fd

Tree-SHA512: b8edceb7e2a8749e1de3ea80bc20b6fb7d4390bf366bb9817206ada3dc8669a91416f4803c22a0e6c636c514e0c858dcfe04523221f8851b10deaf472f107d82
2021-12-15 20:09:55 +05:30

151 lines
7.8 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Copyright (c) 2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Check for circular dependencies
export LC_ALL=C
EXPECTED_CIRCULAR_DEPENDENCIES=(
"chainparamsbase -> util/system -> chainparamsbase"
"index/txindex -> validation -> index/txindex"
"policy/fees -> txmempool -> policy/fees"
"policy/policy -> policy/settings -> policy/policy"
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel"
"qt/bantablemodel -> qt/clientmodel -> qt/bantablemodel"
"qt/bitcoingui -> qt/utilitydialog -> qt/bitcoingui"
"qt/bitcoingui -> qt/walletframe -> qt/bitcoingui"
"qt/bitcoingui -> qt/walletview -> qt/bitcoingui"
"qt/clientmodel -> qt/peertablemodel -> qt/clientmodel"
"qt/paymentserver -> qt/walletmodel -> qt/paymentserver"
"qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel"
"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel"
"qt/walletmodel -> qt/walletmodeltransaction -> qt/walletmodel"
"txmempool -> validation -> txmempool"
"validation -> validationinterface -> validation"
"wallet/fees -> wallet/wallet -> wallet/fees"
"wallet/wallet -> wallet/walletdb -> wallet/wallet"
"wallet/coincontrol -> wallet/wallet -> wallet/coincontrol"
"policy/fees -> policy/policy -> validation -> policy/fees"
"policy/policy -> validation -> policy/policy"
"qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/addressbookpage"
"txmempool -> validation -> validationinterface -> txmempool"
"qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/receivecoinsdialog -> qt/addressbookpage"
"qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/signverifymessagedialog -> qt/addressbookpage"
"qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/sendcoinsdialog -> qt/sendcoinsentry -> qt/addressbookpage"
# Dash
"coinjoin/server -> net_processing -> coinjoin/server"
"evo/cbtx -> evo/simplifiedmns -> evo/cbtx"
"evo/cbtx -> evo/specialtx -> evo/cbtx"
"evo/deterministicmns -> evo/providertx -> evo/deterministicmns"
"evo/deterministicmns -> evo/simplifiedmns -> evo/deterministicmns"
"evo/deterministicmns -> evo/specialtx -> evo/deterministicmns"
"evo/deterministicmns -> llmq/commitment -> evo/deterministicmns"
"evo/deterministicmns -> llmq/utils -> evo/deterministicmns"
"evo/deterministicmns -> validation -> evo/deterministicmns"
"evo/mnauth -> net_processing -> evo/mnauth"
"evo/specialtx -> llmq/blockprocessor -> evo/specialtx"
"evo/specialtx -> llmq/commitment -> evo/specialtx"
"evo/specialtx -> validation -> evo/specialtx"
"governance/classes -> governance/governance -> governance/classes"
"governance/classes -> governance/governance -> net_processing -> masternode/payments -> governance/classes"
"governance/governance -> governance/object -> governance/governance"
"governance/governance -> masternode/sync -> governance/governance"
"governance/governance -> net_processing -> governance/governance"
"governance/object -> governance/validators -> governance/object"
"llmq/quorums -> llmq/utils -> llmq/quorums"
"llmq/blockprocessor -> net_processing -> llmq/blockprocessor"
"llmq/chainlocks -> llmq/instantsend -> llmq/chainlocks"
"llmq/chainlocks -> net_processing -> llmq/chainlocks"
"llmq/dkgsessionmgr -> net_processing -> llmq/dkgsessionmgr"
"llmq/instantsend -> net_processing -> llmq/instantsend"
"llmq/instantsend -> txmempool -> llmq/instantsend"
"llmq/instantsend -> validation -> llmq/instantsend"
"llmq/signing -> llmq/signing_shares -> llmq/signing"
"llmq/signing -> net_processing -> llmq/signing"
"llmq/signing_shares -> net_processing -> llmq/signing_shares"
"logging -> util/system -> logging"
"logging -> util/system -> random -> logging"
"masternode/payments -> validation -> masternode/payments"
"net -> netmessagemaker -> net"
"net_processing -> spork -> net_processing"
"netaddress -> netbase -> netaddress"
"qt/appearancewidget -> qt/guiutil -> qt/appearancewidget"
"qt/bitcoinaddressvalidator -> qt/guiutil -> qt/bitcoinaddressvalidator"
"qt/bitcoingui -> qt/guiutil -> qt/bitcoingui"
"qt/guiutil -> qt/optionsdialog -> qt/guiutil"
"qt/guiutil -> qt/qvalidatedlineedit -> qt/guiutil"
"core_io -> evo/cbtx -> evo/deterministicmns -> core_io"
"core_io -> evo/cbtx -> evo/simplifiedmns -> core_io"
"evo/simplifiedmns -> llmq/blockprocessor -> net_processing -> evo/simplifiedmns"
"llmq/dkgsession -> llmq/dkgsessionmgr -> llmq/dkgsessionhandler -> llmq/dkgsession"
"logging -> util/system -> random -> logging"
"logging -> util/system -> sync -> logging"
"logging -> util/system -> stacktraces -> logging"
"coinjoin/client -> coinjoin/util -> wallet/wallet -> coinjoin/client"
"qt/appearancewidget -> qt/guiutil -> qt/optionsdialog -> qt/appearancewidget"
"qt/bitcoinaddressvalidator -> qt/guiutil -> qt/qvalidatedlineedit -> qt/bitcoinaddressvalidator"
"qt/guiutil -> qt/optionsdialog -> qt/optionsmodel -> qt/guiutil"
"bloom -> evo/cbtx -> evo/simplifiedmns -> merkleblock -> bloom"
"bloom -> evo/cbtx -> llmq/blockprocessor -> net -> bloom"
"evo/deterministicmns -> evo/simplifiedmns -> llmq/blockprocessor -> llmq/debug -> evo/deterministicmns"
"evo/deterministicmns -> evo/simplifiedmns -> llmq/blockprocessor -> net_processing -> evo/deterministicmns"
"evo/specialtx -> llmq/blockprocessor -> net_processing -> txmempool -> evo/specialtx"
"evo/providertx -> evo/specialtx -> llmq/blockprocessor -> net_processing -> txmempool -> evo/providertx"
"coinjoin/client -> net_processing -> coinjoin/client"
"llmq/quorums -> net_processing -> llmq/quorums"
"llmq/commitment -> llmq/utils -> llmq/commitment"
"llmq/dkgsession -> llmq/dkgsessionmgr -> llmq/dkgsession"
"evo/deterministicmns -> validationinterface -> txmempool -> evo/deterministicmns"
"llmq/chainlocks -> llmq/instantsend -> validation -> llmq/chainlocks"
"evo/deterministicmns -> evo/simplifiedmns -> llmq/blockprocessor -> net_processing -> masternode/payments -> evo/deterministicmns"
"governance/governance -> net_processing -> masternode/payments -> governance/governance"
"coinjoin/coinjoin -> llmq/chainlocks -> net -> coinjoin/coinjoin"
"evo/deterministicmns -> llmq/utils -> net -> evo/deterministicmns"
"evo/deterministicmns -> llmq/utils -> net -> masternode/sync -> evo/deterministicmns"
"evo/mnhftx -> evo/specialtx -> evo/mnhftx"
)
EXIT_CODE=0
CIRCULAR_DEPENDENCIES=()
IFS=$'\n'
for CIRC in $(cd src && ../contrib/devtools/circular-dependencies.py {*,*/*,*/*/*}.{h,cpp} | sed -e 's/^Circular dependency: //'); do
CIRCULAR_DEPENDENCIES+=( "$CIRC" )
IS_EXPECTED_CIRC=0
for EXPECTED_CIRC in "${EXPECTED_CIRCULAR_DEPENDENCIES[@]}"; do
if [[ "${CIRC}" == "${EXPECTED_CIRC}" ]]; then
IS_EXPECTED_CIRC=1
break
fi
done
if [[ ${IS_EXPECTED_CIRC} == 0 ]]; then
echo "A new circular dependency in the form of \"${CIRC}\" appears to have been introduced."
echo
EXIT_CODE=1
fi
done
for EXPECTED_CIRC in "${EXPECTED_CIRCULAR_DEPENDENCIES[@]}"; do
IS_PRESENT_EXPECTED_CIRC=0
for CIRC in "${CIRCULAR_DEPENDENCIES[@]}"; do
if [[ "${CIRC}" == "${EXPECTED_CIRC}" ]]; then
IS_PRESENT_EXPECTED_CIRC=1
break
fi
done
if [[ ${IS_PRESENT_EXPECTED_CIRC} == 0 ]]; then
echo "Good job! The circular dependency \"${EXPECTED_CIRC}\" is no longer present."
echo "Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in $0"
echo "to make sure this circular dependency is not accidentally reintroduced."
echo
EXIT_CODE=1
fi
done
exit ${EXIT_CODE}