Skip to content

Commit 3435ae2

Browse files
committed
Test getting a Response while Delayed
1 parent 2664fc4 commit 3435ae2

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

source/geod24/LocalRest.d

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,3 +1377,42 @@ unittest
13771377
node_tid = node_2.tid;
13781378
node_1.check();
13791379
}
1380+
1381+
// Test a node that gets a replay while it's delayed
1382+
unittest
1383+
{
1384+
static import std.concurrency;
1385+
import std.exception;
1386+
1387+
__gshared C.Tid node_tid;
1388+
1389+
static interface API
1390+
{
1391+
void check ();
1392+
int ping ();
1393+
}
1394+
1395+
static class Node : API
1396+
{
1397+
override int ping () { return 42; }
1398+
1399+
override void check ()
1400+
{
1401+
auto node = new RemoteAPI!API(node_tid, 5000.msecs);
1402+
assert(node.ping() == 42);
1403+
// We need to return immediately so that the main thread
1404+
// puts us to sleep
1405+
runTask(() {
1406+
node.ctrl.sleep(200.msecs);
1407+
assert(node.ping() == 42);
1408+
});
1409+
}
1410+
}
1411+
1412+
auto node_1 = RemoteAPI!API.spawn!Node(500.msecs);
1413+
auto node_2 = RemoteAPI!API.spawn!Node();
1414+
node_tid = node_2.tid;
1415+
node_1.check();
1416+
node_1.ctrl.sleep(300.msecs);
1417+
assert(node_1.ping() == 42);
1418+
}

0 commit comments

Comments
 (0)