From db74ecbfb9c20db9501f84a26d79a06287b2b352 Mon Sep 17 00:00:00 2001 From: Morgan Allen Date: Sun, 29 Jul 2018 00:48:32 -0700 Subject: [PATCH] add exchange test this ensure continuous rx is reenabled --- test/test.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/test.js b/test/test.js index 6db9bb9..ab31f2a 100644 --- a/test/test.js +++ b/test/test.js @@ -183,4 +183,34 @@ async.series([ port.write(msg); }; }, "spreadfactor"); + + test(function(t) { + t.plan(4); + + var i = 0; + + async.doUntil(function(done) { + var write = ports["dev" + (1 + i % 2)]; + var read = ports["dev" + (1 + (i + 1) % 2)]; + + var buf = ""; + var msg = `tick${i}`; + + read.on("data", function onData(c) { + buf += c.toString(); + + if(buf.indexOf(msg) !== -1) { + t.pass("got message " + i); + + read.removeListener("data", onData); + + done(null); + } + }); + + write.write(`send${msg}\n`); + }, function() { + return ++i > 5; + }) + }, "exchange"); });