2323#include < kj/test.h>
2424#include < stdexcept>
2525
26- #include < boost/ test/unit_test .hpp>
26+ #include < test/util/framework .hpp>
2727
2828static_assert (ipc::capnp::messages::MAX_MONEY == MAX_MONEY );
2929static_assert (ipc::capnp::messages::MAX_DOUBLE == std::numeric_limits<double >::max());
3030static_assert (ipc::capnp::messages::DEFAULT_BLOCK_RESERVED_WEIGHT == DEFAULT_BLOCK_RESERVED_WEIGHT );
3131static_assert (ipc::capnp::messages::DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS == DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS );
3232
3333// ! Remote init class.
34+ namespace {
3435class TestInit : public interfaces ::Init
3536{
3637public:
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
4345static 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()
123125void 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
0 commit comments