Skip to content

Commit

Permalink
Add test for close event and TODOs to remove close
Browse files Browse the repository at this point in the history
  • Loading branch information
Ybrin committed Nov 13, 2020
1 parent 011aafa commit 09cc191
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/web3-core-requestmanager/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ RequestManager.prototype.setProvider = function (provider, net) {
_this.provider.emit('end', event);
}
};
// TODO: Remove close once the standard allows it
this.provider.on('close', disconnect);
this.provider.on('disconnect', disconnect);

Expand Down
5 changes: 4 additions & 1 deletion test/3_givenProvider-ganache.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ describe('web.providers.givenProvider (ganache)', function(){
assert.equal(1, web3.currentProvider.listenerCount('data'))
assert.equal(1, web3.currentProvider.listenerCount('connect'))
assert.equal(1, web3.currentProvider.listenerCount('error'))
assert.equal(1, web3.currentProvider.listenerCount('disconnect'))
// TODO: Remove close once the standard allows it
assert(
web3.currentProvider.listenerCount("disconnect") === 1 || web3.currentProvider.listenerCount("close") === 1
);
});

it('deploys a contract', async function(){
Expand Down

0 comments on commit 09cc191

Please sign in to comment.