Commit 0c23fd76 authored by Dominik Charousset's avatar Dominik Charousset

Fix wait conditions in BASP unit test, closes #362

parent 6fc2cbf9
...@@ -531,15 +531,18 @@ CAF_TEST(publish_and_connect) { ...@@ -531,15 +531,18 @@ CAF_TEST(publish_and_connect) {
} }
CAF_TEST(remote_actor_and_send) { CAF_TEST(remote_actor_and_send) {
constexpr const char* lo = "localhost";
CAF_MESSAGE("self: " << to_string(self()->address())); CAF_MESSAGE("self: " << to_string(self()->address()));
mpx()->provide_scribe("localhost", 4242, remote_hdl(0)); mpx()->provide_scribe(lo, 4242, remote_hdl(0));
CAF_CHECK(mpx()->pending_scribes().count(make_pair("localhost", 4242)) == 1); CAF_REQUIRE(mpx()->pending_scribes().count(make_pair(lo, 4242)) == 1);
auto mm1 = get_middleman_actor(); auto mm1 = get_middleman_actor();
actor result; actor result;
auto f = self()->sync_send(mm1, connect_atom::value, auto f = self()->sync_send(mm1, connect_atom::value,
"localhost", uint16_t{4242}); lo, uint16_t{4242});
mpx()->exec_runnable(); // process message in basp_broker // wait until BASP broker has received and processed the connect message
CAF_CHECK(mpx()->pending_scribes().count(make_pair("localhost", 4242)) == 0); while (! aut()->valid(remote_hdl(0)))
mpx()->exec_runnable();
CAF_REQUIRE(mpx()->pending_scribes().count(make_pair(lo, 4242)) == 0);
// build a fake server handshake containing the id of our first pseudo actor // build a fake server handshake containing the id of our first pseudo actor
CAF_MESSAGE("server handshake => client handshake + proxy announcement"); CAF_MESSAGE("server handshake => client handshake + proxy announcement");
auto na = registry()->named_actors(); auto na = registry()->named_actors();
...@@ -637,8 +640,9 @@ CAF_TEST(actor_serialize_and_deserialize) { ...@@ -637,8 +640,9 @@ CAF_TEST(actor_serialize_and_deserialize) {
prx->id(), testee->id()}, prx->id(), testee->id()},
msg); msg);
// testee must've responded (process forwarded message in BASP broker) // testee must've responded (process forwarded message in BASP broker)
CAF_MESSAGE("exec runnable, i.e., handle response from testee"); CAF_MESSAGE("wait until BASP broker writes to its output buffer");
mpx()->exec_runnable(); // process forwarded message in basp_broker while (mpx()->output_buffer(remote_hdl(0)).empty())
mpx()->exec_runnable(); // process forwarded message in basp_broker
// output buffer must contain the reflected message // output buffer must contain the reflected message
mock() mock()
.expect(remote_hdl(0), .expect(remote_hdl(0),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment