Skip to content
Merged
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
19 changes: 5 additions & 14 deletions src/arith_uint256.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,8 @@ class base_uint
pn[i] = 0;
}

base_uint(const base_uint& b)
{
for (int i = 0; i < WIDTH; i++)
pn[i] = b.pn[i];
}

base_uint& operator=(const base_uint& b)
{
if (this != &b) {
for (int i = 0; i < WIDTH; i++)
pn[i] = b.pn[i];
}
return *this;
}
base_uint(const base_uint& b) = default;
base_uint& operator=(const base_uint& b) = default;

base_uint(uint64_t b)
{
Expand Down Expand Up @@ -272,6 +260,9 @@ class arith_uint256 : public base_uint<256> {
friend arith_uint256 UintToArith256(const uint256 &);
};

// Keeping the trivially copyable property is beneficial for performance
static_assert(std::is_trivially_copyable_v<arith_uint256>);

uint256 ArithToUint256(const arith_uint256 &);
arith_uint256 UintToArith256(const uint256 &);

Expand Down
2 changes: 1 addition & 1 deletion src/bitcoin-chainstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main(int argc, char* argv[])
class KernelNotifications : public kernel::Notifications
{
public:
kernel::InterruptResult blockTip(SynchronizationState, CBlockIndex&, double) override
kernel::InterruptResult blockTip(SynchronizationState, const CBlockIndex&, double) override
{
std::cout << "Block tip changed" << std::endl;
return {};
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/notifications_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Notifications
public:
virtual ~Notifications() = default;

[[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, CBlockIndex& index, double verification_progress) { return {}; }
[[nodiscard]] virtual InterruptResult blockTip(SynchronizationState state, const CBlockIndex& index, double verification_progress) { return {}; }
virtual void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) {}
virtual void progress(const bilingual_str& title, int progress_percent, bool resume_possible) {}
virtual void warningSet(Warning id, const bilingual_str& message) {}
Expand Down
2 changes: 1 addition & 1 deletion src/node/kernel_notifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static void AlertNotify(const std::string& strMessage)

namespace node {

kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state, CBlockIndex& index, double verification_progress)
kernel::InterruptResult KernelNotifications::blockTip(SynchronizationState state, const CBlockIndex& index, double verification_progress)
{
{
LOCK(m_tip_block_mutex);
Expand Down
2 changes: 1 addition & 1 deletion src/node/kernel_notifications.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class KernelNotifications : public kernel::Notifications
KernelNotifications(const std::function<bool()>& shutdown_request, std::atomic<int>& exit_status, node::Warnings& warnings)
: m_shutdown_request(shutdown_request), m_exit_status{exit_status}, m_warnings{warnings} {}

[[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, CBlockIndex& index, double verification_progress) override EXCLUSIVE_LOCKS_REQUIRED(!m_tip_block_mutex);
[[nodiscard]] kernel::InterruptResult blockTip(SynchronizationState state, const CBlockIndex& index, double verification_progress) override EXCLUSIVE_LOCKS_REQUIRED(!m_tip_block_mutex);

void headerTip(SynchronizationState state, int64_t height, int64_t timestamp, bool presync) override;

Expand Down
79 changes: 46 additions & 33 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import argparse
from collections import deque
from concurrent import futures
import configparser
import csv
import datetime
Expand Down Expand Up @@ -706,15 +707,15 @@ class TestHandler:
"""
Trigger the test scripts passed in via the list.
"""

def __init__(self, *, num_tests_parallel, tests_dir, tmpdir, test_list, flags, use_term_control):
assert num_tests_parallel >= 1
self.executor = futures.ThreadPoolExecutor(max_workers=num_tests_parallel)
self.num_jobs = num_tests_parallel
self.tests_dir = tests_dir
self.tmpdir = tmpdir
self.test_list = test_list
self.flags = flags
self.jobs = []
self.jobs = {}
self.use_term_control = use_term_control

def done(self):
Expand All @@ -731,47 +732,59 @@ def get_next(self):
test_argv = test.split()
testdir = "{}/{}_{}".format(self.tmpdir, re.sub(".py$", "", test_argv[0]), portseed)
tmpdir_arg = ["--tmpdir={}".format(testdir)]
self.jobs.append((test,
time.time(),
subprocess.Popen([sys.executable, self.tests_dir + test_argv[0]] + test_argv[1:] + self.flags + portseed_arg + tmpdir_arg,
text=True,
stdout=log_stdout,
stderr=log_stderr),
testdir,
log_stdout,
log_stderr))

def proc_wait(task):
task[2].wait()
return task

task = [
test,
time.time(),
subprocess.Popen(
[sys.executable, self.tests_dir + test_argv[0]] + test_argv[1:] + self.flags + portseed_arg + tmpdir_arg,
text=True,
stdout=log_stdout,
stderr=log_stderr,
),
testdir,
log_stdout,
log_stderr,
]
fut = self.executor.submit(proc_wait, task)
self.jobs[fut] = test
if not self.jobs:
raise IndexError('pop from empty list')

# Print remaining running jobs when all jobs have been started.
if not self.test_list:
print("Remaining jobs: [{}]".format(", ".join(j[0] for j in self.jobs)))
print("Remaining jobs: [{}]".format(", ".join(sorted(self.jobs.values()))))

dot_count = 0
while True:
# Return all procs that have finished, if any. Otherwise sleep until there is one.
time.sleep(.5)
procs = futures.wait(self.jobs.keys(), timeout=.5, return_when=futures.FIRST_COMPLETED)
self.jobs = {fut: self.jobs[fut] for fut in procs.not_done}
ret = []
for job in self.jobs:
(name, start_time, proc, testdir, log_out, log_err) = job
if proc.poll() is not None:
log_out.seek(0), log_err.seek(0)
[stdout, stderr] = [log_file.read().decode('utf-8') for log_file in (log_out, log_err)]
log_out.close(), log_err.close()
skip_reason = None
if proc.returncode == TEST_EXIT_PASSED and stderr == "":
status = "Passed"
elif proc.returncode == TEST_EXIT_SKIPPED:
status = "Skipped"
skip_reason = re.search(r"Test Skipped: (.*)", stdout).group(1)
else:
status = "Failed"
self.jobs.remove(job)
if self.use_term_control:
clearline = '\r' + (' ' * dot_count) + '\r'
print(clearline, end='', flush=True)
dot_count = 0
ret.append((TestResult(name, status, int(time.time() - start_time)), testdir, stdout, stderr, skip_reason))
for job in procs.done:
(name, start_time, proc, testdir, log_out, log_err) = job.result()

log_out.seek(0), log_err.seek(0)
[stdout, stderr] = [log_file.read().decode('utf-8') for log_file in (log_out, log_err)]
log_out.close(), log_err.close()
skip_reason = None
if proc.returncode == TEST_EXIT_PASSED and stderr == "":
status = "Passed"
elif proc.returncode == TEST_EXIT_SKIPPED:
status = "Skipped"
skip_reason = re.search(r"Test Skipped: (.*)", stdout).group(1)
else:
status = "Failed"

if self.use_term_control:
clearline = '\r' + (' ' * dot_count) + '\r'
print(clearline, end='', flush=True)
dot_count = 0
ret.append((TestResult(name, status, int(time.time() - start_time)), testdir, stdout, stderr, skip_reason))
if ret:
return ret
if self.use_term_control:
Expand Down