From 26b87b4b05413ac2c31253c8ddaa2e4ec852e3de Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Thu, 30 Mar 2017 02:57:22 +0900 Subject: [PATCH] swap test var -> let --- test/abi.js | 18 +++++++++--------- test/blockchain.js | 16 ++++++++-------- test/cmd.js | 24 ++++++++++++------------ test/compiler.js | 14 +++++++------- test/console.js | 14 +++++++------- test/contracts.js | 20 ++++++++++---------- 6 files changed, 53 insertions(+), 53 deletions(-) diff --git a/test/abi.js b/test/abi.js index e54798b2f..64f177412 100644 --- a/test/abi.js +++ b/test/abi.js @@ -1,23 +1,23 @@ /*globals describe, it*/ -var ABIGenerator = require('../lib/contracts/abi.js'); -var assert = require('assert'); +let ABIGenerator = require('../lib/contracts/abi.js'); +let assert = require('assert'); // TODO: instead 'eval' the code with a fake web3 object // and check the generate code interacts as expected describe('embark.ABIGenerator', function() { this.timeout(0); describe('#generateProvider', function() { - var generator = new ABIGenerator({blockchainConfig: {rpcHost: 'somehost', rpcPort: '1234'}, contractsManager: {}}); + let generator = new ABIGenerator({blockchainConfig: {rpcHost: 'somehost', rpcPort: '1234'}, contractsManager: {}}); it('should generate code to connect to a provider', function() { - var providerCode = "\nif (typeof web3 !== 'undefined' && typeof Web3 !== 'undefined') {\n\tweb3 = new Web3(web3.currentProvider);\n} else if (typeof Web3 !== 'undefined') {\n\tweb3 = new Web3(new Web3.providers.HttpProvider(\"http://somehost:1234\"));\n}\nweb3.eth.defaultAccount = web3.eth.accounts[0];"; + let providerCode = "\nif (typeof web3 !== 'undefined' && typeof Web3 !== 'undefined') {\n\tweb3 = new Web3(web3.currentProvider);\n} else if (typeof Web3 !== 'undefined') {\n\tweb3 = new Web3(new Web3.providers.HttpProvider(\"http://somehost:1234\"));\n}\nweb3.eth.defaultAccount = web3.eth.accounts[0];"; assert.equal(generator.generateProvider(), providerCode); }); }); describe('#generateContracts', function() { - var generator = new ABIGenerator({blockchainConfig: {}, contractsManager: { + let generator = new ABIGenerator({blockchainConfig: {}, contractsManager: { contracts: { SimpleStorage: { abiDefinition: [{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initialValue","type":"uint256"}],"type":"constructor"}], @@ -35,19 +35,19 @@ describe('embark.ABIGenerator', function() { }}); describe('with EmbarkJS', function() { - var withEmbarkJS = true; + let withEmbarkJS = true; it('should generate contract code', function() { - var contractCode = "\n\nSimpleStorage = new EmbarkJS.Contract({abi: [{\"constant\":true,\"inputs\":[],\"name\":\"storedData\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"retVal\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"initialValue\",\"type\":\"uint256\"}],\"type\":\"constructor\"}], address: '0x123', code: '12345', gasEstimates: 12000});\nFoo = new EmbarkJS.Contract({abi: [{\"constant\":true,\"inputs\":[],\"name\":\"storedData\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"retVal\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"initialValue\",\"type\":\"uint256\"}],\"type\":\"constructor\"}], address: '0x124', code: '123456', gasEstimates: 12000});"; + let contractCode = "\n\nSimpleStorage = new EmbarkJS.Contract({abi: [{\"constant\":true,\"inputs\":[],\"name\":\"storedData\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"retVal\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"initialValue\",\"type\":\"uint256\"}],\"type\":\"constructor\"}], address: '0x123', code: '12345', gasEstimates: 12000});\nFoo = new EmbarkJS.Contract({abi: [{\"constant\":true,\"inputs\":[],\"name\":\"storedData\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"retVal\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"initialValue\",\"type\":\"uint256\"}],\"type\":\"constructor\"}], address: '0x124', code: '123456', gasEstimates: 12000});"; assert.equal(generator.generateContracts(withEmbarkJS), contractCode); }); }); describe('with default interface', function() { - var withEmbarkJS = false; + let withEmbarkJS = false; it('should generate contract code', function() { - var contractCode = "\n\nSimpleStorageAbi = [{\"constant\":true,\"inputs\":[],\"name\":\"storedData\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"retVal\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"initialValue\",\"type\":\"uint256\"}],\"type\":\"constructor\"}];\nSimpleStorageContract = web3.eth.contract(SimpleStorageAbi);\nSimpleStorage = SimpleStorageContract.at('0x123');\nFooAbi = [{\"constant\":true,\"inputs\":[],\"name\":\"storedData\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"retVal\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"initialValue\",\"type\":\"uint256\"}],\"type\":\"constructor\"}];\nFooContract = web3.eth.contract(FooAbi);\nFoo = FooContract.at('0x124');"; + let contractCode = "\n\nSimpleStorageAbi = [{\"constant\":true,\"inputs\":[],\"name\":\"storedData\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"retVal\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"initialValue\",\"type\":\"uint256\"}],\"type\":\"constructor\"}];\nSimpleStorageContract = web3.eth.contract(SimpleStorageAbi);\nSimpleStorage = SimpleStorageContract.at('0x123');\nFooAbi = [{\"constant\":true,\"inputs\":[],\"name\":\"storedData\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"}],\"name\":\"set\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"get\",\"outputs\":[{\"name\":\"retVal\",\"type\":\"uint256\"}],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"initialValue\",\"type\":\"uint256\"}],\"type\":\"constructor\"}];\nFooContract = web3.eth.contract(FooAbi);\nFoo = FooContract.at('0x124');"; assert.equal(generator.generateContracts(withEmbarkJS), contractCode); }); }); diff --git a/test/blockchain.js b/test/blockchain.js index 43fefaf59..a707d2c27 100644 --- a/test/blockchain.js +++ b/test/blockchain.js @@ -1,17 +1,17 @@ /*globals describe, it*/ -var Blockchain = require('../lib/cmds/blockchain/blockchain.js'); -var assert = require('assert'); +let Blockchain = require('../lib/cmds/blockchain/blockchain.js'); +let assert = require('assert'); describe('embark.Blockchain', function() { - //var Client = function() {}; + //let Client = function() {}; //Client.prototype.name = "ClientName"; describe('#initializer', function() { - //var client = new Client(); + //let client = new Client(); describe('with empty config', function() { it('should have a default config', function() { - var config = { + let config = { networkType: 'custom', genesisBlock: false, geth_bin: 'geth', @@ -31,7 +31,7 @@ describe('embark.Blockchain', function() { account: {}, bootnodes: "" }; - var blockchain = Blockchain(config, 'geth'); + let blockchain = Blockchain(config, 'geth'); assert.deepEqual(blockchain.config, config); }); @@ -39,7 +39,7 @@ describe('embark.Blockchain', function() { describe('with config', function() { it('should take config params', function() { - var config = { + let config = { networkType: 'livenet', genesisBlock: 'foo/bar/genesis.json', geth_bin: 'geth', @@ -59,7 +59,7 @@ describe('embark.Blockchain', function() { account: {}, bootnodes: "" }; - var blockchain = Blockchain(config, 'geth'); + let blockchain = Blockchain(config, 'geth'); assert.deepEqual(blockchain.config, config); }); diff --git a/test/cmd.js b/test/cmd.js index 519107506..45e99ebcd 100644 --- a/test/cmd.js +++ b/test/cmd.js @@ -1,5 +1,5 @@ -var Embark = require('../lib/index'); -var Cmd = require('../lib/cmd'); +let Embark = require('../lib/index'); +let Cmd = require('../lib/cmd'); // Function to send a line to stdin function sendLine(line) { @@ -8,8 +8,8 @@ function sendLine(line) { }); } -var passingLines = function () { - var lines = []; +let passingLines = function () { + let lines = []; lines.push('Initializing Embark Template....'); lines.push('Installing packages.. this can take a few seconds'); lines.push('Init complete'); @@ -21,11 +21,11 @@ describe('embark.Cmd', function () { describe('#new', function () { it('it should create an app with a name', function (done) { - var cmd = new Cmd(Embark); - var pl = passingLines(); - var appname = 'deleteapp'; + let cmd = new Cmd(Embark); + let pl = passingLines(); + let appname = 'deleteapp'; cmd.newApp(appname, function (output) { - var lines = output.split('\n'); + let lines = output.split('\n'); console.log(lines); assert.equal(lines[0], pl[0]); assert.equal(lines[1], pl[1]); @@ -36,12 +36,12 @@ describe('embark.Cmd', function () { }); it('it should prompt when given an empty app name', function (done) { - var cmd = new Cmd(Embark); - var pl = passingLines(); - var appname = 'deleteapp'; + let cmd = new Cmd(Embark); + let pl = passingLines(); + let appname = 'deleteapp'; cmd.newApp(undefined, function (output) { - var lines = output.split('\n'); + let lines = output.split('\n'); console.log(lines); sendLine(appname + '\n'); assert.equal(lines[0], pl[0]); diff --git a/test/compiler.js b/test/compiler.js index 9cbd1126a..03731bfcb 100644 --- a/test/compiler.js +++ b/test/compiler.js @@ -1,20 +1,20 @@ /*globals describe, it*/ -var Compiler = require('../lib/contracts/compiler.js'); -var TestLogger = require('../lib/core/test_logger.js'); -var assert = require('assert'); -var fs = require('fs'); +let Compiler = require('../lib/contracts/compiler.js'); +let TestLogger = require('../lib/core/test_logger.js'); +let assert = require('assert'); +let fs = require('fs'); -var readFile = function(file) { +let readFile = function(file) { return {filename: file, content: fs.readFileSync(file).toString()}; }; describe('embark.Compiler', function() { - var compiler = new Compiler({logger: new TestLogger({})}); + let compiler = new Compiler({logger: new TestLogger({})}); describe('#compile_solidity', function() { this.timeout(0); - var expectedObject = {}; + let expectedObject = {}; expectedObject["SimpleStorage"] = {"code":"606060405234610000576040516020806100f083398101604052515b60008190555b505b60bf806100316000396000f300606060405263ffffffff60e060020a6000350416632a1afcd98114603657806360fe47b11460525780636d4ce63c146061575b6000565b346000576040607d565b60408051918252519081900360200190f35b34600057605f6004356083565b005b346000576040608c565b60408051918252519081900360200190f35b60005481565b60008190555b50565b6000545b905600a165627a7a72305820a250be048d43f54e9afbb37211dc73ba843d23b95863b60afe703903500077220029","realRuntimeBytecode": "606060405263ffffffff60e060020a6000350416632a1afcd98114603657806360fe47b11460525780636d4ce63c146061575b6000565b346000576040607d565b60408051918252519081900360200190f35b34600057605f6004356083565b005b346000576040608c565b60408051918252519081900360200190f35b60005481565b60008190555b50565b6000545b905600a165627a7a72305820","runtimeBytecode":"606060405263ffffffff60e060020a6000350416632a1afcd98114603657806360fe47b11460525780636d4ce63c146061575b6000565b346000576040607d565b60408051918252519081900360200190f35b34600057605f6004356083565b005b346000576040608c565b60408051918252519081900360200190f35b60005481565b60008190555b50565b6000545b905600a165627a7a72305820a250be048d43f54e9afbb37211dc73ba843d23b95863b60afe703903500077220029","swarmHash": "a250be048d43f54e9afbb37211dc73ba843d23b95863b60afe70390350007722","gasEstimates":{"creation":[20131,38200],"external":{"get()":269,"set(uint256)":20163,"storedData()":224},"internal":{}},"functionHashes":{"get()":"6d4ce63c","set(uint256)":"60fe47b1","storedData()":"2a1afcd9"},"abiDefinition":[{"constant":true,"inputs":[],"name":"storedData","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint256"}],"payable":false,"type":"function"},{"inputs":[{"name":"initialValue","type":"uint256"}],"payable":false,"type":"constructor"}]}; diff --git a/test/console.js b/test/console.js index a0f9d6e29..71b6998e5 100644 --- a/test/console.js +++ b/test/console.js @@ -1,12 +1,12 @@ /*globals describe, it*/ -var Console = require('../lib/dashboard/console.js'); -var Plugins = require('../lib/core/plugins.js'); -var assert = require('assert'); -var version = require('../package.json').version; +let Console = require('../lib/dashboard/console.js'); +let Plugins = require('../lib/core/plugins.js'); +let assert = require('assert'); +let version = require('../package.json').version; describe('embark.Console', function() { - var plugins = new Plugins({plugins: {}}); - var console = new Console({plugins: plugins, version: version}); + let plugins = new Plugins({plugins: {}}); + let console = new Console({plugins: plugins, version: version}); describe('#executeCmd', function() { @@ -14,7 +14,7 @@ describe('embark.Console', function() { it('it should provide a help text', function(done) { console.executeCmd('help', function(output) { - var lines = output.split('\n'); + let lines = output.split('\n'); assert.equal(lines[0], 'Welcome to Embark ' + version); assert.equal(lines[2], 'possible commands are:'); done(); diff --git a/test/contracts.js b/test/contracts.js index 57b65bcf3..7e366a19e 100644 --- a/test/contracts.js +++ b/test/contracts.js @@ -1,17 +1,17 @@ /*globals describe, it*/ -var ContractsManager = require('../lib/contracts/contracts.js'); -var Logger = require('../lib/core/logger.js'); -var assert = require('assert'); -var fs = require('fs'); +let ContractsManager = require('../lib/contracts/contracts.js'); +let Logger = require('../lib/core/logger.js'); +let assert = require('assert'); +let fs = require('fs'); -var readFile = function(file) { +let readFile = function(file) { return {filename: file, content: fs.readFileSync(file).toString()}; }; describe('embark.Contratcs', function() { describe('simple', function() { - var contractsManager = new ContractsManager({ + let contractsManager = new ContractsManager({ contractFiles: [ readFile('test/contracts/simple_storage.sol'), readFile('test/contracts/token.sol') @@ -41,7 +41,7 @@ describe('embark.Contratcs', function() { throw err; } - var contracts = contractsManager.listContracts(); + let contracts = contractsManager.listContracts(); assert.equal(contracts.length, 2); assert.equal(contracts[0].deploy, true); @@ -70,7 +70,7 @@ describe('embark.Contratcs', function() { }); describe('config with contract instances', function() { - var contractsManager = new ContractsManager({ + let contractsManager = new ContractsManager({ contractFiles: [ readFile('test/contracts/simple_storage.sol'), readFile('test/contracts/token_storage.sol') @@ -110,7 +110,7 @@ describe('embark.Contratcs', function() { throw err; } - var contracts = contractsManager.listContracts(); + let contracts = contractsManager.listContracts(); assert.equal(contracts.length, 4); assert.equal(contracts[0].className, "MySimpleStorage"); @@ -127,7 +127,7 @@ describe('embark.Contratcs', function() { //assert.equal(contracts[3].code, ''); //assert.equal(contracts[3].runtimeBytecode, ''); - var parentContract = contracts[2]; + let parentContract = contracts[2]; //MySimpleStorage assert.equal(contracts[0].deploy, true);