mirror of https://github.com/embarklabs/embark.git
use callbacks instead of exiting
This commit is contained in:
parent
6afa07f111
commit
1491028665
|
@ -1,4 +1,4 @@
|
|||
/*global contract, config, it, assert*/
|
||||
/*global contract, config, it, assert, web3*/
|
||||
const SimpleStorage = require('Embark/contracts/SimpleStorage');
|
||||
|
||||
let accounts;
|
||||
|
@ -17,7 +17,7 @@ config({
|
|||
}
|
||||
}
|
||||
}, (_err, web3_accounts) => {
|
||||
accounts = web3_accounts
|
||||
accounts = web3_accounts;
|
||||
});
|
||||
|
||||
contract("SimpleStorage", function () {
|
||||
|
|
|
@ -64,7 +64,11 @@ class BlockchainConnector {
|
|||
embark.registerActionForEvent("contracts:deploy:afterAll", this.subscribeToContractEvents.bind(this));
|
||||
|
||||
if (!this.web3) {
|
||||
this.initWeb3();
|
||||
this.initWeb3(err => {
|
||||
if (err) {
|
||||
this.logger.error(__('Error initiating Web3 provider'), err.message || err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.isWeb3Ready = true;
|
||||
}
|
||||
|
@ -177,7 +181,10 @@ class BlockchainConnector {
|
|||
if (err) {
|
||||
return self.logger.error(err);
|
||||
}
|
||||
self.provider.startWeb3Provider(async () => {
|
||||
self.provider.startWeb3Provider(async (err) => {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
try {
|
||||
const blockNumber = await self.web3.eth.getBlockNumber();
|
||||
await self.web3.eth.getBlock(blockNumber);
|
||||
|
|
|
@ -17,6 +17,7 @@ class Provider {
|
|||
this.isDev = options.isDev;
|
||||
this.events = options.events;
|
||||
this.nonceCache = {};
|
||||
this.accounts = [];
|
||||
|
||||
this.events.setCommandHandler("blockchain:provider:contract:accounts:get", cb => {
|
||||
const accounts = this.accounts.map(a => a.address || a);
|
||||
|
@ -80,8 +81,8 @@ class Provider {
|
|||
accounts = accounts.concat(self.blockchainAccounts);
|
||||
|
||||
self.accounts = AccountParser.parseAccountsConfig(self.accountsConfig, self.web3, dappPath(), self.logger, accounts);
|
||||
} catch (_e) {
|
||||
process.exit(1);
|
||||
} catch (e) {
|
||||
return callback(e);
|
||||
}
|
||||
|
||||
if (!self.accounts.length) {
|
||||
|
|
|
@ -166,7 +166,8 @@ Blockchain.prototype.setupProxy = async function () {
|
|||
let addresses;
|
||||
try {
|
||||
addresses = AccountParser.parseAccountsConfig(this.userConfig.accounts, false, dappPath(), this.logger);
|
||||
} catch (_e) {
|
||||
} catch (e) {
|
||||
this.logger.error(e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,8 @@ export class Simulator {
|
|||
let parsedAccounts;
|
||||
try {
|
||||
parsedAccounts = AccountParser.parseAccountsConfig(simulatorAccounts, web3, dappPath(), this.logger);
|
||||
} catch (_e) {
|
||||
} catch (e) {
|
||||
this.logger.error(e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
parsedAccounts.forEach((account) => {
|
||||
|
|
|
@ -159,8 +159,8 @@ class Test {
|
|||
if (accounts) {
|
||||
try {
|
||||
self.simOptions.accounts = AccountParser.parseAccountsConfig(accounts, web3, this.dappPath);
|
||||
} catch (_e) {
|
||||
process.exit(1);
|
||||
} catch (e) {
|
||||
return callback(e);
|
||||
}
|
||||
} else {
|
||||
self.simOptions.accounts = null;
|
||||
|
@ -255,6 +255,7 @@ class Test {
|
|||
}
|
||||
], (err, accounts) => {
|
||||
if (err) {
|
||||
self.logger.error(err.message || err);
|
||||
// TODO Do not exit in case of not a normal run (eg after a change)
|
||||
if (!self.options.inProcess) process.exit(1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue