Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void BitcoinGUI::createActions()
connect(usedSendingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedSendingAddresses);
connect(usedReceivingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedReceivingAddresses);
connect(openAction, &QAction::triggered, this, &BitcoinGUI::openClicked);
connect(m_open_wallet_menu, &QMenu::aboutToShow, [this] {
connect(m_open_wallet_menu, &QMenu::aboutToShow, m_wallet_controller, [this] {
m_open_wallet_menu->clear();
for (const std::pair<const std::string, bool>& i : m_wallet_controller->listWalletDir()) {
const std::string& path = i.first;
Expand All @@ -533,7 +533,7 @@ void BitcoinGUI::createActions()
continue;
}

connect(action, &QAction::triggered, [this, path] {
connect(action, &QAction::triggered, m_wallet_controller, [this, path] {
auto activity = new OpenWalletActivity(m_wallet_controller, this);
connect(activity, &OpenWalletActivity::opened, this, &BitcoinGUI::setCurrentWallet, Qt::QueuedConnection);
connect(activity, &OpenWalletActivity::opened, rpcConsole, &RPCConsole::setCurrentWallet, Qt::QueuedConnection);
Expand All @@ -545,7 +545,7 @@ void BitcoinGUI::createActions()
action->setEnabled(false);
}
});
connect(m_restore_wallet_action, &QAction::triggered, [this] {
connect(m_restore_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
//: Name of the wallet data file format.
QString name_data_file = tr("Wallet Data");

Expand All @@ -571,16 +571,16 @@ void BitcoinGUI::createActions()
auto backup_file_path = fs::PathFromString(backup_file.toStdString());
activity->restore(backup_file_path, wallet_name.toStdString());
});
connect(m_close_wallet_action, &QAction::triggered, [this] {
connect(m_close_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
m_wallet_controller->closeWallet(walletFrame->currentWalletModel(), this);
});
connect(m_create_wallet_action, &QAction::triggered, [this] {
connect(m_create_wallet_action, &QAction::triggered, m_wallet_controller, [this] {
auto activity = new CreateWalletActivity(m_wallet_controller, this);
connect(activity, &CreateWalletActivity::created, this, &BitcoinGUI::setCurrentWallet);
connect(activity, &CreateWalletActivity::created, rpcConsole, &RPCConsole::setCurrentWallet);
activity->create();
});
connect(m_close_all_wallets_action, &QAction::triggered, [this] {
connect(m_close_all_wallets_action, &QAction::triggered, m_wallet_controller, [this] {
m_wallet_controller->closeAllWallets(this);
});

Expand Down Expand Up @@ -892,7 +892,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH

m_mask_values_action->setChecked(_clientModel->getOptionsModel()->getOption(OptionsModel::OptionID::MaskValues).toBool());
} else {
if(trayIconMenu)
// Shutdown requested, disable menus
if (trayIconMenu)
{
// Disable context menu on tray icon
trayIconMenu->clear();
Expand All @@ -906,6 +907,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
}
#endif // ENABLE_WALLET
unitDisplayControl->setOptionsModel(nullptr);
// Disable top bar menu actions
appMenuBar->clear();

#ifdef Q_OS_MACOS
if(dockIconMenu)
Expand Down
11 changes: 5 additions & 6 deletions test/functional/interface_usdt_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,24 @@ def __repr__(self):
checked_outbound_version_msg = 0
events = []

def check_p2p_message(event, inbound):
def check_p2p_message(event, is_inbound):
nonlocal checked_inbound_version_msg, checked_outbound_version_msg
if event.msg_type.decode("utf-8") == "version":
self.log.info(
f"check_p2p_message(): {'inbound' if inbound else 'outbound'} {event}")
f"check_p2p_message(): {'inbound' if is_inbound else 'outbound'} {event}")
peer = self.nodes[0].getpeerinfo()[0]
msg = msg_version()
msg.deserialize(BytesIO(bytes(event.msg[:event.msg_size])))
assert_equal(peer["id"], event.peer_id, peer["id"])
assert_equal(peer["addr"], event.peer_addr.decode("utf-8"))
assert_equal(peer["connection_type"],
event.peer_conn_type.decode("utf-8"))
if inbound:
if is_inbound:
checked_inbound_version_msg += 1
else:
checked_outbound_version_msg += 1

def handle_inbound(_, data, __):
nonlocal events
event = ctypes.cast(data, ctypes.POINTER(P2PMessage)).contents
events.append((event, True))

Expand All @@ -157,8 +156,8 @@ def handle_outbound(_, data, __):

self.log.info(
"check receipt and content of in- and outbound version messages")
for event, inbound in events:
check_p2p_message(event, inbound)
for event, is_inbound in events:
check_p2p_message(event, is_inbound)
assert_equal(EXPECTED_INOUTBOUND_VERSION_MSG,
checked_inbound_version_msg)
assert_equal(EXPECTED_INOUTBOUND_VERSION_MSG,
Expand Down
68 changes: 29 additions & 39 deletions test/functional/interface_usdt_utxocache.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,43 +254,30 @@ def test_add_spent(self):
# that the handle_* functions succeeded.
EXPECTED_HANDLE_ADD_SUCCESS = 2
EXPECTED_HANDLE_SPENT_SUCCESS = 1
handle_add_succeeds = 0
handle_spent_succeeds = 0

expected_utxocache_spents = []
expected_utxocache_adds = []
expected_utxocache_spents = []

actual_utxocache_adds = []
actual_utxocache_spents = []

def compare_utxo_with_event(utxo, event):
"""Compare a utxo dict to the event produced by BPF"""
assert_equal(utxo["txid"], bytes(event.txid[::-1]).hex())
assert_equal(utxo["index"], event.index)
assert_equal(utxo["height"], event.height)
assert_equal(utxo["value"], event.value)
assert_equal(utxo["is_coinbase"], event.is_coinbase)

def handle_utxocache_add(_, data, __):
nonlocal handle_add_succeeds
event = ctypes.cast(data, ctypes.POINTER(UTXOCacheChange)).contents
self.log.info(f"handle_utxocache_add(): {event}")
add = expected_utxocache_adds.pop(0)
try:
assert_equal(add["txid"], bytes(event.txid[::-1]).hex())
assert_equal(add["index"], event.index)
assert_equal(add["height"], event.height)
assert_equal(add["value"], event.value)
assert_equal(add["is_coinbase"], event.is_coinbase)
except AssertionError:
self.log.exception("Assertion failed")
else:
handle_add_succeeds += 1
actual_utxocache_adds.append(event)

def handle_utxocache_spent(_, data, __):
nonlocal handle_spent_succeeds
event = ctypes.cast(data, ctypes.POINTER(UTXOCacheChange)).contents
self.log.info(f"handle_utxocache_spent(): {event}")
spent = expected_utxocache_spents.pop(0)
try:
assert_equal(spent["txid"], bytes(event.txid[::-1]).hex())
assert_equal(spent["index"], event.index)
assert_equal(spent["height"], event.height)
assert_equal(spent["value"], event.value)
assert_equal(spent["is_coinbase"], event.is_coinbase)
except AssertionError:
self.log.exception("Assertion failed")
else:
handle_spent_succeeds += 1
actual_utxocache_spents.append(event)

bpf["utxocache_add"].open_perf_buffer(handle_utxocache_add)
bpf["utxocache_spent"].open_perf_buffer(handle_utxocache_spent)
Expand Down Expand Up @@ -326,19 +313,18 @@ def handle_utxocache_spent(_, data, __):
"is_coinbase": block_index == 0,
})

assert_equal(EXPECTED_HANDLE_ADD_SUCCESS, len(expected_utxocache_adds))
assert_equal(EXPECTED_HANDLE_SPENT_SUCCESS,
len(expected_utxocache_spents))

bpf.perf_buffer_poll(timeout=200)
bpf.cleanup()

assert_equal(EXPECTED_HANDLE_ADD_SUCCESS, len(expected_utxocache_adds), len(actual_utxocache_adds))
assert_equal(EXPECTED_HANDLE_SPENT_SUCCESS, len(expected_utxocache_spents), len(actual_utxocache_spents))

self.log.info(
f"check that we successfully traced {EXPECTED_HANDLE_ADD_SUCCESS} adds and {EXPECTED_HANDLE_SPENT_SUCCESS} spent")
assert_equal(0, len(expected_utxocache_adds))
assert_equal(0, len(expected_utxocache_spents))
assert_equal(EXPECTED_HANDLE_ADD_SUCCESS, handle_add_succeeds)
assert_equal(EXPECTED_HANDLE_SPENT_SUCCESS, handle_spent_succeeds)
for expected_utxo, actual_event in zip(expected_utxocache_adds + expected_utxocache_spents,
actual_utxocache_adds + actual_utxocache_spents):
compare_utxo_with_event(expected_utxo, actual_event)

bpf.cleanup()

def test_flush(self):
""" Tests the utxocache:flush tracepoint API.
Expand Down Expand Up @@ -368,9 +354,13 @@ def handle_utxocache_flush(_, data, __):
assert_equal(expected["mode"], FLUSHMODE_NAME[event.mode])
possible_cache_sizes.remove(event.size) # fails if size not in set
# sanity checks only
assert(event.memory > 0)
assert(event.duration > 0)
handle_flush_succeeds += 1
try:
assert event.memory > 0
assert event.duration > 0
except AssertionError:
self.log.exception("Assertion error")
else:
handle_flush_succeeds += 1

bpf["utxocache_flush"].open_perf_buffer(handle_utxocache_flush)

Expand Down
5 changes: 1 addition & 4 deletions test/functional/interface_usdt_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def __repr__(self):
self.duration)

BLOCKS_EXPECTED = 2
blocks_checked = 0
expected_blocks = dict()
events = []

Expand All @@ -98,7 +97,6 @@ def __repr__(self):
usdt_contexts=[ctx], debug=0, cflags=["-Wno-error=implicit-function-declaration"])

def handle_blockconnected(_, data, __):
nonlocal events, blocks_checked
event = ctypes.cast(data, ctypes.POINTER(Block)).contents
self.log.info(f"handle_blockconnected(): {event}")
block_hash = bytes(event.hash[::-1]).hex()
Expand All @@ -111,7 +109,6 @@ def handle_blockconnected(_, data, __):
# only plausibility checks
assert(event.duration > 0)
del expected_blocks[block_hash]
blocks_checked += 1

bpf["block_connected"].open_perf_buffer(
handle_blockconnected)
Expand All @@ -136,7 +133,7 @@ def handle_blockconnected(_, data, __):
# only plausibility checks
assert event.duration > 0
del expected_blocks[block_hash]
assert_equal(BLOCKS_EXPECTED, blocks_checked)
assert_equal(BLOCKS_EXPECTED, len(events))
assert_equal(0, len(expected_blocks))

bpf.cleanup()
Expand Down
8 changes: 6 additions & 2 deletions test/fuzz/test_runner.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright (c) 2019-2020 The Bitcoin Core developers
# Copyright (c) 2019-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Run fuzz test targets.
Expand Down Expand Up @@ -249,7 +249,11 @@ def merge_inputs(*, fuzz_pool, corpus, test_list, src_dir, fuzz_bin, merge_dir):
# [0] https://github.com/bitcoin-core/qa-assets/issues/130#issuecomment-1761760866
'-shuffle=0',
'-prefer_small=1',
'-use_value_profile=1', # Also done by oss-fuzz https://github.com/google/oss-fuzz/issues/1406#issuecomment-387790487
'-use_value_profile=0',
# use_value_profile is enabled by oss-fuzz [0], but disabled for
# now to avoid bloating the qa-assets git repository [1].
# [0] https://github.com/google/oss-fuzz/issues/1406#issuecomment-387790487
# [1] https://github.com/bitcoin-core/qa-assets/issues/130#issuecomment-1749075891
os.path.join(corpus, t),
os.path.join(merge_dir, t),
]
Expand Down
5 changes: 4 additions & 1 deletion test/lint/lint-python.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
"""

import os
from pathlib import Path
import subprocess
import sys

from importlib.metadata import metadata, PackageNotFoundError

# Customize mypy cache dir via environment variable
cache_dir = Path(__file__).parent.parent / ".mypy_cache"
os.environ["MYPY_CACHE_DIR"] = str(cache_dir)

DEPS = ['flake8', 'lief', 'mypy', 'pyzmq']
MYPY_CACHE_DIR = f"{os.getenv('BASE_ROOT_DIR', '')}/test/.mypy_cache"
FILES_ARGS = ['git', 'ls-files', '--','test/functional/*.py', 'contrib/devtools/*.py', ':(exclude)contrib/devtools/github-merge.py']
EXCLUDE_DIRS = ['src/dashbls/',
'src/immer/']
Expand Down
Loading