Browse files

Add failing test.

The test demonstrates failure for the following scenario. A single-subscription
client calls unsubscribe immediately followed by a subscribe. It will fail when
it tries to receive the next pmessage/message because the client will be in
false pub_sub_mode. Here is why it is false: First, the 2nd subscribe sets
pub_sub_mode to true during send_command. Next, the unsubscribe's
return_reply sets pub_sub_mode to false. The 2nd subscribe's return_reply does
not re-set pub_sub_mode back to true. So the result is a client with false
pub_sub_mode that fails upon receipt of the next message or pmessage.
  • Loading branch information...
1 parent 5a5af9a commit 2afa0e5acca0051749beb4b4eb19b1d70418b5ed @bnoguchi bnoguchi committed Mar 13, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 tests/re_sub_test.js
@@ -0,0 +1,14 @@
+var client = require('../index').createClient()
+ , client2 = require('../index').createClient()
+ , assert = require('assert');
+client.once('subscribe', function (channel, count) {
+ client.unsubscribe('x');
+ client.subscribe('x', function () {
+ client.quit();
+ client2.quit();
+ });
+ client2.publish('x', 'hi');

0 comments on commit 2afa0e5

Please sign in to comment.