mirror of https://github.com/embarklabs/embark.git
code review
This commit is contained in:
parent
78bb9bc34d
commit
6afa07f111
|
@ -74,11 +74,15 @@ class Provider {
|
||||||
self.logger.warn('Error while getting the node\'s accounts.', err.message || err);
|
self.logger.warn('Error while getting the node\'s accounts.', err.message || err);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.blockchainAccounts = AccountParser.parseAccountsConfig(self.blockchainConfig.accounts, self.web3, dappPath(), self.logger, accounts);
|
try {
|
||||||
|
self.blockchainAccounts = AccountParser.parseAccountsConfig(self.blockchainConfig.accounts, self.web3, dappPath(), self.logger, accounts);
|
||||||
|
|
||||||
accounts = accounts.concat(self.blockchainAccounts);
|
accounts = accounts.concat(self.blockchainAccounts);
|
||||||
|
|
||||||
self.accounts = AccountParser.parseAccountsConfig(self.accountsConfig, self.web3, dappPath(), self.logger, accounts);
|
self.accounts = AccountParser.parseAccountsConfig(self.accountsConfig, self.web3, dappPath(), self.logger, accounts);
|
||||||
|
} catch (_e) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (!self.accounts.length) {
|
if (!self.accounts.length) {
|
||||||
self.accounts = accounts;
|
self.accounts = accounts;
|
||||||
|
|
|
@ -163,7 +163,12 @@ Blockchain.prototype.initProxy = function () {
|
||||||
Blockchain.prototype.setupProxy = async function () {
|
Blockchain.prototype.setupProxy = async function () {
|
||||||
if (!this.proxyIpc) this.proxyIpc = new IPC({ipcRole: 'client'});
|
if (!this.proxyIpc) this.proxyIpc = new IPC({ipcRole: 'client'});
|
||||||
|
|
||||||
const addresses = AccountParser.parseAccountsConfig(this.userConfig.accounts, false, dappPath(), this.logger);
|
let addresses;
|
||||||
|
try {
|
||||||
|
addresses = AccountParser.parseAccountsConfig(this.userConfig.accounts, false, dappPath(), this.logger);
|
||||||
|
} catch (_e) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
let wsProxy;
|
let wsProxy;
|
||||||
if (this.config.wsRPC) {
|
if (this.config.wsRPC) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ export class Simulator {
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*eslint complexity: ["error", 25]*/
|
/*eslint complexity: ["error", 26]*/
|
||||||
run(options) {
|
run(options) {
|
||||||
let cmds = [];
|
let cmds = [];
|
||||||
|
|
||||||
|
@ -42,7 +42,12 @@ export class Simulator {
|
||||||
let simulatorAccounts = this.blockchainConfig.simulatorAccounts || options.simulatorAccounts;
|
let simulatorAccounts = this.blockchainConfig.simulatorAccounts || options.simulatorAccounts;
|
||||||
if (simulatorAccounts && simulatorAccounts.length > 0) {
|
if (simulatorAccounts && simulatorAccounts.length > 0) {
|
||||||
let web3 = new (require('web3'))();
|
let web3 = new (require('web3'))();
|
||||||
let parsedAccounts = AccountParser.parseAccountsConfig(simulatorAccounts, web3, dappPath(), this.logger);
|
let parsedAccounts;
|
||||||
|
try {
|
||||||
|
parsedAccounts = AccountParser.parseAccountsConfig(simulatorAccounts, web3, dappPath(), this.logger);
|
||||||
|
} catch (_e) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
parsedAccounts.forEach((account) => {
|
parsedAccounts.forEach((account) => {
|
||||||
let cmd = '--account="' + account.privateKey + ','+account.hexBalance + '"';
|
let cmd = '--account="' + account.privateKey + ','+account.hexBalance + '"';
|
||||||
cmds.push(cmd);
|
cmds.push(cmd);
|
||||||
|
|
|
@ -157,7 +157,11 @@ class Test {
|
||||||
|
|
||||||
this.events.request("blockchain:get", (web3) => {
|
this.events.request("blockchain:get", (web3) => {
|
||||||
if (accounts) {
|
if (accounts) {
|
||||||
self.simOptions.accounts = AccountParser.parseAccountsConfig(accounts, web3, this.dappPath);
|
try {
|
||||||
|
self.simOptions.accounts = AccountParser.parseAccountsConfig(accounts, web3, this.dappPath);
|
||||||
|
} catch (_e) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.simOptions.accounts = null;
|
self.simOptions.accounts = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ class AccountParser {
|
||||||
accountsConfig.forEach(accountConfig => {
|
accountsConfig.forEach(accountConfig => {
|
||||||
let account = AccountParser.getAccount(accountConfig, web3, dappPath, logger, nodeAccounts);
|
let account = AccountParser.getAccount(accountConfig, web3, dappPath, logger, nodeAccounts);
|
||||||
if (account === ERROR_ACCOUNT) {
|
if (account === ERROR_ACCOUNT) {
|
||||||
process.exit(1);
|
throw new Error('Error getting the account');
|
||||||
}
|
}
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -4,7 +4,6 @@ const assert = require('assert');
|
||||||
const sinon = require('sinon');
|
const sinon = require('sinon');
|
||||||
let TestLogger = require('../lib/utils/test_logger');
|
let TestLogger = require('../lib/utils/test_logger');
|
||||||
const Web3 = require('web3');
|
const Web3 = require('web3');
|
||||||
const fs = require('../lib/core/fs');
|
|
||||||
import { dappPath, getWeiBalanceFromString, getHexBalanceFromString, AccountParser } from 'embark-utils';
|
import { dappPath, getWeiBalanceFromString, getHexBalanceFromString, AccountParser } from 'embark-utils';
|
||||||
i18n.setOrDetectLocale('en');
|
i18n.setOrDetectLocale('en');
|
||||||
|
|
||||||
|
@ -75,12 +74,12 @@ describe('embark.AccountParser', function () {
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return nothing with bad config', function () {
|
it('should return an error with bad config', function () {
|
||||||
const account = AccountParser.getAccount({
|
const account = AccountParser.getAccount({
|
||||||
badConfig: 'not working'
|
badConfig: 'not working'
|
||||||
}, web3, dappPath(), testLogger);
|
}, web3, dappPath(), testLogger);
|
||||||
|
|
||||||
assert.strictEqual(account, null);
|
assert.strictEqual(account, 'ERROR_ACCOUNT');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should just return the addresses when no web3', function () {
|
it('should just return the addresses when no web3', function () {
|
||||||
|
|
Loading…
Reference in New Issue