Add EADDRINUSE test (#404)

truffle-plugin
cgewecke 5 years ago
parent ee72e8d66d
commit cd7fae0327
  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;
}
await pify(this.server.listen)(this.port);
// NB: EADDRINUSE errors are uncatch-able?
pify(this.server.listen)(this.port);
}
assertHasBlockchain(provider){

@ -100,10 +100,6 @@ class AppUI extends UI {
'istanbul-fail': `${c.red('Istanbul coverage reports could not be generated. ')}`,
'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])

@ -1,7 +1,9 @@
const assert = require('assert');
const fs = require('fs');
const path = require('path')
const pify = require('pify')
const shell = require('shelljs');
const ganache = require('ganache-core-sc');
const verify = require('../../util/verifiers')
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
it('truffle crashes', async function() {
verify.cleanInitialState();

Loading…
Cancel
Save