Skip to content

Commit 742edb9

Browse files
committed
Destroy Boost.Test with lazer beams
1 parent 71a1eee commit 742edb9

136 files changed

Lines changed: 8824 additions & 8229 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/addrman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct AddressPosition {
6969
const int bucket;
7070
const int position;
7171

72-
bool operator==(AddressPosition other) {
72+
bool operator==(AddressPosition other) const {
7373
return std::tie(tried, multiplicity, bucket, position) ==
7474
std::tie(other.tried, other.multiplicity, other.bucket, other.position);
7575
}

src/crypto/hmac_sha256.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CHMAC_SHA256
1717
CSHA256 inner;
1818

1919
public:
20-
static const size_t OUTPUT_SIZE = 32;
20+
static constexpr size_t OUTPUT_SIZE = 32;
2121

2222
CHMAC_SHA256(const unsigned char* key, size_t keylen);
2323
CHMAC_SHA256& Write(const unsigned char* data, size_t len)

src/crypto/hmac_sha512.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CHMAC_SHA512
1717
CSHA512 inner;
1818

1919
public:
20-
static const size_t OUTPUT_SIZE = 64;
20+
static constexpr size_t OUTPUT_SIZE = 64;
2121

2222
CHMAC_SHA512(const unsigned char* key, size_t keylen);
2323
CHMAC_SHA512& Write(const unsigned char* data, size_t len)

src/crypto/ripemd160.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CRIPEMD160
1717
uint64_t bytes{0};
1818

1919
public:
20-
static const size_t OUTPUT_SIZE = 20;
20+
static constexpr size_t OUTPUT_SIZE = 20;
2121

2222
CRIPEMD160();
2323
CRIPEMD160& Write(const unsigned char* data, size_t len);

src/crypto/sha1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CSHA1
1717
uint64_t bytes{0};
1818

1919
public:
20-
static const size_t OUTPUT_SIZE = 20;
20+
static constexpr size_t OUTPUT_SIZE = 20;
2121

2222
CSHA1();
2323
CSHA1& Write(const unsigned char* data, size_t len);

src/crypto/sha256.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CSHA256
1818
uint64_t bytes{0};
1919

2020
public:
21-
static const size_t OUTPUT_SIZE = 32;
21+
static constexpr size_t OUTPUT_SIZE = 32;
2222

2323
CSHA256();
2424
CSHA256& Write(const unsigned char* data, size_t len);

src/ipc/libmultiprocess/src/mp/proxy.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <optional>
3131
#include <stdexcept>
3232
#include <string>
33+
#include <csignal>
3334
#include <sys/socket.h>
3435
#include <thread>
3536
#include <tuple>
@@ -203,6 +204,9 @@ EventLoop::EventLoop(const char* exe_name, LogOptions log_opts, void* context)
203204
m_log_opts(std::move(log_opts)),
204205
m_context(context)
205206
{
207+
// Ignore SIGPIPE so writes to a closed pipe/socket return EPIPE instead of
208+
// terminating the process when the remote end disconnects unexpectedly.
209+
std::signal(SIGPIPE, SIG_IGN);
206210
int fds[2];
207211
KJ_SYSCALL(socketpair(AF_UNIX, SOCK_STREAM, 0, fds));
208212
m_wait_fd = fds[0];

src/ipc/test/ipc_test.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,32 @@
2323
#include <kj/test.h>
2424
#include <stdexcept>
2525

26-
#include <boost/test/unit_test.hpp>
26+
#include <test/util/framework.hpp>
2727

2828
static_assert(ipc::capnp::messages::MAX_MONEY == MAX_MONEY);
2929
static_assert(ipc::capnp::messages::MAX_DOUBLE == std::numeric_limits<double>::max());
3030
static_assert(ipc::capnp::messages::DEFAULT_BLOCK_RESERVED_WEIGHT == DEFAULT_BLOCK_RESERVED_WEIGHT);
3131
static_assert(ipc::capnp::messages::DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS == DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS);
3232

3333
//! Remote init class.
34+
namespace {
3435
class TestInit : public interfaces::Init
3536
{
3637
public:
3738
std::atomic<bool> stop_called{false};
3839
std::unique_ptr<interfaces::Echo> makeEcho() override { return interfaces::MakeEcho(); }
3940
void stop() override { stop_called.store(true); }
4041
};
42+
} // namespace
4143

4244
//! Generate a temporary path with temp_directory_path and mkstemp
4345
static std::string TempPath(std::string_view pattern)
4446
{
4547
std::string temp{fs::PathToString(fs::path{fs::temp_directory_path()} / fs::PathFromString(std::string{pattern}))};
4648
temp.push_back('\0');
4749
int fd{mkstemp(temp.data())};
48-
BOOST_CHECK_GE(fd, 0);
49-
BOOST_CHECK_EQUAL(close(fd), 0);
50+
CHECK(fd >= 0);
51+
CHECK(close(fd) == 0);
5052
temp.resize(temp.size() - 1);
5153
fs::remove(fs::PathFromString(temp));
5254
return temp;
@@ -85,17 +87,17 @@ void IpcPipeTest()
8587
std::unique_ptr<mp::ProxyClient<gen::FooInterface>> foo{foo_promise.get_future().get()};
8688

8789
// Test: make sure arguments were sent and return value is received
88-
BOOST_CHECK_EQUAL(foo->add(1, 2), 3);
90+
CHECK(foo->add(1, 2) == 3);
8991

9092
COutPoint txout1{Txid::FromUint256(uint256{100}), 200};
9193
COutPoint txout2{foo->passOutPoint(txout1)};
92-
BOOST_CHECK(txout1 == txout2);
94+
CHECK(txout1 == txout2);
9395

9496
UniValue uni1{UniValue::VOBJ};
9597
uni1.pushKV("i", 1);
9698
uni1.pushKV("s", "two");
9799
UniValue uni2{foo->passUniValue(uni1)};
98-
BOOST_CHECK_EQUAL(uni1.write(), uni2.write());
100+
CHECK(uni1.write() == uni2.write());
99101

100102
CMutableTransaction mtx;
101103
mtx.version = 2;
@@ -104,15 +106,15 @@ void IpcPipeTest()
104106
mtx.vout.emplace_back(COIN, CScript());
105107
CTransactionRef tx1{MakeTransactionRef(mtx)};
106108
CTransactionRef tx2{foo->passTransaction(tx1)};
107-
BOOST_CHECK(*Assert(tx1) == *Assert(tx2));
109+
CHECK(*Assert(tx1) == *Assert(tx2));
108110

109111
std::vector<char> vec1{'H', 'e', 'l', 'l', 'o'};
110112
std::vector<char> vec2{foo->passVectorChar(vec1)};
111-
BOOST_CHECK_EQUAL(std::string_view(vec1.begin(), vec1.end()), std::string_view(vec2.begin(), vec2.end()));
113+
CHECK(std::string_view(vec1.begin(), vec1.end()) == std::string_view(vec2.begin(), vec2.end()));
112114

113115
auto script1{CScript() << OP_11};
114116
auto script2{foo->passScript(script1)};
115-
BOOST_CHECK_EQUAL(HexStr(script1), HexStr(script2));
117+
CHECK(HexStr(script1) == HexStr(script2));
116118

117119
// Test cleanup: disconnect and join thread
118120
foo.reset();
@@ -123,7 +125,7 @@ void IpcPipeTest()
123125
void IpcSocketPairTest()
124126
{
125127
int fds[2];
126-
BOOST_CHECK_EQUAL(socketpair(AF_UNIX, SOCK_STREAM, 0, fds), 0);
128+
CHECK(socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == 0);
127129
std::unique_ptr<interfaces::Init> init{std::make_unique<TestInit>()};
128130
std::unique_ptr<ipc::Protocol> protocol{ipc::capnp::MakeCapnpProtocol()};
129131
std::promise<void> promise;
@@ -133,10 +135,10 @@ void IpcSocketPairTest()
133135
promise.get_future().wait();
134136
std::unique_ptr<interfaces::Init> remote_init{protocol->connect(fds[1], "test-connect")};
135137
std::unique_ptr<interfaces::Echo> remote_echo{remote_init->makeEcho()};
136-
BOOST_CHECK_EQUAL(remote_echo->echo("echo test"), "echo test");
138+
CHECK(remote_echo->echo("echo test") == "echo test");
137139
remote_echo.reset();
138140
remote_init->stop();
139-
BOOST_CHECK(static_cast<TestInit*>(init.get())->stop_called.load());
141+
CHECK(static_cast<TestInit*>(init.get())->stop_called.load());
140142
remote_init.reset();
141143
thread.join();
142144
}
@@ -149,24 +151,24 @@ void IpcSocketTest(const fs::path& datadir)
149151
std::unique_ptr<ipc::Process> process{ipc::MakeProcess()};
150152

151153
std::string invalid_bind{"invalid:"};
152-
BOOST_CHECK_THROW(process->bind(datadir, "test_bitcoin", invalid_bind), std::invalid_argument);
153-
BOOST_CHECK_THROW(process->connect(datadir, "test_bitcoin", invalid_bind), std::invalid_argument);
154+
CHECK_THROWS_AS(process->bind(datadir, "test_bitcoin", invalid_bind), std::invalid_argument);
155+
CHECK_THROWS_AS(process->connect(datadir, "test_bitcoin", invalid_bind), std::invalid_argument);
154156

155157
auto bind_and_listen{[&](const std::string& bind_address) {
156158
std::string address{bind_address};
157159
int serve_fd = process->bind(datadir, "test_bitcoin", address);
158-
BOOST_CHECK_GE(serve_fd, 0);
159-
BOOST_CHECK_EQUAL(address, bind_address);
160+
CHECK(serve_fd >= 0);
161+
CHECK(address == bind_address);
160162
protocol->listen(serve_fd, "test-serve", *init);
161163
}};
162164

163165
auto connect_and_test{[&](const std::string& connect_address) {
164166
std::string address{connect_address};
165167
int connect_fd{process->connect(datadir, "test_bitcoin", address)};
166-
BOOST_CHECK_EQUAL(address, connect_address);
168+
CHECK(address == connect_address);
167169
std::unique_ptr<interfaces::Init> remote_init{protocol->connect(connect_fd, "test-connect")};
168170
std::unique_ptr<interfaces::Echo> remote_echo{remote_init->makeEcho()};
169-
BOOST_CHECK_EQUAL(remote_echo->echo("echo test"), "echo test");
171+
CHECK(remote_echo->echo("echo test") == "echo test");
170172
}};
171173

172174
// Need to specify explicit socket addresses outside the data directory, because the data

src/ipc/test/ipc_tests.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@
77

88
#include <test/util/common.h>
99
#include <test/util/setup_common.h>
10-
#include <boost/test/unit_test.hpp>
10+
#include <test/util/framework.hpp>
1111

12-
BOOST_FIXTURE_TEST_SUITE(ipc_tests, BasicTestingSetup)
13-
BOOST_AUTO_TEST_CASE(ipc_tests)
12+
TEST_SUITE_BEGIN("ipc_tests")
13+
FIXTURE_TEST_CASE("ipc_tests", BasicTestingSetup)
1414
{
1515
IpcPipeTest();
1616
IpcSocketPairTest();
1717
IpcSocketTest(m_args.GetDataDirNet());
1818
}
1919

2020
// Test address parsing.
21-
BOOST_AUTO_TEST_CASE(parse_address_test)
21+
FIXTURE_TEST_CASE("parse_address_test", BasicTestingSetup)
2222
{
2323
std::unique_ptr<ipc::Process> process{ipc::MakeProcess()};
2424
fs::path datadir{"/var/empty/notexist"};
2525
auto check_notexist{[](const std::system_error& e) { return e.code() == std::errc::no_such_file_or_directory; }};
2626
auto check_address{[&](std::string address, std::string expect_address, std::string expect_error) {
2727
if (expect_error.empty()) {
28-
BOOST_CHECK_EXCEPTION(process->connect(datadir, "test_bitcoin", address), std::system_error, check_notexist);
28+
CHECK_EXCEPTION(process->connect(datadir, "test_bitcoin", address), std::system_error, check_notexist);
2929
} else {
30-
BOOST_CHECK_EXCEPTION(process->connect(datadir, "test_bitcoin", address), std::invalid_argument, HasReason(expect_error));
30+
CHECK_EXCEPTION(process->connect(datadir, "test_bitcoin", address), std::invalid_argument, HasReason(expect_error));
3131
}
32-
BOOST_CHECK_EQUAL(address, expect_address);
32+
CHECK(address == expect_address);
3333
}};
3434
check_address("unix", "unix:/var/empty/notexist/test_bitcoin.sock", "");
3535
check_address("unix:", "unix:/var/empty/notexist/test_bitcoin.sock", "");
@@ -40,4 +40,4 @@ BOOST_AUTO_TEST_CASE(parse_address_test)
4040
check_address("invalid", "invalid", "Unrecognized address 'invalid'");
4141
}
4242

43-
BOOST_AUTO_TEST_SUITE_END()
43+
TEST_SUITE_END()

src/support/lockedpool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ class LockedPool
131131
* allocation and deallocation overhead. Setting it too high allocates
132132
* more locked memory from the OS than strictly necessary.
133133
*/
134-
static const size_t ARENA_SIZE = 256*1024;
134+
static constexpr size_t ARENA_SIZE = 256*1024;
135135
/** Chunk alignment. Another compromise. Setting this too high will waste
136136
* memory, setting it too low will facilitate fragmentation.
137137
*/
138-
static const size_t ARENA_ALIGN = 16;
138+
static constexpr size_t ARENA_ALIGN = 16;
139139

140140
/** Callback when allocation succeeds but locking fails.
141141
*/

0 commit comments

Comments
 (0)