Skip to content

Commit

Permalink
add targetGasLimit Ether units and test
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Lipert committed Sep 25, 2018
1 parent b24449d commit 33b8b00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/modules/blockchain_process/blockchain.js
@@ -1,5 +1,6 @@
const async = require('async');
const child_process = require('child_process');
const web3 = require('web3');

const fs = require('../../core/fs.js');
const constants = require('../../constants.json');
Expand Down Expand Up @@ -52,7 +53,7 @@ var Blockchain = function(options) {
wsOrigins: this.blockchainConfig.wsOrigins || false,
wsApi: (this.blockchainConfig.wsApi || defaultWsApi),
vmdebug: this.blockchainConfig.vmdebug || false,
targetGasLimit: this.blockchainConfig.targetGasLimit || false,
targetGasLimit: utils.getWeiBalanceFromString(this.blockchainConfig.targetGasLimit, web3) || false,
syncMode: this.blockchainConfig.syncMode,
syncmode: this.blockchainConfig.syncmode,
verbosity: this.blockchainConfig.verbosity
Expand Down
12 changes: 10 additions & 2 deletions test/blockchain.js
Expand Up @@ -82,7 +82,7 @@ describe('embark.Blockchain', function () {
wsOrigins: false,
wsPort: 12346,
wsRPC: true,
targetGasLimit: false,
targetGasLimit: "8 Mwei",
syncMode: undefined,
syncmode: undefined,
verbosity: undefined,
Expand All @@ -95,7 +95,15 @@ describe('embark.Blockchain', function () {
config.rpcPort += constants.blockchain.servicePortOnProxy;
}

assert.deepEqual(blockchain.config, config);
try {
assert.deepEqual(blockchain.config, config);
} catch (e) {
// Verify Ether unit conversion to wei
assert(e instanceof assert.AssertionError);
assert.equal(e.actual['targetGasLimit'], '8000000');
assert.deepEqual(Object.assign({}, blockchain.config, {targetGasLimit: undefined}),
Object.assign({}, config, {targetGasLimit: undefined}));
}
done();
});
});
Expand Down

0 comments on commit 33b8b00

Please sign in to comment.