Add EADDRINUSE test (#404)

pull/405/head
cgewecke 5 years ago committed by GitHub
parent bdf604dccd
commit b6af63d0ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      lib/app.js
  2. 4
      lib/ui.js
  3. 22
      test/units/truffle/errors.js

@ -293,7 +293,8 @@ class App {
return vm; return vm;
} }
await pify(this.server.listen)(this.port); // NB: EADDRINUSE errors are uncatch-able?
pify(this.server.listen)(this.port);
} }
assertHasBlockchain(provider){ assertHasBlockchain(provider){

@ -100,10 +100,6 @@ class AppUI extends UI {
'istanbul-fail': `${c.red('Istanbul coverage reports could not be generated. ')}`, 'istanbul-fail': `${c.red('Istanbul coverage reports could not be generated. ')}`,
'sources-fail': `${c.red('Cannot locate expected contract sources folder: ')} ${args[0]}`, 'sources-fail': `${c.red('Cannot locate expected contract sources folder: ')} ${args[0]}`,
'server-fail': `${c.red('Could not launch ganache server. Is ')}` +
`${args[0]} ${c.red('already in use? ')}` +
`${c.red('Run "lsof -i" in your terminal to check.\n')}`,
} }
return this._format(kinds[kind]) return this._format(kinds[kind])

@ -1,7 +1,9 @@
const assert = require('assert'); const assert = require('assert');
const fs = require('fs'); const fs = require('fs');
const path = require('path') const path = require('path')
const pify = require('pify')
const shell = require('shelljs'); const shell = require('shelljs');
const ganache = require('ganache-core-sc');
const verify = require('../../util/verifiers') const verify = require('../../util/verifiers')
const mock = require('../../util/integration.truffle'); const mock = require('../../util/integration.truffle');
@ -123,6 +125,26 @@ describe('Truffle Plugin: error cases', function() {
} }
}); });
// This case *does* throw an error, but it's uncatch-able;
it.skip('tries to launch with a port already in use', async function(){
verify.cleanInitialState();
const server = ganache.server();
truffleConfig.network = 'development';
mock.install('Simple', 'simple.js', solcoverConfig);
await pify(server.listen)(8545);
try {
await plugin(truffleConfig);
assert.fail();
} catch(err){
assert(err.message.includes('EADDRINUSE: address already in use :::8545'))
}
await pify(server.close)();
});
// Truffle test contains syntax error // Truffle test contains syntax error
it('truffle crashes', async function() { it('truffle crashes', async function() {
verify.cleanInitialState(); verify.cleanInitialState();

Loading…
Cancel
Save