Skip to content

Commit

Permalink
Add resubscribe to existing subscription case
Browse files Browse the repository at this point in the history
  • Loading branch information
cgewecke committed Dec 17, 2019
1 parent 7790a26 commit ac880f6
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/eth.subscribe.ganache.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,27 @@ describe('subscription connect/reconnect', function() {
});
});

it('resubscribes', function(done){
it('resubscribes to an existing subscription', function(done){
this.timeout(5000);

let stage = 0;

subscription = web3.eth.subscribe('newBlockHeaders');

subscription.on('data', function(result){
if (stage === 0) {
subscription.resubscribe();
stage = 1;
return;
}

assert(result.parentHash);
subscription.unsubscribe(); // Stop listening..
done();
});
});

it('resubscribes after being unsubscribed', function(done){
this.timeout(5000);

let stage = 0;
Expand Down

0 comments on commit ac880f6

Please sign in to comment.