diff --git a/libs/remix-lib/src/execution/execution-context.ts b/libs/remix-lib/src/execution/execution-context.ts index d8a307141f..cdf78ebcf1 100644 --- a/libs/remix-lib/src/execution/execution-context.ts +++ b/libs/remix-lib/src/execution/execution-context.ts @@ -7,7 +7,7 @@ import { Web3VmProvider } from '../web3Provider/web3VmProvider' const EthJSVM = require('ethereumjs-vm').default const StateManager = require('ethereumjs-vm/dist/state/stateManager').default -const LogsManager = require('./logsManager.js') +import { LogsManager } from './logsManager' declare let ethereum: any let web3 diff --git a/libs/remix-lib/test/eventManager.ts b/libs/remix-lib/test/eventManager.ts index 6ca027b486..3caa7a2e0f 100644 --- a/libs/remix-lib/test/eventManager.ts +++ b/libs/remix-lib/test/eventManager.ts @@ -1,33 +1,33 @@ 'use strict' -const tape = require('tape') -const EventManager = require('../src/eventManager') +import tape from 'tape' +import { EventManager } from '../src/eventManager' tape('eventManager', function (t) { t.test('eventManager', function (st) { const events = new EventManager() const listenner = {} let trace = '' - listenner.listen = function (data1) { + listenner['listen'] = function (data1) { trace += data1 } const registeredFunction = function (data) { trace += data } - events.register('event1', listenner, listenner.listen) - events.register('event2', registeredFunction) + events.register('event1', listenner, listenner['listen']) + events.register('event2', registeredFunction, null) events.trigger('event1', ['event1']) events.trigger('event2', ['event2']) st.equal(trace, 'event1event2') - events.unregister('event1', listenner.listen) + events.unregister('event1', listenner['listen'], null) st.equal(events.registered['event1'].length, 1) st.equal(events.registered['event2'].length, 1) - events.unregister('event1', listenner, listenner.listen) + events.unregister('event1', listenner, listenner['listen']) st.equal(events.registered['event1'].length, 0) st.equal(events.registered['event2'].length, 1) - events.unregister('event2', registeredFunction) + events.unregister('event2', registeredFunction, null) st.equal(events.registered['event1'].length, 0) st.equal(events.registered['event2'].length, 0) st.end() diff --git a/libs/remix-lib/test/tests.ts b/libs/remix-lib/test/tests.ts index 6f8565ebb9..2921875905 100644 --- a/libs/remix-lib/test/tests.ts +++ b/libs/remix-lib/test/tests.ts @@ -1,5 +1,5 @@ -require('./eventManager.js') -require('./util.js') -require('./txFormat.js') -require('./txHelper.js') -require('./txResultHelper.js') +require('./eventManager.ts') +require('./util.ts') +require('./txFormat.ts') +require('./txHelper.ts') +require('./txResultHelper.ts') diff --git a/libs/remix-lib/test/txFormat.ts b/libs/remix-lib/test/txFormat.ts index b29ea2075d..d33760f9f9 100644 --- a/libs/remix-lib/test/txFormat.ts +++ b/libs/remix-lib/test/txFormat.ts @@ -1,11 +1,12 @@ 'use strict' -import * as tape from 'tape' -const txFormat = require('../src/execution/txFormat') -const txHelper = require('../src/execution/txHelper') -const util = require('../src/util') +import tape from 'tape' +import * as txFormat from '../src/execution/txFormat' +import * as txHelper from '../src/execution/txHelper' +import { hexToIntArray } from '../src/util' let compiler = require('solc') -const compilerInput = require('../src/helpers/compilerHelper').compilerInput -const executionContext = require('../').execution.executionContext +import { compilerInput } from '../src/helpers/compilerHelper' +import { ExecutionContext } from '../src/execution/execution-context' +const executionContext = new ExecutionContext() const solidityVersion = 'v0.6.0+commit.26b70077' /* tape *********************************************************** */ @@ -150,7 +151,7 @@ function testInvalidTupleInput (st, params) { /* tape *********************************************************** */ tape('ContractParameters - (TxFormat.buildData) - link Libraries', function (t) { - executionContext.setContext('vm') + executionContext.setContext('vm', null, null, null) const compileData = compiler.compile(compilerInput(deploySimpleLib)) const fakeDeployedContracts = { @@ -293,7 +294,7 @@ tape('test abiEncoderV2', function (t) { console.log(error) st.equal(encoded.dataHex, functionId + encodedData.replace('0x', '')) }) - let decoded = txFormat.decodeResponse(util.hexToIntArray(encodedData), contract.abi[0]) + let decoded = txFormat.decodeResponse(hexToIntArray(encodedData), contract.abi[0]) console.log(decoded) st.equal(decoded[0], `tuple(uint256,uint256,string): ${value1},${value2},${value3}`) }) @@ -314,14 +315,14 @@ tape('test abiEncoderV2 array of tuple', function (t) { const contract = output.contracts['test.sol']['test'] txFormat.encodeParams('[34, "test"]', contract.abi[1], (error, encoded) => { console.log(error) - const decoded = txFormat.decodeResponse(util.hexToIntArray(encoded.dataHex), contract.abi[1]) + const decoded = txFormat.decodeResponse(hexToIntArray(encoded.dataHex), contract.abi[1]) console.log(decoded) st.equal(decoded[0], 'tuple(uint256,string): _strucmts 34,test') }) txFormat.encodeParams('[[34, "test"], [123, "test2"]]', contract.abi[2], (error, encoded) => { console.log(error) - const decoded = txFormat.decodeResponse(util.hexToIntArray(encoded.dataHex), contract.abi[2]) + const decoded = txFormat.decodeResponse(hexToIntArray(encoded.dataHex), contract.abi[2]) console.log(decoded) st.equal(decoded[0], 'tuple(uint256,string)[]: strucmts 34,test,123,test2') }) diff --git a/libs/remix-lib/test/txHelper.ts b/libs/remix-lib/test/txHelper.ts index f46606a275..2532bcd34d 100644 --- a/libs/remix-lib/test/txHelper.ts +++ b/libs/remix-lib/test/txHelper.ts @@ -1,6 +1,6 @@ 'use strict' -const tape = require('tape') -const txHelper = require('../src/execution/txHelper') +import tape from 'tape' +import * as txHelper from '../src/execution/txHelper' tape('getFunction', function (st) { st.plan(6) diff --git a/libs/remix-lib/test/txResultHelper.ts b/libs/remix-lib/test/txResultHelper.ts index 21e04c4a4f..8fa2e5cdf2 100644 --- a/libs/remix-lib/test/txResultHelper.ts +++ b/libs/remix-lib/test/txResultHelper.ts @@ -1,9 +1,8 @@ 'use strict' -const tape = require('tape') -const { BN, toBuffer } = require('ethereumjs-util') - -const { resultToRemixTx } = require('../src/helpers/txResultHelper') +import tape from 'tape' +import { BN, toBuffer } from 'ethereumjs-util' +import { resultToRemixTx } from '../src/helpers/txResultHelper' const TRANSACTION_HASH = '0x538ad944d09c2df403f064c1e4556fae877fe3f1b600c567622e330c2bdbbe2e' const CONTRACT_ADDRESS_HEX = '0x692a70d2e424a56d2c6c27aa97d1a86395877b3a' diff --git a/libs/remix-lib/test/util.ts b/libs/remix-lib/test/util.ts index b7116cf9d1..23af34b9cd 100644 --- a/libs/remix-lib/test/util.ts +++ b/libs/remix-lib/test/util.ts @@ -1,6 +1,6 @@ 'use strict' -const tape = require('tape') -const util = require('../src/util') +import tape from 'tape' +import * as util from '../src/util' tape('Util', function (t) { t.test('lowerbound', function (st) { diff --git a/libs/remix-lib/tsconfig.lib.json b/libs/remix-lib/tsconfig.lib.json index 8bd00f9004..0bfa34a172 100644 --- a/libs/remix-lib/tsconfig.lib.json +++ b/libs/remix-lib/tsconfig.lib.json @@ -1,16 +1,16 @@ { - "extends": "../../tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "../../dist/out-tsc", - "declaration": true, - "rootDir": "./", - "types": ["node", "tape"] - }, - "exclude": [ - "**/*.spec.js", - "test/" - ], - "include": ["**/*.ts"] - } + "extends": "../../tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../dist/out-tsc", + "declaration": true, + "rootDir": "./", + "types": ["node", "tape"] + }, + "exclude": [ + "**/*.spec.js", + "test/" + ], + "include": ["**/*.ts"] +} \ No newline at end of file diff --git a/workspace.json b/workspace.json index f8fb4de1c9..73527185b5 100644 --- a/workspace.json +++ b/workspace.json @@ -128,7 +128,7 @@ "test": { "builder": "@nrwl/workspace:run-commands", "options": { - "commands": ["npm-run-all test"], + "commands": ["./../../node_modules/.bin/npm-run-all test"], "cwd": "libs/remix-analyzer" } }, @@ -162,7 +162,7 @@ "test": { "builder": "@nrwl/workspace:run-commands", "options": { - "commands": ["npm-run-all test"], + "commands": ["./../../node_modules/.bin/npm-run-all test"], "cwd": "libs/remix-astwalker" } }, @@ -196,7 +196,7 @@ "test": { "builder": "@nrwl/workspace:run-commands", "options": { - "commands": ["npm-run-all test"], + "commands": ["./../../node_modules/.bin/npm-run-all test"], "cwd": "libs/remix-debug" } }, @@ -241,7 +241,7 @@ "test": { "builder": "@nrwl/workspace:run-commands", "options": { - "commands": ["npm-run-all test"], + "commands": ["./../../node_modules/.bin/npm-run-all test"], "cwd": "libs/remix-lib" } }, @@ -275,7 +275,7 @@ "test": { "builder": "@nrwl/workspace:run-commands", "options": { - "commands": ["npm-run-all test"], + "commands": ["./../../node_modules/.bin/npm-run-all test"], "cwd": "libs/remix-simulator" } }, @@ -320,7 +320,7 @@ "test": { "builder": "@nrwl/workspace:run-commands", "options": { - "commands": ["npm-run-all test"], + "commands": ["./../../node_modules/.bin/npm-run-all test"], "cwd": "libs/remix-solidity" } }, @@ -402,7 +402,7 @@ "test": { "builder": "@nrwl/workspace:run-commands", "options": { - "commands": ["npm-run-all test"], + "commands": ["./../../node_modules/.bin/npm-run-all test"], "cwd": "libs/remix-url-resolver" } },