Skip to content

Commit c332774

Browse files
committed
test: Fix failing exception check in new thread busy test
New thread busy test from 1238170 (bitcoin-core#214) is checking for "Future already retrieved" error with string match which is fragile and does not work on all platforms, resulting in error: test/mp/test/test.cpp:339: error: failed: expected e.what() == std::string("Future already retrieved") [std::future_error: Future already retrieved == Future already retrieved] This change fixes the test to check for an error code instead. Separately there seems to be a problem with this KJ_EXPECT call because it prints error output without causing the test to fail. This may be happening because it is not called on the main test thread. That issue is not addressed by this change and requires more followup.
1 parent ca3c05d commit c332774

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/mp/test/test.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <capnp/rpc.h>
1111
#include <condition_variable>
1212
#include <cstring>
13-
#include <exception>
1413
#include <functional>
1514
#include <future>
1615
#include <kj/async.h>
@@ -23,14 +22,15 @@
2322
#include <kj/test.h>
2423
#include <memory>
2524
#include <mp/proxy.h>
26-
#include "mp/proxy.capnp.h"
25+
#include <mp/proxy.capnp.h>
2726
#include <mp/proxy-io.h>
28-
#include "mp/util.h"
27+
#include <mp/util.h>
2928
#include <optional>
3029
#include <set>
3130
#include <stdexcept>
3231
#include <string>
3332
#include <string_view>
33+
#include <system_error>
3434
#include <thread>
3535
#include <utility>
3636
#include <vector>
@@ -333,9 +333,9 @@ KJ_TEST("Make simultaneous IPC callbacks with same request_thread and callback_t
333333
{
334334
signal.get_future().get();
335335
}
336-
catch(const std::exception& e)
336+
catch (const std::future_error& e)
337337
{
338-
KJ_EXPECT(e.what() == std::string("Future already retrieved"));
338+
KJ_EXPECT(e.code() == std::make_error_code(std::future_errc::future_already_retrieved));
339339
}
340340
};
341341

0 commit comments

Comments
 (0)