From ce2caa4da0bd1b059905442b0e32d785f4784499 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 16 Dec 2019 19:14:59 -0500 Subject: [PATCH] update remix-simulator syntax to use const, let and this --- remix-simulator/index.js | 2 +- remix-simulator/src/genesis.js | 10 +-- remix-simulator/src/methods/accounts.js | 10 +-- remix-simulator/src/methods/blocks.js | 2 +- remix-simulator/src/methods/filters.js | 2 +- remix-simulator/src/methods/misc.js | 8 +-- remix-simulator/src/methods/net.js | 2 +- remix-simulator/src/methods/transactions.js | 24 +++---- remix-simulator/src/methods/txProcess.js | 14 ++-- remix-simulator/src/provider.js | 8 +-- remix-simulator/src/utils/logs.js | 20 +++--- remix-simulator/test/accounts.js | 30 ++++----- remix-simulator/test/blocks.js | 74 ++++++++++----------- remix-simulator/test/misc.js | 42 ++++++------ 14 files changed, 124 insertions(+), 124 deletions(-) diff --git a/remix-simulator/index.js b/remix-simulator/index.js index 4b17d07532..3ce817f94e 100644 --- a/remix-simulator/index.js +++ b/remix-simulator/index.js @@ -1,4 +1,4 @@ -var Provider = require('./src/provider') +const Provider = require('./src/provider') module.exports = { Provider: Provider diff --git a/remix-simulator/src/genesis.js b/remix-simulator/src/genesis.js index f008ead194..b9674c695e 100644 --- a/remix-simulator/src/genesis.js +++ b/remix-simulator/src/genesis.js @@ -1,9 +1,9 @@ -var EthJSBlock = require('ethereumjs-block') -var ethJSUtil = require('ethereumjs-util') -var BN = ethJSUtil.BN +const EthJSBlock = require('ethereumjs-block') +const ethJSUtil = require('ethereumjs-util') +const BN = ethJSUtil.BN function generateBlock (executionContext) { - var block = new EthJSBlock({ + const block = new EthJSBlock({ header: { timestamp: (new Date().getTime() / 1000 | 0), number: 0, @@ -15,7 +15,7 @@ function generateBlock (executionContext) { uncleHeaders: [] }) - executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }).then(function () { + executionContext.vm().runBlock({ block: block, generate: true, skipBlockValidation: true, skipBalance: false }).then(() => { executionContext.addBlock(block) }) } diff --git a/remix-simulator/src/methods/accounts.js b/remix-simulator/src/methods/accounts.js index c7c369ff80..0bd5d10cc6 100644 --- a/remix-simulator/src/methods/accounts.js +++ b/remix-simulator/src/methods/accounts.js @@ -1,8 +1,8 @@ -var ethJSUtil = require('ethereumjs-util') -var BN = ethJSUtil.BN -var Web3 = require('web3') +const ethJSUtil = require('ethereumjs-util') +const BN = ethJSUtil.BN +const Web3 = require('web3') -var Accounts = function (executionContext) { +const Accounts = function (executionContext) { this.web3 = new Web3() this.executionContext = executionContext // TODO: make it random and/or use remix-libs @@ -23,7 +23,7 @@ Accounts.prototype.init = async function () { if (err) { throw new Error(err) } - var balance = '0x56BC75E2D63100000' + const balance = '0x56BC75E2D63100000' account.balance = balance || '0xf00000000000000001' resolve() }) diff --git a/remix-simulator/src/methods/blocks.js b/remix-simulator/src/methods/blocks.js index b8fe4e8f07..182a5bf838 100644 --- a/remix-simulator/src/methods/blocks.js +++ b/remix-simulator/src/methods/blocks.js @@ -1,5 +1,5 @@ -var Blocks = function (executionContext, _options) { +const Blocks = function (executionContext, _options) { this.executionContext = executionContext const options = _options || {} this.coinbase = options.coinbase || '0x0000000000000000000000000000000000000000' diff --git a/remix-simulator/src/methods/filters.js b/remix-simulator/src/methods/filters.js index 7453d615bd..999bf24b12 100644 --- a/remix-simulator/src/methods/filters.js +++ b/remix-simulator/src/methods/filters.js @@ -1,5 +1,5 @@ -var Filters = function (executionContext) { +const Filters = function (executionContext) { this.executionContext = executionContext } diff --git a/remix-simulator/src/methods/misc.js b/remix-simulator/src/methods/misc.js index 590ca5bb1c..045082702f 100644 --- a/remix-simulator/src/methods/misc.js +++ b/remix-simulator/src/methods/misc.js @@ -1,7 +1,7 @@ -var version = require('../../package.json').version -var web3 = require('web3') +const version = require('../../package.json').version +const web3 = require('web3') -var Misc = function () { +const Misc = function () { } Misc.prototype.methods = function () { @@ -41,7 +41,7 @@ Misc.prototype.eth_hashrate = function (payload, cb) { } Misc.prototype.web3_sha3 = function (payload, cb) { - let str = payload.params[0] + const str = payload.params[0] cb(null, web3.utils.sha3(str)) } diff --git a/remix-simulator/src/methods/net.js b/remix-simulator/src/methods/net.js index 83104d772b..1c4819c19a 100644 --- a/remix-simulator/src/methods/net.js +++ b/remix-simulator/src/methods/net.js @@ -1,5 +1,5 @@ -var Net = function () { +const Net = function () { } Net.prototype.methods = function () { diff --git a/remix-simulator/src/methods/transactions.js b/remix-simulator/src/methods/transactions.js index 94a211513a..b642f5dc36 100644 --- a/remix-simulator/src/methods/transactions.js +++ b/remix-simulator/src/methods/transactions.js @@ -1,9 +1,9 @@ -var Web3 = require('web3') -var ethJSUtil = require('ethereumjs-util') -var processTx = require('./txProcess.js') -var BN = ethJSUtil.BN +const Web3 = require('web3') +const ethJSUtil = require('ethereumjs-util') +const processTx = require('./txProcess.js') +const BN = ethJSUtil.BN -var Transactions = function (executionContext) { +const Transactions = function (executionContext) { this.executionContext = executionContext } @@ -39,9 +39,9 @@ Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) { return cb(error) } - var txBlock = this.executionContext.txs[receipt.hash] + const txBlock = this.executionContext.txs[receipt.hash] - var r = { + const r = { 'transactionHash': receipt.hash, 'transactionIndex': '0x00', 'blockHash': '0x' + txBlock.hash().toString('hex'), @@ -111,10 +111,10 @@ Transactions.prototype.eth_getTransactionByHash = function (payload, cb) { return cb(error) } - var txBlock = this.executionContext.txs[receipt.transactionHash] + const txBlock = this.executionContext.txs[receipt.transactionHash] // TODO: params to add later - let r = { + const r = { 'blockHash': '0x' + txBlock.hash().toString('hex'), 'blockNumber': '0x' + txBlock.header.number.toString('hex'), 'from': receipt.from, @@ -151,7 +151,7 @@ Transactions.prototype.eth_getTransactionByHash = function (payload, cb) { Transactions.prototype.eth_getTransactionByBlockHashAndIndex = function (payload, cb) { const txIndex = payload.params[1] - var txBlock = this.executionContext.blocks[payload.params[0]] + const txBlock = this.executionContext.blocks[payload.params[0]] const txHash = '0x' + txBlock.transactions[Web3.utils.toDecimal(txIndex)].hash().toString('hex') this.executionContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => { @@ -193,7 +193,7 @@ Transactions.prototype.eth_getTransactionByBlockHashAndIndex = function (payload Transactions.prototype.eth_getTransactionByBlockNumberAndIndex = function (payload, cb) { const txIndex = payload.params[1] - var txBlock = this.executionContext.blocks[payload.params[0]] + const txBlock = this.executionContext.blocks[payload.params[0]] const txHash = '0x' + txBlock.transactions[Web3.utils.toDecimal(txIndex)].hash().toString('hex') this.executionContext.web3().eth.getTransactionReceipt(txHash, (error, receipt) => { @@ -202,7 +202,7 @@ Transactions.prototype.eth_getTransactionByBlockNumberAndIndex = function (paylo } // TODO: params to add later - let r = { + const r = { 'blockHash': '0x' + txBlock.hash().toString('hex'), 'blockNumber': '0x' + txBlock.header.number.toString('hex'), 'from': receipt.from, diff --git a/remix-simulator/src/methods/txProcess.js b/remix-simulator/src/methods/txProcess.js index 1126850643..c3c61c3031 100644 --- a/remix-simulator/src/methods/txProcess.js +++ b/remix-simulator/src/methods/txProcess.js @@ -1,9 +1,9 @@ -var RemixLib = require('remix-lib') -var TxExecution = RemixLib.execution.txExecution -var TxRunner = RemixLib.execution.txRunner +const RemixLib = require('remix-lib') +const TxExecution = RemixLib.execution.txExecution +const TxRunner = RemixLib.execution.txRunner function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) { - let finalCallback = function (err, result) { + const finalCallback = function (err, result) { if (err) { return callback(err) } @@ -16,7 +16,7 @@ function runCall (payload, from, to, data, value, gasLimit, txRunner, callbacks, } function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, callback) { - let finalCallback = function (err, result) { + const finalCallback = function (err, result) { if (err) { return callback(err) } @@ -27,7 +27,7 @@ function runTx (payload, from, to, data, value, gasLimit, txRunner, callbacks, c } function createContract (payload, from, data, value, gasLimit, txRunner, callbacks, callback) { - let finalCallback = function (err, result) { + const finalCallback = function (err, result) { if (err) { return callback(err) } @@ -40,7 +40,7 @@ function createContract (payload, from, data, value, gasLimit, txRunner, callbac let txRunnerInstance function processTx (executionContext, accounts, payload, isCall, callback) { - let api = { + const api = { logMessage: (msg) => { }, logHtmlMessage: (msg) => { diff --git a/remix-simulator/src/provider.js b/remix-simulator/src/provider.js index c7929e297d..7fe1017994 100644 --- a/remix-simulator/src/provider.js +++ b/remix-simulator/src/provider.js @@ -1,5 +1,5 @@ -var RemixLib = require('remix-lib') -var executionContext = RemixLib.execution.executionContext +const RemixLib = require('remix-lib') +const executionContext = RemixLib.execution.executionContext const log = require('./utils/logs.js') const merge = require('merge') @@ -40,7 +40,7 @@ Provider.prototype.init = async function () { Provider.prototype.sendAsync = function (payload, callback) { log.info('payload method is ', payload.method) - let method = this.methods[payload.method] + const method = this.methods[payload.method] if (this.options.logDetails) { log.info(payload) } @@ -53,7 +53,7 @@ Provider.prototype.sendAsync = function (payload, callback) { if (err) { return callback(err) } - let response = {'id': payload.id, 'jsonrpc': '2.0', 'result': result} + const response = {'id': payload.id, 'jsonrpc': '2.0', 'result': result} callback(null, response) }) } diff --git a/remix-simulator/src/utils/logs.js b/remix-simulator/src/utils/logs.js index 7139140b97..d6a22b651a 100644 --- a/remix-simulator/src/utils/logs.js +++ b/remix-simulator/src/utils/logs.js @@ -1,8 +1,8 @@ 'use strict' -var gray = require('ansi-gray') -var timestamp = require('time-stamp') -var supportsColor = require('color-support') +const gray = require('ansi-gray') +const timestamp = require('time-stamp') +const supportsColor = require('color-support') function hasFlag (flag) { return ((typeof (process) !== 'undefined') && (process.argv.indexOf('--' + flag) !== -1)) @@ -24,7 +24,7 @@ function addColor (str) { return str } -let logger = { +const logger = { stdout: function (arg) { if (typeof (process) === 'undefined' || !process.stdout) return process.stdout.write(arg) @@ -36,40 +36,40 @@ let logger = { } function getTimestamp () { - let coloredTimestamp = addColor(timestamp('HH:mm:ss')) + const coloredTimestamp = addColor(timestamp('HH:mm:ss')) return '[' + coloredTimestamp + ']' } function log () { - var time = getTimestamp() + const time = getTimestamp() logger.stdout(time + ' ') console.log.apply(console, arguments) return this } function info () { - var time = getTimestamp() + const time = getTimestamp() logger.stdout(time + ' ') console.info.apply(console, arguments) return this } function dir () { - var time = getTimestamp() + const time = getTimestamp() logger.stdout(time + ' ') console.dir.apply(console, arguments) return this } function warn () { - var time = getTimestamp() + const time = getTimestamp() logger.stderr(time + ' ') console.warn.apply(console, arguments) return this } function error () { - var time = getTimestamp() + const time = getTimestamp() logger.stderr(time + ' ') console.error.apply(console, arguments) return this diff --git a/remix-simulator/test/accounts.js b/remix-simulator/test/accounts.js index 08ad48b1b8..fbe0e6e1eb 100644 --- a/remix-simulator/test/accounts.js +++ b/remix-simulator/test/accounts.js @@ -1,28 +1,28 @@ /* global describe, before, it */ -var Web3 = require('web3') -var RemixSim = require('../index.js') -let web3 = new Web3() -var assert = require('assert') +const Web3 = require('web3') +const RemixSim = require('../index.js') +const web3 = new Web3() +const assert = require('assert') -describe('Accounts', function () { +describe('Accounts', () => { before(function () { - let provider = new RemixSim.Provider() + const provider = new RemixSim.Provider() web3.setProvider(provider) }) describe('eth_getAccounts', () => { it('should get a list of accounts', async function () { - let accounts = await web3.eth.getAccounts() + const accounts = await web3.eth.getAccounts() assert.notEqual(accounts.length, 0) }) }) describe('eth_getBalance', () => { - it('should get a account balance', async function () { - let accounts = await web3.eth.getAccounts() - let balance0 = await web3.eth.getBalance(accounts[0]) - let balance1 = await web3.eth.getBalance(accounts[1]) - let balance2 = await web3.eth.getBalance(accounts[2]) + it('should get a account balance', async () => { + const accounts = await web3.eth.getAccounts() + const balance0 = await web3.eth.getBalance(accounts[0]) + const balance1 = await web3.eth.getBalance(accounts[1]) + const balance2 = await web3.eth.getBalance(accounts[2]) assert.deepEqual(balance0, '100000000000000000000') assert.deepEqual(balance1, '100000000000000000000') @@ -31,9 +31,9 @@ describe('Accounts', function () { }) describe('eth_sign', () => { - it('should sign payloads', async function () { - let accounts = await web3.eth.getAccounts() - let signature = await web3.eth.sign('Hello world', accounts[0]) + it('should sign payloads', async () => { + const accounts = await web3.eth.getAccounts() + const signature = await web3.eth.sign('Hello world', accounts[0]) assert.deepEqual(signature.length, 132) }) diff --git a/remix-simulator/test/blocks.js b/remix-simulator/test/blocks.js index c6c6503016..fb048764de 100644 --- a/remix-simulator/test/blocks.js +++ b/remix-simulator/test/blocks.js @@ -1,22 +1,22 @@ /* global describe, before, it */ -var Web3 = require('web3') -var RemixSim = require('../index.js') -let web3 = new Web3() -var assert = require('assert') +const Web3 = require('web3') +const RemixSim = require('../index.js') +const web3 = new Web3() +const assert = require('assert') -describe('blocks', function () { - before(function () { - let provider = new RemixSim.Provider({ +describe('blocks', () => { + before(() => { + const provider = new RemixSim.Provider({ coinbase: '0x0000000000000000000000000000000000000001' }) web3.setProvider(provider) }) describe('eth_getBlockByNumber', () => { - it('should get block given its number', async function () { - let block = await web3.eth.getBlock(0) + it('should get block given its number', async () => { + const block = await web3.eth.getBlock(0) - let expectedBlock = { + const expectedBlock = { difficulty: '69762765929000', extraData: '0x0', gasLimit: 8000000, @@ -42,56 +42,56 @@ describe('blocks', function () { }) describe('eth_getGasPrice', () => { - it('should get gas price', async function () { - let gasPrice = await web3.eth.getGasPrice() + it('should get gas price', async () => { + const gasPrice = await web3.eth.getGasPrice() assert.equal(gasPrice, 1) }) }) describe('eth_coinbase', () => { - it('should get coinbase', async function () { - let coinbase = await web3.eth.getCoinbase() + it('should get coinbase', async () => { + const coinbase = await web3.eth.getCoinbase() assert.equal(coinbase, '0x0000000000000000000000000000000000000001') }) }) describe('eth_blockNumber', () => { - it('should get current block number', async function () { - let number = await web3.eth.getBlockNumber() + it('should get current block number', async () => { + const number = await web3.eth.getBlockNumber() assert.equal(number, 0) }) }) describe('eth_getBlockByHash', () => { - it('should get block given its hash', async function () { - let correctBlock = await web3.eth.getBlock(0) - let block = await web3.eth.getBlock(correctBlock.hash) + it('should get block given its hash', async () => { + const correctBlock = await web3.eth.getBlock(0) + const block = await web3.eth.getBlock(correctBlock.hash) assert.deepEqual(block, correctBlock) }) }) describe('eth_getBlockTransactionCountByHash', () => { - it('should get block given its hash', async function () { - let correctBlock = await web3.eth.getBlock(0) - let numberTransactions = await web3.eth.getBlockTransactionCount(correctBlock.hash) + it('should get block given its hash', async () => { + const correctBlock = await web3.eth.getBlock(0) + const numberTransactions = await web3.eth.getBlockTransactionCount(correctBlock.hash) assert.deepEqual(numberTransactions, 0) }) }) describe('eth_getBlockTransactionCountByNumber', () => { - it('should get block given its hash', async function () { - let numberTransactions = await web3.eth.getBlockTransactionCount(0) + it('should get block given its hash', async () => { + const numberTransactions = await web3.eth.getBlockTransactionCount(0) assert.deepEqual(numberTransactions, 0) }) }) describe('eth_getUncleCountByBlockHash', () => { - it('should get block given its hash', async function () { - let correctBlock = await web3.eth.getBlock(0) - let numberTransactions = await (new Promise((resolve, reject) => { + it('should get block given its hash', async () => { + const correctBlock = await web3.eth.getBlock(0) + const numberTransactions = await (new Promise((resolve, reject) => { web3._requestManager.send({method: 'eth_getUncleCountByBlockHash', params: [correctBlock.hash]}, (err, numberTransactions) => { if (err) return reject(err) resolve(numberTransactions) @@ -102,9 +102,9 @@ describe('blocks', function () { }) describe('eth_getUncleCountByBlockNumber', () => { - it('should get block given its number', async function () { - let correctBlock = await web3.eth.getBlock(0) - let numberTransactions = await (new Promise((resolve, reject) => { + it('should get block given its number', async () => { + const correctBlock = await web3.eth.getBlock(0) + const numberTransactions = await (new Promise((resolve, reject) => { web3._requestManager.send({method: 'eth_getUncleCountByBlockHash', params: [0]}, (err, numberTransactions) => { if (err) return reject(err) resolve(numberTransactions) @@ -115,8 +115,8 @@ describe('blocks', function () { }) describe('eth_getStorageAt', () => { - it('should get storage at position at given address', async function () { - let abi = [ + it('should get storage at position at given address', async () => { + const abi = [ { 'constant': false, 'inputs': [ @@ -198,7 +198,7 @@ describe('blocks', function () { } ] - let code = '0x608060405234801561001057600080fd5b506040516020806102018339810180604052602081101561003057600080fd5b810190808051906020019092919050505080600081905550506101a9806100586000396000f3fe60806040526004361061005c576000357c0100000000000000000000000000000000000000000000000000000000900480632a1afcd91461006157806360fe47b11461008c5780636d4ce63c146100c7578063ce01e1ec146100f2575b600080fd5b34801561006d57600080fd5b5061007661012d565b6040518082815260200191505060405180910390f35b34801561009857600080fd5b506100c5600480360360208110156100af57600080fd5b8101908080359060200190929190505050610133565b005b3480156100d357600080fd5b506100dc61013d565b6040518082815260200191505060405180910390f35b3480156100fe57600080fd5b5061012b6004803603602081101561011557600080fd5b8101908080359060200190929190505050610146565b005b60005481565b8060008190555050565b60008054905090565b80600081905550807f63a242a632efe33c0e210e04e4173612a17efa4f16aa4890bc7e46caece80de060405160405180910390a25056fea165627a7a7230582063160eb16dc361092a85ced1a773eed0b63738b83bea1e1c51cf066fa90e135d0029' + const code = '0x608060405234801561001057600080fd5b506040516020806102018339810180604052602081101561003057600080fd5b810190808051906020019092919050505080600081905550506101a9806100586000396000f3fe60806040526004361061005c576000357c0100000000000000000000000000000000000000000000000000000000900480632a1afcd91461006157806360fe47b11461008c5780636d4ce63c146100c7578063ce01e1ec146100f2575b600080fd5b34801561006d57600080fd5b5061007661012d565b6040518082815260200191505060405180910390f35b34801561009857600080fd5b506100c5600480360360208110156100af57600080fd5b8101908080359060200190929190505050610133565b005b3480156100d357600080fd5b506100dc61013d565b6040518082815260200191505060405180910390f35b3480156100fe57600080fd5b5061012b6004803603602081101561011557600080fd5b8101908080359060200190929190505050610146565b005b60005481565b8060008190555050565b60008054905090565b80600081905550807f63a242a632efe33c0e210e04e4173612a17efa4f16aa4890bc7e46caece80de060405160405180910390a25056fea165627a7a7230582063160eb16dc361092a85ced1a773eed0b63738b83bea1e1c51cf066fa90e135d0029' const contract = new web3.eth.Contract(abi) const accounts = await web3.eth.getAccounts() @@ -222,8 +222,8 @@ describe('blocks', function () { }) describe('eth_call', () => { - it('should get a value', async function () { - let abi = [ + it('should get a value', async () => { + const abi = [ { 'constant': false, 'inputs': [ @@ -305,7 +305,7 @@ describe('blocks', function () { } ] - let code = '0x608060405234801561001057600080fd5b506040516020806102018339810180604052602081101561003057600080fd5b810190808051906020019092919050505080600081905550506101a9806100586000396000f3fe60806040526004361061005c576000357c0100000000000000000000000000000000000000000000000000000000900480632a1afcd91461006157806360fe47b11461008c5780636d4ce63c146100c7578063ce01e1ec146100f2575b600080fd5b34801561006d57600080fd5b5061007661012d565b6040518082815260200191505060405180910390f35b34801561009857600080fd5b506100c5600480360360208110156100af57600080fd5b8101908080359060200190929190505050610133565b005b3480156100d357600080fd5b506100dc61013d565b6040518082815260200191505060405180910390f35b3480156100fe57600080fd5b5061012b6004803603602081101561011557600080fd5b8101908080359060200190929190505050610146565b005b60005481565b8060008190555050565b60008054905090565b80600081905550807f63a242a632efe33c0e210e04e4173612a17efa4f16aa4890bc7e46caece80de060405160405180910390a25056fea165627a7a7230582063160eb16dc361092a85ced1a773eed0b63738b83bea1e1c51cf066fa90e135d0029' + const code = '0x608060405234801561001057600080fd5b506040516020806102018339810180604052602081101561003057600080fd5b810190808051906020019092919050505080600081905550506101a9806100586000396000f3fe60806040526004361061005c576000357c0100000000000000000000000000000000000000000000000000000000900480632a1afcd91461006157806360fe47b11461008c5780636d4ce63c146100c7578063ce01e1ec146100f2575b600080fd5b34801561006d57600080fd5b5061007661012d565b6040518082815260200191505060405180910390f35b34801561009857600080fd5b506100c5600480360360208110156100af57600080fd5b8101908080359060200190929190505050610133565b005b3480156100d357600080fd5b506100dc61013d565b6040518082815260200191505060405180910390f35b3480156100fe57600080fd5b5061012b6004803603602081101561011557600080fd5b8101908080359060200190929190505050610146565b005b60005481565b8060008190555050565b60008054905090565b80600081905550807f63a242a632efe33c0e210e04e4173612a17efa4f16aa4890bc7e46caece80de060405160405180910390a25056fea165627a7a7230582063160eb16dc361092a85ced1a773eed0b63738b83bea1e1c51cf066fa90e135d0029' const contract = new web3.eth.Contract(abi) const accounts = await web3.eth.getAccounts() @@ -314,7 +314,7 @@ describe('blocks', function () { contractInstance.currentProvider = web3.eth.currentProvider contractInstance.givenProvider = web3.eth.currentProvider - let value = await contractInstance.methods.get().call({ from: accounts[0] }) + const value = await contractInstance.methods.get().call({ from: accounts[0] }) assert.deepEqual(value, 100) }) }) diff --git a/remix-simulator/test/misc.js b/remix-simulator/test/misc.js index 69d7320fec..134eb90461 100644 --- a/remix-simulator/test/misc.js +++ b/remix-simulator/test/misc.js @@ -1,22 +1,22 @@ /* global describe, before, it */ -var Web3 = require('web3') -var RemixSim = require('../index.js') -let web3 = new Web3() -var assert = require('assert') +const Web3 = require('web3') +const RemixSim = require('../index.js') +const web3 = new Web3() +const assert = require('assert') -describe('Misc', function () { - before(function () { - let provider = new RemixSim.Provider() +describe('Misc', () => { + before(() => { + const provider = new RemixSim.Provider() web3.setProvider(provider) }) describe('web3_clientVersion', () => { - it('should get correct remix simulator version', async function (done) { + it('should get correct remix simulator version', async (done) => { web3._requestManager.send({ method: 'web3_clientVersion', params: [] }, (err, version) => { if (err) { throw new Error(err) } - let remixVersion = require('../package.json').version + const remixVersion = require('../package.json').version assert.equal(version, 'Remix Simulator/' + remixVersion) done() }) @@ -24,7 +24,7 @@ describe('Misc', function () { }) describe('eth_protocolVersion', () => { - it('should get protocol version', async function () { + it('should get protocol version', async () => { web3._requestManager.send({ method: 'eth_protocolVersion', params: [] }, (err, result) => { if (err) { throw new Error(err) @@ -35,28 +35,28 @@ describe('Misc', function () { }) describe('eth_syncing', () => { - it('should get if is syncing', async function () { - let isSyncing = await web3.eth.isSyncing() + it('should get if is syncing', async () => { + const isSyncing = await web3.eth.isSyncing() assert.equal(isSyncing, false) }) }) describe('eth_mining', () => { - it('should get if is mining', async function () { - let isMining = await web3.eth.isMining() + it('should get if is mining', async () => { + const isMining = await web3.eth.isMining() assert.equal(isMining, false) }) }) describe('eth_hashrate', () => { - it('should get hashrate', async function () { - let hashrate = await web3.eth.getHashrate() + it('should get hashrate', async () => { + const hashrate = await web3.eth.getHashrate() assert.equal(hashrate, 0) }) }) describe('web3_sha3', () => { - it('should get result of a sha3', async function () { + it('should get result of a sha3', async () => { web3._requestManager.send({ method: 'web3_sha3', params: ['0x68656c6c6f20776f726c64'] }, (err, result) => { if (err) { throw new Error(err) @@ -67,7 +67,7 @@ describe('Misc', function () { }) describe('eth_getCompilers', () => { - it('should get list of compilers', async function () { + it('should get list of compilers', async () => { web3._requestManager.send({ method: 'eth_getCompilers', params: [] }, (err, result) => { if (err) { throw new Error(err) @@ -78,7 +78,7 @@ describe('Misc', function () { }) describe('eth_compileSolidity', () => { - it('get unsupported result when requesting solidity compiler', async function () { + it('get unsupported result when requesting solidity compiler', async () => { web3._requestManager.send({ method: 'eth_compileSolidity', params: [] }, (err, result) => { if (err) { throw new Error(err) @@ -89,7 +89,7 @@ describe('Misc', function () { }) describe('eth_compileLLL', () => { - it('get unsupported result when requesting LLL compiler', async function () { + it('get unsupported result when requesting LLL compiler', async () => { web3._requestManager.send({ method: 'eth_compileLLL', params: [] }, (err, result) => { if (err) { throw new Error(err) @@ -100,7 +100,7 @@ describe('Misc', function () { }) describe('eth_compileSerpent', () => { - it('get unsupported result when requesting serpent compiler', async function () { + it('get unsupported result when requesting serpent compiler', async () => { web3._requestManager.send({ method: 'eth_compileSerpent', params: [] }, (err, result) => { if (err) { throw new Error(err)