diff --git a/.travis.yml b/.travis.yml index 4c420f1a91..10e4063641 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,16 @@ language: node_js node_js: - stable +env: + - TEST_DIR=remix-core + - TEST_DIR=remix-lib + - TEST_DIR=remix-solidity + - TEST_DIR=remix-debugger script: - - npm run test - - ./ci/browser_tests.sh + - cd $TEST_DIR && npm install && npm test deploy: provider: script - script: ci/deploy_from_travis.sh + script: remix-debugger/ci/deploy_from_travis.sh skip_cleanup: true on: branch: master diff --git a/remix-core/index.js b/remix-core/index.js new file mode 100644 index 0000000000..c1319856c5 --- /dev/null +++ b/remix-core/index.js @@ -0,0 +1,20 @@ +var CodeManager = require('./src/code/codeManager') +var StorageViewer = require('./src/storage/storageViewer') +var StorageResolver = require('./src/storage/storageResolver') +var TraceManager = require('./src/trace/traceManager') + +module.exports = { + global: { + web3: null + }, + code: { + CodeManager: CodeManager + }, + storage: { + StorageViewer: StorageViewer, + StorageResolver: StorageResolver + }, + trace: { + TraceManager: TraceManager + } +} diff --git a/remix-core/package.json b/remix-core/package.json new file mode 100644 index 0000000000..23a4273910 --- /dev/null +++ b/remix-core/package.json @@ -0,0 +1,81 @@ +{ + "name": "remix-core", + "version": "0.0.2", + "description": "Ethereum IDE and tools for the web", + "contributors": [ + { + "name": "Yann Levreau", + "email": "yann@ethereum.com" + }, + { + "name": "Liana Husikyan", + "email": "liana@ethereum.com" + } + ], + "main": "./index.js", + "dependencies": { + "babel-preset-es2015": "^6.24.0", + "babel-plugin-transform-object-assign": "^6.22.0", + "babel-eslint": "^7.1.1", + "babelify": "^7.3.0", + "fast-async": "^6.1.2", + "npm-link-local": "^1.1.0", + "remix-lib": "^0.0.1", + "standard": "^7.0.1", + "tape": "^4.6.0" + }, + "scripts": { + "postinstall": "npm-link-local ../remix-lib", + "test": "standard && tape ./test/tests.js" + }, + "standard": { + "ignore": [ + "node_modules/*", + "build/*", + "test/resources/*" + ], + "parser": "babel-eslint" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ethereum/remix.git" + }, + "author": "cpp-ethereum team", + "license": "MIT", + "bugs": { + "url": "https://github.com/ethereum/remix/issues" + }, + "homepage": "https://github.com/ethereum/remix#readme", + "browserify": { + "transform": [ + [ + "babelify", + { + "plugins": [ + [ + "fast-async", + { + "runtimePatten": null, + "compiler": { + "promises": true, + "es7": true, + "noRuntime": true, + "wrapAwait": true + } + } + ], + "transform-object-assign" + ] + } + ], + [ + "babelify", + { + "presets": [ + "es2015" + ] + } + ] + ] + } +} diff --git a/src/code/breakpointManager.js b/remix-core/src/code/breakpointManager.js similarity index 98% rename from src/code/breakpointManager.js rename to remix-core/src/code/breakpointManager.js index 77526fbc5d..26949da056 100644 --- a/src/code/breakpointManager.js +++ b/remix-core/src/code/breakpointManager.js @@ -1,6 +1,7 @@ 'use strict' -var EventManager = require('../lib/eventManager') -var helper = require('../helpers/traceHelper') +var remixLib = require('remix-lib') +var EventManager = remixLib.EventManager +var helper = remixLib.helpers.trace /** * allow to manage breakpoint diff --git a/src/code/codeManager.js b/remix-core/src/code/codeManager.js similarity index 96% rename from src/code/codeManager.js rename to remix-core/src/code/codeManager.js index ddfd8a6813..fb5256b442 100644 --- a/src/code/codeManager.js +++ b/remix-core/src/code/codeManager.js @@ -1,8 +1,9 @@ 'use strict' -var traceHelper = require('../helpers/traceHelper') +var remixLib = require('remix-lib') +var EventManager = remixLib.EventManager +var traceHelper = remixLib.helpers.trace +var SourceMappingDecoder = remixLib.SourceMappingDecoder var codeResolver = require('./codeResolver') -var EventManager = require('../lib/eventManager') -var SourceMappingDecoder = require('../util/sourceMappingDecoder') /* resolve contract code referenced by vmtrace in order to be used by asm listview. diff --git a/src/code/codeResolver.js b/remix-core/src/code/codeResolver.js similarity index 93% rename from src/code/codeResolver.js rename to remix-core/src/code/codeResolver.js index 66356c2193..5a72b7fad6 100644 --- a/src/code/codeResolver.js +++ b/remix-core/src/code/codeResolver.js @@ -1,6 +1,7 @@ 'use strict' var codeUtils = require('./codeUtils') -var util = require('../helpers/global') +var remixLib = require('remix-lib') +var global = remixLib.global module.exports = { bytecodeByAddress: {}, // bytes code by contract addesses @@ -28,7 +29,7 @@ module.exports = { loadCode: function (address, callback) { console.log('loading new code from web3 ' + address) - util.web3.eth.getCode(address, function (error, result) { + global.web3.eth.getCode(address, function (error, result) { if (error) { console.log(error) } else { diff --git a/src/code/codeUtils.js b/remix-core/src/code/codeUtils.js similarity index 100% rename from src/code/codeUtils.js rename to remix-core/src/code/codeUtils.js diff --git a/src/code/disassembler.js b/remix-core/src/code/disassembler.js similarity index 96% rename from src/code/disassembler.js rename to remix-core/src/code/disassembler.js index 60ce1f40a3..69c6082c65 100644 --- a/src/code/disassembler.js +++ b/remix-core/src/code/disassembler.js @@ -1,7 +1,8 @@ 'use strict' var parseCode = require('./codeUtils').parseCode -var util = require('../helpers/util') +var remixLib = require('remix-lib') +var util = remixLib.util var createExpressions = function (instructions) { var expressions = [] diff --git a/src/code/opcodes.js b/remix-core/src/code/opcodes.js similarity index 100% rename from src/code/opcodes.js rename to remix-core/src/code/opcodes.js diff --git a/src/storage/mappingPreimages.js b/remix-core/src/storage/mappingPreimages.js similarity index 96% rename from src/storage/mappingPreimages.js rename to remix-core/src/storage/mappingPreimages.js index d9a5416406..b55b5f4cc2 100644 --- a/src/storage/mappingPreimages.js +++ b/remix-core/src/storage/mappingPreimages.js @@ -1,4 +1,5 @@ -var global = require('../helpers/global') +var remixLib = require('remix-lib') +var global = remixLib.global module.exports = { decodeMappingsKeys: decodeMappingsKeys diff --git a/src/storage/storageResolver.js b/remix-core/src/storage/storageResolver.js similarity index 97% rename from src/storage/storageResolver.js rename to remix-core/src/storage/storageResolver.js index 3ad236c0a0..9f0bb5b8bc 100644 --- a/src/storage/storageResolver.js +++ b/remix-core/src/storage/storageResolver.js @@ -1,6 +1,7 @@ 'use strict' -var traceHelper = require('../helpers/traceHelper') -var util = require('../helpers/global') +var remixLib = require('remix-lib') +var traceHelper = remixLib.helpers.trace +var global = remixLib.global var mappingPreimages = require('./mappingPreimages') /** @@ -145,7 +146,7 @@ function storageRangeWeb3Call (tx, address, start, maxSize, callback) { if (traceHelper.isContractCreation(address)) { callback(null, {}, null) } else { - util.web3.debug.storageRangeAt( + global.web3.debug.storageRangeAt( tx.blockHash, tx.transactionIndex === undefined ? tx.hash : tx.transactionIndex, address, start, diff --git a/src/storage/storageViewer.js b/remix-core/src/storage/storageViewer.js similarity index 97% rename from src/storage/storageViewer.js rename to remix-core/src/storage/storageViewer.js index aa50b9d93f..eee40708eb 100644 --- a/src/storage/storageViewer.js +++ b/remix-core/src/storage/storageViewer.js @@ -1,5 +1,6 @@ 'use strict' -var helper = require('../helpers/util') +var remixLib = require('remix-lib') +var util = remixLib.util var mappingPreimages = require('./mappingPreimages') /** @@ -44,7 +45,7 @@ class StorageViewer { * @param {Function} - callback - {key, hashedKey, value} - */ storageSlot (slot, callback) { - var hashed = helper.sha3_256(slot) + var hashed = util.sha3_256(slot) if (this.storageChanges[hashed]) { return callback(null, this.storageChanges[hashed]) } diff --git a/src/trace/traceAnalyser.js b/remix-core/src/trace/traceAnalyser.js similarity index 98% rename from src/trace/traceAnalyser.js rename to remix-core/src/trace/traceAnalyser.js index 66aefa2c51..240e1ee3dd 100644 --- a/src/trace/traceAnalyser.js +++ b/remix-core/src/trace/traceAnalyser.js @@ -1,5 +1,6 @@ 'use strict' -var traceHelper = require('../helpers/traceHelper') +var remixLib = require('remix-lib') +var traceHelper = remixLib.helpers.trace function TraceAnalyser (_cache) { this.traceCache = _cache diff --git a/src/trace/traceCache.js b/remix-core/src/trace/traceCache.js similarity index 98% rename from src/trace/traceCache.js rename to remix-core/src/trace/traceCache.js index 71f14be8ee..6dc98a16b2 100644 --- a/src/trace/traceCache.js +++ b/remix-core/src/trace/traceCache.js @@ -1,5 +1,6 @@ 'use strict' -var helper = require('../helpers/util') +var remixLib = require('remix-lib') +var helper = remixLib.util function TraceCache () { this.init() diff --git a/src/trace/traceManager.js b/remix-core/src/trace/traceManager.js similarity index 97% rename from src/trace/traceManager.js rename to remix-core/src/trace/traceManager.js index f2f050e58a..d9eefd688f 100644 --- a/src/trace/traceManager.js +++ b/remix-core/src/trace/traceManager.js @@ -3,9 +3,10 @@ var TraceAnalyser = require('./traceAnalyser') var TraceRetriever = require('./traceRetriever') var TraceCache = require('./traceCache') var TraceStepManager = require('./traceStepManager') -var traceHelper = require('../helpers/traceHelper') -var util = require('../helpers/util') -var globalUtil = require('../helpers/global') +var remixLib = require('remix-lib') +var traceHelper = remixLib.helpers.trace +var util = remixLib.util +var global = remixLib.global function TraceManager () { this.isLoading = false @@ -21,7 +22,7 @@ function TraceManager () { TraceManager.prototype.resolveTrace = function (tx, callback) { this.tx = tx this.init() - if (!globalUtil.web3) callback('web3 not loaded', false) + if (!global.web3) callback('web3 not loaded', false) this.isLoading = true var self = this this.traceRetriever.getTrace(tx.hash, function (error, result) { diff --git a/src/trace/traceRetriever.js b/remix-core/src/trace/traceRetriever.js similarity index 67% rename from src/trace/traceRetriever.js rename to remix-core/src/trace/traceRetriever.js index 20bf528af3..4c2fb38101 100644 --- a/src/trace/traceRetriever.js +++ b/remix-core/src/trace/traceRetriever.js @@ -1,5 +1,6 @@ 'use strict' -var util = require('../helpers/global') +var remixLib = require('remix-lib') +var global = remixLib.global function TraceRetriever () { } @@ -11,7 +12,7 @@ TraceRetriever.prototype.getTrace = function (txHash, callback) { disableStack: false, fullStorage: false } - util.web3.debug.traceTransaction(txHash, options, function (error, result) { + global.web3.debug.traceTransaction(txHash, options, function (error, result) { callback(error, result) }) } diff --git a/src/trace/traceStepManager.js b/remix-core/src/trace/traceStepManager.js similarity index 94% rename from src/trace/traceStepManager.js rename to remix-core/src/trace/traceStepManager.js index 8b77c12a30..5b4f50a625 100644 --- a/src/trace/traceStepManager.js +++ b/remix-core/src/trace/traceStepManager.js @@ -1,6 +1,7 @@ 'use strict' -var traceHelper = require('../helpers/traceHelper') -var util = require('../helpers/util') +var remixLib = require('remix-lib') +var traceHelper = remixLib.helpers.trace +var util = remixLib.util function TraceStepManager (_traceAnalyser) { this.traceAnalyser = _traceAnalyser diff --git a/test/codeManager.js b/remix-core/test/codeManager.js similarity index 86% rename from test/codeManager.js rename to remix-core/test/codeManager.js index 948e6d3d88..5795bfaf33 100644 --- a/test/codeManager.js +++ b/remix-core/test/codeManager.js @@ -1,10 +1,11 @@ 'use strict' var tape = require('tape') -var Web3Providers = require('../src/web3Provider/web3Providers') +var remixLib = require('remix-lib') +var Web3Providers = remixLib.vm.Web3Providers var TraceManager = require('../src/trace/traceManager') var CodeManager = require('../src/code/codeManager') var web3Test = require('./resources/testWeb3') -var util = require('../src/helpers/global') +var global = remixLib.global tape('CodeManager', function (t) { var codeManager @@ -16,12 +17,12 @@ tape('CodeManager', function (t) { console.log(mes) t.fail(mes) } else { - util.web3 = obj + global.web3 = obj var traceManager = new TraceManager() codeManager = new CodeManager(traceManager) - var contractCode = util.web3.eth.getCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5') + var contractCode = global.web3.eth.getCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5') codeManager.codeResolver.cacheExecutingCode('0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5', contractCode) // so a call to web3 is not necessary - var tx = util.web3.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51') + var tx = global.web3.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51') traceManager.resolveTrace(tx, function (error, result) { if (error) { t.fail(' - traceManager.resolveTrace - failed ' + result) @@ -62,7 +63,7 @@ function continueTesting (t, codeManager) { } } }) - var tx = util.web3.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51') + var tx = global.web3.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51') codeManager.resolveStep(0, tx) codeManager.resolveStep(70, tx) }) diff --git a/test/disassembler.js b/remix-core/test/disassembler.js similarity index 100% rename from test/disassembler.js rename to remix-core/test/disassembler.js diff --git a/test/init.js b/remix-core/test/init.js similarity index 100% rename from test/init.js rename to remix-core/test/init.js diff --git a/test/resources/testWeb3.js b/remix-core/test/resources/testWeb3.js similarity index 98% rename from test/resources/testWeb3.js rename to remix-core/test/resources/testWeb3.js index 2a31fc2de9..a138a81eb4 100644 --- a/test/resources/testWeb3.js +++ b/remix-core/test/resources/testWeb3.js @@ -4,7 +4,7 @@ var web3Override = {} web3Override.eth = {} web3Override.debug = {} var data = init.readFile(require('path').resolve(__dirname, 'testWeb3.json')) -var data = JSON.parse(data) +data = JSON.parse(data) web3Override.eth.getCode = function (address, callback) { if (callback) { diff --git a/test/resources/testWeb3.json b/remix-core/test/resources/testWeb3.json similarity index 100% rename from test/resources/testWeb3.json rename to remix-core/test/resources/testWeb3.json diff --git a/remix-core/test/tests.js b/remix-core/test/tests.js new file mode 100644 index 0000000000..28f85278c9 --- /dev/null +++ b/remix-core/test/tests.js @@ -0,0 +1,3 @@ +require('./traceManager.js') +require('./codeManager.js') +require('./disassembler.js') diff --git a/test/traceManager.js b/remix-core/test/traceManager.js similarity index 97% rename from test/traceManager.js rename to remix-core/test/traceManager.js index cd801ba499..eddbd5b399 100644 --- a/test/traceManager.js +++ b/remix-core/test/traceManager.js @@ -1,8 +1,9 @@ 'use strict' var TraceManager = require('../src/trace/traceManager') var tape = require('tape') -var Web3Providers = require('../src/web3Provider/web3Providers') -var util = require('../src/helpers/global') +var remixLib = require('remix-lib') +var Web3Providers = remixLib.vm.Web3Providers +var global = remixLib.global var web3Test = require('./resources/testWeb3') tape('TraceManager', function (t) { @@ -17,7 +18,7 @@ tape('TraceManager', function (t) { console.log(mes) st.fail(mes) } else { - util.web3 = obj + global.web3 = obj traceManager = new TraceManager() st.end() } @@ -25,7 +26,7 @@ tape('TraceManager', function (t) { }) t.test('TraceManager.resolveTrace', function (st) { - var tx = util.web3.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51') + var tx = global.web3.eth.getTransaction('0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51') traceManager.resolveTrace(tx, function (error, result) { if (error) { st.fail(' - traceManager.resolveTrace - failed ' + result) diff --git a/assets/css/font-awesome.min.css b/remix-debugger/assets/css/font-awesome.min.css similarity index 100% rename from assets/css/font-awesome.min.css rename to remix-debugger/assets/css/font-awesome.min.css diff --git a/assets/fonts/FontAwesome.otf b/remix-debugger/assets/fonts/FontAwesome.otf similarity index 100% rename from assets/fonts/FontAwesome.otf rename to remix-debugger/assets/fonts/FontAwesome.otf diff --git a/assets/fonts/fontawesome-webfont.eot b/remix-debugger/assets/fonts/fontawesome-webfont.eot similarity index 100% rename from assets/fonts/fontawesome-webfont.eot rename to remix-debugger/assets/fonts/fontawesome-webfont.eot diff --git a/assets/fonts/fontawesome-webfont.svg b/remix-debugger/assets/fonts/fontawesome-webfont.svg similarity index 100% rename from assets/fonts/fontawesome-webfont.svg rename to remix-debugger/assets/fonts/fontawesome-webfont.svg diff --git a/assets/fonts/fontawesome-webfont.ttf b/remix-debugger/assets/fonts/fontawesome-webfont.ttf similarity index 100% rename from assets/fonts/fontawesome-webfont.ttf rename to remix-debugger/assets/fonts/fontawesome-webfont.ttf diff --git a/assets/fonts/fontawesome-webfont.woff b/remix-debugger/assets/fonts/fontawesome-webfont.woff similarity index 100% rename from assets/fonts/fontawesome-webfont.woff rename to remix-debugger/assets/fonts/fontawesome-webfont.woff diff --git a/assets/fonts/fontawesome-webfont.woff2 b/remix-debugger/assets/fonts/fontawesome-webfont.woff2 similarity index 100% rename from assets/fonts/fontawesome-webfont.woff2 rename to remix-debugger/assets/fonts/fontawesome-webfont.woff2 diff --git a/ci/browser_tests.sh b/remix-debugger/ci/browser_tests.sh similarity index 100% rename from ci/browser_tests.sh rename to remix-debugger/ci/browser_tests.sh diff --git a/ci/deploy_from_travis.sh b/remix-debugger/ci/deploy_from_travis.sh similarity index 100% rename from ci/deploy_from_travis.sh rename to remix-debugger/ci/deploy_from_travis.sh diff --git a/ci/deploy_key.enc b/remix-debugger/ci/deploy_key.enc similarity index 100% rename from ci/deploy_key.enc rename to remix-debugger/ci/deploy_key.enc diff --git a/ci/sauceDisconnect.js b/remix-debugger/ci/sauceDisconnect.js similarity index 100% rename from ci/sauceDisconnect.js rename to remix-debugger/ci/sauceDisconnect.js diff --git a/findClient.js b/remix-debugger/findClient.js similarity index 100% rename from findClient.js rename to remix-debugger/findClient.js diff --git a/index.html b/remix-debugger/index.html similarity index 100% rename from index.html rename to remix-debugger/index.html diff --git a/remix-debugger/index.js b/remix-debugger/index.js new file mode 100644 index 0000000000..9dcb27a11e --- /dev/null +++ b/remix-debugger/index.js @@ -0,0 +1,26 @@ +'use strict' +var VMDebugger = require('./src/ui/VmDebugger') +var Debugger = require('./src/ui/Ethdebugger') +var BasicPanel = require('./src/ui/BasicPanel') +var TreeView = require('./src/ui/TreeView') +var styleGuide = require('./src/ui/styles/style-guide') + +if (typeof (module) !== 'undefined' && typeof (module.exports) !== 'undefined') { + module.exports = modules() +} + +if (typeof (window) !== 'undefined') { + window.remix = modules() +} + +function modules () { + return { + ui: { + Debugger: Debugger, + VMdebugger: VMDebugger, + BasicPanel: BasicPanel, + TreeView: TreeView, + styleGuide: styleGuide + } + } +} diff --git a/nightwatch.js b/remix-debugger/nightwatch.js similarity index 96% rename from nightwatch.js rename to remix-debugger/nightwatch.js index 2b02d9e989..259ba280bc 100644 --- a/nightwatch.js +++ b/remix-debugger/nightwatch.js @@ -2,8 +2,8 @@ var TRAVIS_JOB_NUMBER = process.env.TRAVIS_JOB_NUMBER module.exports = { - 'src_folders': ['./test-browser'], - 'output_folder': './test-browser/reports', + 'src_folders': ['./test-browser/test'], + 'output_folder': './test-browser/test/reports', 'custom_commands_path': '', 'custom_assertions_path': '', 'globals_path': '', diff --git a/package.json b/remix-debugger/package.json similarity index 86% rename from package.json rename to remix-debugger/package.json index d3315eed4f..29826fabf0 100644 --- a/package.json +++ b/remix-debugger/package.json @@ -1,6 +1,6 @@ { - "name": "ethereum-remix", - "version": "0.0.4", + "name": "remix-debugger", + "version": "0.0.2", "description": "Ethereum IDE and tools for the web", "contributors": [ { @@ -12,17 +12,19 @@ "email": "liana@ethdev.com" } ], - "main": "./src/index.js", - "dependencies": { - "which": "^1.2.10" - }, + "main": "./index.js", "devDependencies": { + "csjs-inject": "^1.0.1", + "yo-yo": "^1.2.1", + "yo-yoify": "^3.1.0", + "remix-lib": "^0.0.1", + "remix-core": "^0.0.1", + "remix-solidity": "^0.0.1", "babel-eslint": "^7.1.1", "babel-preset-es2015": "^6.24.0", "babel-plugin-transform-object-assign": "^6.22.0", "babelify": "^7.3.0", "browserify": "^13.0.1", - "csjs-inject": "^1.0.1", "ethereum-common": "0.0.18", "ethereumjs-block": "^1.2.2", "ethereumjs-tx": "^1.1.1", @@ -31,17 +33,17 @@ "fast-async": "^6.1.2", "http-server": "^0.9.0", "nightwatch": "^0.9.5", + "npm-link-local": "^1.1.0", "selenium-standalone": "^6.0.1", "solc": "^0.4.13", "standard": "^7.0.1", "standard-reporter": "^1.0.5", "tape": "^4.6.0", - "web3": "^0.15.3", - "yo-yo": "^1.2.1", - "yo-yoify": "^3.1.0" + "web3": "^0.15.3" }, "scripts": { - "build": "mkdirp build; browserify src/index.js > build/app.js", + "postinstall": "npm-link-local ../remix-lib && npm-link-local ../remix-core && npm-link-local ../remix-solidity", + "build": "mkdirp build; browserify index.js > build/app.js", "lint": "standard | notify-error", "nightwatch_local": "nightwatch --config nightwatch.js --env local", "nightwatch_remote_chrome": "nightwatch --config nightwatch.js --env chrome", @@ -50,7 +52,6 @@ "nightwatch_remote_parallel": "nightwatch --config nightwatch.js --env ie,safari,chrome,default", "nightwatch_remote_safari": "nightwatch --config nightwatch.js --env safari", "onchange": "onchange build/app.js -- npm run lint", - "prepublish": "npm run build", "selenium": "selenium-standalone start", "selenium-install": "selenium-standalone install", "serve": "http-server .", @@ -58,7 +59,7 @@ "start_dev": "npm-run-all -lpr serve watch onchange", "start_eth": "npm run warning_message; eth -j --rpccorsdomain '*'", "start_geth": "npm run warning_message; geth --rpc --rpcapi 'web3,eth,debug' --rpcport 8545 --rpccorsdomain '*'", - "test": "standard && tape ./test/tests.js", + "test": "standard && tape ./test/tests.js && ./ci/browser_tests.sh", "test-browser": "npm-run-all -lpr selenium serve waittest", "waittest": "sleep 5 && npm run nightwatch_local", "warning_message": "echo 'DO NOT DO THIS IF eth/geth STORES PRIVATE KEYS!! External system might be able to access your node through the RPC server.\n\n';", @@ -79,8 +80,7 @@ "node_modules/*", "build/*", "test/resources/*" - ], - "parser": "babel-eslint" + ] }, "browserify": { "transform": [ @@ -118,3 +118,4 @@ ] } } + diff --git a/runNode.sh b/remix-debugger/runNode.sh similarity index 100% rename from runNode.sh rename to remix-debugger/runNode.sh diff --git a/src/ui/BasicPanel.js b/remix-debugger/src/ui/BasicPanel.js similarity index 94% rename from src/ui/BasicPanel.js rename to remix-debugger/src/ui/BasicPanel.js index ac3562b9fd..6efed6231c 100644 --- a/src/ui/BasicPanel.js +++ b/remix-debugger/src/ui/BasicPanel.js @@ -1,7 +1,8 @@ 'use strict' var style = require('./styles/basicStyles') var yo = require('yo-yo') -var ui = require('../helpers/ui') +var remixLib = require('remix-lib') +var ui = remixLib.helpers.ui var csjs = require('csjs-inject') diff --git a/src/ui/ButtonNavigator.js b/remix-debugger/src/ui/ButtonNavigator.js similarity index 98% rename from src/ui/ButtonNavigator.js rename to remix-debugger/src/ui/ButtonNavigator.js index 80c1ec562d..b6f8140c93 100644 --- a/src/ui/ButtonNavigator.js +++ b/remix-debugger/src/ui/ButtonNavigator.js @@ -1,5 +1,6 @@ 'use strict' -var EventManager = require('../lib/eventManager') +var remixLib = require('remix-lib') +var EventManager = remixLib.EventManager var yo = require('yo-yo') var csjs = require('csjs-inject') diff --git a/src/ui/CalldataPanel.js b/remix-debugger/src/ui/CalldataPanel.js similarity index 100% rename from src/ui/CalldataPanel.js rename to remix-debugger/src/ui/CalldataPanel.js diff --git a/src/ui/CallstackPanel.js b/remix-debugger/src/ui/CallstackPanel.js similarity index 100% rename from src/ui/CallstackPanel.js rename to remix-debugger/src/ui/CallstackPanel.js diff --git a/src/ui/CodeListView.js b/remix-debugger/src/ui/CodeListView.js similarity index 96% rename from src/ui/CodeListView.js rename to remix-debugger/src/ui/CodeListView.js index 6130c2e5b4..88690c7a3d 100644 --- a/src/ui/CodeListView.js +++ b/remix-debugger/src/ui/CodeListView.js @@ -1,9 +1,10 @@ 'use strict' var style = require('./styles/basicStyles') var yo = require('yo-yo') -var ui = require('../helpers/ui') +var remixLib = require('remix-lib') +var ui = remixLib.helpers.ui var DropdownPanel = require('./DropdownPanel') -var EventManager = require('../lib/eventManager') +var EventManager = remixLib.EventManager var csjs = require('csjs-inject') var styleGuide = require('./styles/style-guide') var styles = styleGuide() diff --git a/src/ui/DropdownPanel.js b/remix-debugger/src/ui/DropdownPanel.js similarity index 98% rename from src/ui/DropdownPanel.js rename to remix-debugger/src/ui/DropdownPanel.js index f1328f1aca..8c3161b630 100644 --- a/src/ui/DropdownPanel.js +++ b/remix-debugger/src/ui/DropdownPanel.js @@ -1,9 +1,10 @@ 'use strict' var yo = require('yo-yo') -var ui = require('../helpers/ui') +var remixLib = require('remix-lib') +var ui = remixLib.helpers.ui var styleDropdown = require('./styles/dropdownPanel') var TreeView = require('./TreeView') -var EventManager = require('../lib/eventManager') +var EventManager = remixLib.EventManager var csjs = require('csjs-inject') var styleGuide = require('./styles/style-guide') diff --git a/src/ui/Ethdebugger.js b/remix-debugger/src/ui/Ethdebugger.js similarity index 89% rename from src/ui/Ethdebugger.js rename to remix-debugger/src/ui/Ethdebugger.js index c99d3bd2fe..73450e5609 100644 --- a/src/ui/Ethdebugger.js +++ b/remix-debugger/src/ui/Ethdebugger.js @@ -1,18 +1,21 @@ 'use strict' var TxBrowser = require('./TxBrowser') var StepManager = require('./StepManager') -var TraceManager = require('../trace/traceManager') +var remixCore = require('remix-core') +var TraceManager = remixCore.trace.TraceManager var VmDebugger = require('./VmDebugger') var style = require('./styles/basicStyles') -var util = require('../helpers/global') -var EventManager = require('../lib/eventManager') +var remixLib = require('remix-lib') +var global = remixLib.global +var EventManager = remixLib.EventManager var yo = require('yo-yo') -var ui = require('../helpers/ui') -var Web3Providers = require('../web3Provider/web3Providers') -var DummyProvider = require('../web3Provider/dummyProvider') -var CodeManager = require('../code/codeManager') -var SolidityProxy = require('../solidity/solidityProxy') -var InternalCallTree = require('../util/internalCallTree') +var ui = remixLib.helpers.ui +var Web3Providers = remixLib.vm.Web3Providers +var DummyProvider = remixLib.vm.DummyProvider +var CodeManager = remixCore.code.CodeManager +var remixSolidity = require('remix-solidity') +var SolidityProxy = remixSolidity.SolidityProxy +var InternalCallTree = remixSolidity.InternalCallTree function Ethdebugger () { var self = this @@ -67,7 +70,7 @@ Ethdebugger.prototype.setBreakpointManager = function (breakpointManager) { } Ethdebugger.prototype.web3 = function () { - return util.web3 + return global.web3 } Ethdebugger.prototype.addProvider = function (type, obj) { @@ -81,7 +84,7 @@ Ethdebugger.prototype.switchProvider = function (type) { if (error) { console.log('provider ' + type + ' not defined') } else { - util.web3 = obj + global.web3 = obj self.event.trigger('providerChanged', [type]) } }) diff --git a/src/ui/FullStoragesChanges.js b/remix-debugger/src/ui/FullStoragesChanges.js similarity index 95% rename from src/ui/FullStoragesChanges.js rename to remix-debugger/src/ui/FullStoragesChanges.js index 9c965f146c..ef454851c2 100644 --- a/src/ui/FullStoragesChanges.js +++ b/remix-debugger/src/ui/FullStoragesChanges.js @@ -1,6 +1,7 @@ 'use strict' var DropdownPanel = require('./DropdownPanel') -var StorageViewer = require('../storage/storageViewer') +var remixCore = require('remix-core') +var StorageViewer = remixCore.storage.StorageViewer var yo = require('yo-yo') function FullStoragesChanges (_parent, _traceManager) { diff --git a/src/ui/MemoryPanel.js b/remix-debugger/src/ui/MemoryPanel.js similarity index 88% rename from src/ui/MemoryPanel.js rename to remix-debugger/src/ui/MemoryPanel.js index b48b59d49b..c37cf48b2c 100644 --- a/src/ui/MemoryPanel.js +++ b/remix-debugger/src/ui/MemoryPanel.js @@ -1,6 +1,7 @@ 'use strict' var DropdownPanel = require('./DropdownPanel') -var util = require('../helpers/ui') +var remixLib = require('remix-lib') +var ui = remixLib.helpers.ui var yo = require('yo-yo') function MemoryPanel (_parent, _traceManager) { @@ -29,7 +30,7 @@ MemoryPanel.prototype.init = function () { console.log(error) self.basicPanel.update({}) } else if (self.parent.currentStepIndex === index) { - self.basicPanel.update(util.formatMemory(memory, 16)) + self.basicPanel.update(ui.formatMemory(memory, 16)) } }) }) diff --git a/src/ui/Slider.js b/remix-debugger/src/ui/Slider.js similarity index 94% rename from src/ui/Slider.js rename to remix-debugger/src/ui/Slider.js index cd2e9f1606..4491de82a2 100644 --- a/src/ui/Slider.js +++ b/remix-debugger/src/ui/Slider.js @@ -1,8 +1,9 @@ 'use strict' var style = require('./styles/sliderStyles') -var EventManager = require('../lib/eventManager') +var remixLib = require('remix-lib') +var EventManager = remixLib.EventManager var yo = require('yo-yo') -var ui = require('../helpers/ui') +var ui = remixLib.helpers.ui class Slider { constructor (_traceManager, _stepOverride) { diff --git a/src/ui/SolidityLocals.js b/remix-debugger/src/ui/SolidityLocals.js similarity index 92% rename from src/ui/SolidityLocals.js rename to remix-debugger/src/ui/SolidityLocals.js index 0437f730a5..b5e5a26f79 100644 --- a/src/ui/SolidityLocals.js +++ b/remix-debugger/src/ui/SolidityLocals.js @@ -1,8 +1,10 @@ 'use strict' var DropdownPanel = require('./DropdownPanel') -var localDecoder = require('../solidity/localDecoder') +var remixSolidity = require('remix-solidity') +var localDecoder = remixSolidity.localDecoder var solidityTypeFormatter = require('./SolidityTypeFormatter') -var StorageViewer = require('../storage/storageViewer') +var remixCore = require('remix-core') +var StorageViewer = remixCore.storage.StorageViewer var yo = require('yo-yo') class SolidityLocals { diff --git a/src/ui/SolidityState.js b/remix-debugger/src/ui/SolidityState.js similarity index 94% rename from src/ui/SolidityState.js rename to remix-debugger/src/ui/SolidityState.js index 7bcd345eef..7c1d77c2fe 100644 --- a/src/ui/SolidityState.js +++ b/remix-debugger/src/ui/SolidityState.js @@ -1,8 +1,10 @@ 'use strict' var DropdownPanel = require('./DropdownPanel') -var stateDecoder = require('../solidity/stateDecoder') +var remixSolidity = require('remix-solidity') +var stateDecoder = remixSolidity.stateDecoder var solidityTypeFormatter = require('./SolidityTypeFormatter') -var StorageViewer = require('../storage/storageViewer') +var remixCore = require('remix-core') +var StorageViewer = remixCore.storage.StorageViewer var yo = require('yo-yo') function SolidityState (_parent, _traceManager, _codeManager, _solidityProxy) { diff --git a/src/ui/SolidityTypeFormatter.js b/remix-debugger/src/ui/SolidityTypeFormatter.js similarity index 100% rename from src/ui/SolidityTypeFormatter.js rename to remix-debugger/src/ui/SolidityTypeFormatter.js diff --git a/src/ui/StackPanel.js b/remix-debugger/src/ui/StackPanel.js similarity index 94% rename from src/ui/StackPanel.js rename to remix-debugger/src/ui/StackPanel.js index 0460c8a3ea..c07aa01094 100644 --- a/src/ui/StackPanel.js +++ b/remix-debugger/src/ui/StackPanel.js @@ -1,6 +1,7 @@ 'use strict' var DropdownPanel = require('./DropdownPanel') -var ui = require('../helpers/ui') +var remixLib = require('remix-lib') +var ui = remixLib.helpers.ui var yo = require('yo-yo') function StackPanel (_parent, _traceManager) { diff --git a/src/ui/StepDetail.js b/remix-debugger/src/ui/StepDetail.js similarity index 100% rename from src/ui/StepDetail.js rename to remix-debugger/src/ui/StepDetail.js diff --git a/src/ui/StepManager.js b/remix-debugger/src/ui/StepManager.js similarity index 96% rename from src/ui/StepManager.js rename to remix-debugger/src/ui/StepManager.js index 86ed76f69b..eaa2ec0d85 100644 --- a/src/ui/StepManager.js +++ b/remix-debugger/src/ui/StepManager.js @@ -1,9 +1,10 @@ 'use strict' var ButtonNavigator = require('./ButtonNavigator') var Slider = require('./Slider') -var EventManager = require('../lib/eventManager') +var remixLib = require('remix-lib') +var EventManager = remixLib.EventManager var yo = require('yo-yo') -var utils = require('../helpers/util.js') +var util = remixLib.util function StepManager (_parent, _traceManager) { this.event = new EventManager() @@ -73,7 +74,7 @@ function StepManager (_parent, _traceManager) { StepManager.prototype.resolveToReducedTrace = function (value, incr) { if (this.parent.callTree.reducedTrace.length) { - var nextSource = utils.findClosestIndex(value, this.parent.callTree.reducedTrace) + var nextSource = util.findClosestIndex(value, this.parent.callTree.reducedTrace) nextSource = nextSource + incr if (nextSource <= 0) { nextSource = 0 diff --git a/src/ui/StoragePanel.js b/remix-debugger/src/ui/StoragePanel.js similarity index 94% rename from src/ui/StoragePanel.js rename to remix-debugger/src/ui/StoragePanel.js index 67cb11e854..cd4573e4f7 100644 --- a/src/ui/StoragePanel.js +++ b/remix-debugger/src/ui/StoragePanel.js @@ -1,6 +1,7 @@ 'use strict' var DropdownPanel = require('./DropdownPanel') -var StorageViewer = require('../storage/storageViewer') +var remixCore = require('remix-core') +var StorageViewer = remixCore.storage.StorageViewer var yo = require('yo-yo') function StoragePanel (_parent, _traceManager) { diff --git a/src/ui/TreeView.js b/remix-debugger/src/ui/TreeView.js similarity index 97% rename from src/ui/TreeView.js rename to remix-debugger/src/ui/TreeView.js index 680d3b4939..e1f0e09361 100644 --- a/src/ui/TreeView.js +++ b/remix-debugger/src/ui/TreeView.js @@ -1,7 +1,8 @@ 'use strict' var yo = require('yo-yo') var style = require('./styles/treeView') -var ui = require('../helpers/ui') +var remixLib = require('remix-lib') +var ui = remixLib.helpers.ui class TreeView { diff --git a/src/ui/TxBrowser.js b/remix-debugger/src/ui/TxBrowser.js similarity index 86% rename from src/ui/TxBrowser.js rename to remix-debugger/src/ui/TxBrowser.js index c2db3da118..1ae081118e 100644 --- a/src/ui/TxBrowser.js +++ b/remix-debugger/src/ui/TxBrowser.js @@ -1,9 +1,10 @@ -var util = require('../helpers/global') -var EventManager = require('../lib/eventManager') -var traceHelper = require('../helpers/traceHelper') +var remixLib = require('remix-lib') +var global = remixLib.global +var EventManager = remixLib.EventManager +var traceHelper = remixLib.helpers.trace var yo = require('yo-yo') -var ui = require('../helpers/ui') -var init = require('../helpers/init') +var ui = remixLib.helpers.ui +var init = remixLib.init var DropdownPanel = require('./DropdownPanel') var style = require('./styles/basicStyles') var csjs = require('csjs-inject') @@ -87,11 +88,11 @@ TxBrowser.prototype.submit = function () { try { var self = this if (this.txNumber.indexOf('0x') !== -1) { - util.web3.eth.getTransaction(this.txNumber, function (error, result) { + global.web3.eth.getTransaction(this.txNumber, function (error, result) { self.update(error, result) }) } else { - util.web3.eth.getTransactionFromBlock(this.blockNumber, this.txNumber, function (error, result) { + global.web3.eth.getTransactionFromBlock(this.blockNumber, this.txNumber, function (error, result) { self.update(error, result) }) } @@ -126,13 +127,13 @@ TxBrowser.prototype.update = function (error, tx) { } TxBrowser.prototype.updateWeb3Url = function (newhost) { - init.setProvider(util.web3, newhost) + init.setProvider(global.web3, newhost) var self = this this.checkWeb3(function (error, block) { if (!error) { - self.connectInfo = 'Connected to ' + util.web3.currentProvider.host + '. Current block number: ' + block + self.connectInfo = 'Connected to ' + global.web3.currentProvider.host + '. Current block number: ' + block } else { - self.connectInfo = 'Unable to connect to ' + util.web3.currentProvider.host + '. ' + error.message + self.connectInfo = 'Unable to connect to ' + global.web3.currentProvider.host + '. ' + error.message } yo.update(self.view, self.render()) }) @@ -140,7 +141,7 @@ TxBrowser.prototype.updateWeb3Url = function (newhost) { TxBrowser.prototype.checkWeb3 = function (callback) { try { - util.web3.eth.getBlockNumber(function (error, block) { + global.web3.eth.getBlockNumber(function (error, block) { callback(error, block) }) } catch (e) { @@ -174,7 +175,7 @@ TxBrowser.prototype.init = function (ev) { TxBrowser.prototype.connectionSetting = function () { if (this.displayConnectionSetting) { var self = this - return yo`
Node URL: + return yo`
Node URL: ${this.connectInfo}
` } else { return '' diff --git a/src/ui/VmDebugger.js b/remix-debugger/src/ui/VmDebugger.js similarity index 97% rename from src/ui/VmDebugger.js rename to remix-debugger/src/ui/VmDebugger.js index 9a2c3de094..c372c7b9f5 100644 --- a/src/ui/VmDebugger.js +++ b/remix-debugger/src/ui/VmDebugger.js @@ -10,7 +10,8 @@ var StepDetail = require('./StepDetail') var DropdownPanel = require('./DropdownPanel') var SolidityState = require('./SolidityState') var SolidityLocals = require('./SolidityLocals') -var StorageResolver = require('../storage/storageResolver.js') +var remixCore = require('remix-core') +var StorageResolver = remixCore.storage.StorageResolver var yo = require('yo-yo') function VmDebugger (_parent, _traceManager, _codeManager, _solidityProxy, _callTree) { diff --git a/src/ui/styles/basicStyles.js b/remix-debugger/src/ui/styles/basicStyles.js similarity index 100% rename from src/ui/styles/basicStyles.js rename to remix-debugger/src/ui/styles/basicStyles.js diff --git a/src/ui/styles/dropdownPanel.js b/remix-debugger/src/ui/styles/dropdownPanel.js similarity index 100% rename from src/ui/styles/dropdownPanel.js rename to remix-debugger/src/ui/styles/dropdownPanel.js diff --git a/src/ui/styles/sliderStyles.js b/remix-debugger/src/ui/styles/sliderStyles.js similarity index 100% rename from src/ui/styles/sliderStyles.js rename to remix-debugger/src/ui/styles/sliderStyles.js diff --git a/src/ui/styles/style-guide.js b/remix-debugger/src/ui/styles/style-guide.js similarity index 100% rename from src/ui/styles/style-guide.js rename to remix-debugger/src/ui/styles/style-guide.js diff --git a/src/ui/styles/treeView.js b/remix-debugger/src/ui/styles/treeView.js similarity index 100% rename from src/ui/styles/treeView.js rename to remix-debugger/src/ui/styles/treeView.js diff --git a/test/resources/insertTestWeb3.js b/remix-debugger/test-browser/resources/insertTestWeb3.js similarity index 92% rename from test/resources/insertTestWeb3.js rename to remix-debugger/test-browser/resources/insertTestWeb3.js index a333fb6500..833c7198e1 100644 --- a/test/resources/insertTestWeb3.js +++ b/remix-debugger/test-browser/resources/insertTestWeb3.js @@ -1,9 +1,10 @@ +/* global XMLHttpRequest */ function loadJSON (url, callback) { var xobj = new XMLHttpRequest() xobj.overrideMimeType('application/json') xobj.open('GET', url, true) xobj.onreadystatechange = function () { - if (xobj.readyState == 4 && xobj.status == '200') { + if (xobj.readyState === 4 && xobj.status === 200) { callback(xobj.responseText) } } @@ -23,7 +24,7 @@ function loadTestWeb3 (data) { return data.testCodes[address] } } - + uiTestweb3.debug.traceTransaction = function (txHash, options, callback) { callback(null, data.testTraces[txHash]) } @@ -54,7 +55,7 @@ function loadTestWeb3 (data) { uiTestweb3.setProvider = function (provider) {} - uiTestweb3.currentProvider = {host: 'web3 modified for testing purposes :)'} + uiTestweb3.currentProvider = {host: 'web3 modified for testing purposes :)'} vmdebugger.addProvider('TEST', uiTestweb3) vmdebugger.switchProvider('TEST') } @@ -69,9 +70,8 @@ function waitForRemix (data) { }, 500) } -loadJSON('/test/resources/testWeb3.json', function (result) { +loadJSON('/test-browser/resources/testWeb3.json', function (result) { var data = JSON.parse(result) waitForRemix(data) }) - diff --git a/remix-debugger/test-browser/resources/testWeb3.json b/remix-debugger/test-browser/resources/testWeb3.json new file mode 100644 index 0000000000..ba5f88cb0f --- /dev/null +++ b/remix-debugger/test-browser/resources/testWeb3.json @@ -0,0 +1,17 @@ +{ + "testTxs": { + "0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51": {"blockHash":"0xd1d34932f8733e0485b7d9bf8500c4046d650f20ed7792508c304304fa7bbfac","blockNumber":89,"from":"0x00101c5bfa3fc8bad02c9f5fd65b069306251915","gas":105967,"gasPrice":"20000000000","hash":"0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51","input":"0x60fe47b10000000000000000000000000000000000000000000000000000000000000038","nonce":3,"to":"0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5","transactionIndex":0,"value":"0"} + }, + + "testTxsByBlock": { + "105967-0": {"blockHash":"0xd1d34932f8733e0485b7d9bf8500c4046d650f20ed7792508c304304fa7bbfac","blockNumber":89,"from":"0x00101c5bfa3fc8bad02c9f5fd65b069306251915","gas":105967,"gasPrice":"20000000000","hash":"0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51","input":"0x60fe47b10000000000000000000000000000000000000000000000000000000000000038","nonce":3,"to":"0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5","transactionIndex":0,"value":"0"} + }, + + "testCodes": { + "0x0d3a18d64dfe4f927832ab58d6451cecc4e517c5": "0x60606040526000357c01000000000000000000000000000000000000000000000000000000009004806360fe47b11460415780636d4ce63c14605757603f565b005b605560048080359060200190919050506089565b005b606260048050506078565b6040518082815260200191505060405180910390f35b600060006000505490506086565b90565b80600060005081905550602d6040516045806100f083390180828152602001915050604051809103906000f0600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff02191690830217905550602281016000600050819055505b505660606040526040516020806045833981016040528080519060200190919050505b806001016000600050819055505b50600a80603b6000396000f360606040526008565b00" + }, + + "testTraces": { + "0x20ef65b8b186ca942fcccd634f37074dde49b541c27994fc7596740ef44cfd51": {"gas":"0x0000000000000000000000000000000000000000000000000000000000019def","return":"0x","structLogs":[{"gas":"84503","gasCost":"3","memory":[],"op":"PUSH1","pc":"0","stack":[]},{"gas":"84500","gasCost":"3","op":"PUSH1","pc":"2","stack":["0x60"]},{"gas":"84497","gasCost":"12","memexpand":"3","op":"MSTORE","pc":"4","stack":["0x60","0x40"]},{"gas":"84485","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"5","stack":[]},{"gas":"84482","gasCost":"3","op":"CALLDATALOAD","pc":"7","stack":["0x00"]},{"gas":"84479","gasCost":"3","op":"PUSH29","pc":"8","stack":["0x60fe47b100000000000000000000000000000000000000000000000000000000"]},{"gas":"84476","gasCost":"3","op":"SWAP1","pc":"38","stack":["0x60fe47b100000000000000000000000000000000000000000000000000000000","0x0100000000000000000000000000000000000000000000000000000000"]},{"gas":"84473","gasCost":"5","op":"DIV","pc":"39","stack":["0x0100000000000000000000000000000000000000000000000000000000","0x60fe47b100000000000000000000000000000000000000000000000000000000"]},{"gas":"84468","gasCost":"3","op":"DUP1","pc":"40","stack":["0x60fe47b1"]},{"gas":"84465","gasCost":"3","op":"PUSH4","pc":"41","stack":["0x60fe47b1","0x60fe47b1"]},{"gas":"84462","gasCost":"3","op":"EQ","pc":"46","stack":["0x60fe47b1","0x60fe47b1","0x60fe47b1"]},{"gas":"84459","gasCost":"3","op":"PUSH1","pc":"47","stack":["0x60fe47b1","0x01"]},{"gas":"84456","gasCost":"10","op":"JUMPI","pc":"49","stack":["0x60fe47b1","0x01","0x41"]},{"gas":"84446","gasCost":"1","op":"JUMPDEST","pc":"65","stack":["0x60fe47b1"]},{"gas":"84445","gasCost":"3","op":"PUSH1","pc":"66","stack":["0x60fe47b1"]},{"gas":"84442","gasCost":"3","op":"PUSH1","pc":"68","stack":["0x60fe47b1","0x55"]},{"gas":"84439","gasCost":"3","op":"DUP1","pc":"70","stack":["0x60fe47b1","0x55","0x04"]},{"gas":"84436","gasCost":"3","op":"DUP1","pc":"71","stack":["0x60fe47b1","0x55","0x04","0x04"]},{"gas":"84433","gasCost":"3","op":"CALLDATALOAD","pc":"72","stack":["0x60fe47b1","0x55","0x04","0x04","0x04"]},{"gas":"84430","gasCost":"3","op":"SWAP1","pc":"73","stack":["0x60fe47b1","0x55","0x04","0x04","0x38"]},{"gas":"84427","gasCost":"3","op":"PUSH1","pc":"74","stack":["0x60fe47b1","0x55","0x04","0x38","0x04"]},{"gas":"84424","gasCost":"3","op":"ADD","pc":"76","stack":["0x60fe47b1","0x55","0x04","0x38","0x04","0x20"]},{"gas":"84421","gasCost":"3","op":"SWAP1","pc":"77","stack":["0x60fe47b1","0x55","0x04","0x38","0x24"]},{"gas":"84418","gasCost":"3","op":"SWAP2","pc":"78","stack":["0x60fe47b1","0x55","0x04","0x24","0x38"]},{"gas":"84415","gasCost":"3","op":"SWAP1","pc":"79","stack":["0x60fe47b1","0x55","0x38","0x24","0x04"]},{"gas":"84412","gasCost":"2","op":"POP","pc":"80","stack":["0x60fe47b1","0x55","0x38","0x04","0x24"]},{"gas":"84410","gasCost":"2","op":"POP","pc":"81","stack":["0x60fe47b1","0x55","0x38","0x04"]},{"gas":"84408","gasCost":"3","op":"PUSH1","pc":"82","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"84405","gasCost":"8","op":"JUMP","pc":"84","stack":["0x60fe47b1","0x55","0x38","0x89"]},{"gas":"84397","gasCost":"1","op":"JUMPDEST","pc":"137","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"84396","gasCost":"3","op":"DUP1","pc":"138","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"84393","gasCost":"3","op":"PUSH1","pc":"139","stack":["0x60fe47b1","0x55","0x38","0x38"]},{"gas":"84390","gasCost":"3","op":"PUSH1","pc":"141","stack":["0x60fe47b1","0x55","0x38","0x38","0x00"]},{"gas":"84387","gasCost":"2","op":"POP","pc":"143","stack":["0x60fe47b1","0x55","0x38","0x38","0x00","0x00"]},{"gas":"84385","gasCost":"3","op":"DUP2","pc":"144","stack":["0x60fe47b1","0x55","0x38","0x38","0x00"]},{"gas":"84382","gasCost":"3","op":"SWAP1","pc":"145","stack":["0x60fe47b1","0x55","0x38","0x38","0x00","0x38"]},{"gas":"84379","gasCost":"5000","op":"SSTORE","pc":"146","stack":["0x60fe47b1","0x55","0x38","0x38","0x38","0x00"]},{"gas":"79379","gasCost":"2","op":"POP","pc":"147","stack":["0x60fe47b1","0x55","0x38","0x38"]},{"gas":"79377","gasCost":"3","op":"PUSH1","pc":"148","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"79374","gasCost":"3","op":"PUSH1","pc":"150","stack":["0x60fe47b1","0x55","0x38","0x2d"]},{"gas":"79371","gasCost":"3","op":"MLOAD","pc":"152","stack":["0x60fe47b1","0x55","0x38","0x2d","0x40"]},{"gas":"79368","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"153","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60"]},{"gas":"79365","gasCost":"3","op":"DUP1","pc":"155","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45"]},{"gas":"79362","gasCost":"3","op":"PUSH2","pc":"156","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45","0x45"]},{"gas":"79359","gasCost":"3","op":"DUP4","pc":"159","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45","0x45","0xf0"]},{"gas":"79356","gasCost":"21","memexpand":"3","op":"CODECOPY","pc":"160","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45","0x45","0xf0","0x60"]},{"gas":"79335","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000"],"op":"ADD","pc":"161","stack":["0x60fe47b1","0x55","0x38","0x2d","0x60","0x45"]},{"gas":"79332","gasCost":"3","op":"DUP1","pc":"162","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5"]},{"gas":"79329","gasCost":"3","op":"DUP3","pc":"163","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5"]},{"gas":"79326","gasCost":"3","op":"DUP2","pc":"164","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5","0x2d"]},{"gas":"79323","gasCost":"6","memexpand":"1","op":"MSTORE","pc":"165","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5","0x2d","0xa5"]},{"gas":"79317","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"PUSH1","pc":"166","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5"]},{"gas":"79314","gasCost":"3","op":"ADD","pc":"168","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xa5","0x20"]},{"gas":"79311","gasCost":"3","op":"SWAP2","pc":"169","stack":["0x60fe47b1","0x55","0x38","0x2d","0xa5","0xc5"]},{"gas":"79308","gasCost":"2","op":"POP","pc":"170","stack":["0x60fe47b1","0x55","0x38","0xc5","0xa5","0x2d"]},{"gas":"79306","gasCost":"2","op":"POP","pc":"171","stack":["0x60fe47b1","0x55","0x38","0xc5","0xa5"]},{"gas":"79304","gasCost":"3","op":"PUSH1","pc":"172","stack":["0x60fe47b1","0x55","0x38","0xc5"]},{"gas":"79301","gasCost":"3","op":"MLOAD","pc":"174","stack":["0x60fe47b1","0x55","0x38","0xc5","0x40"]},{"gas":"79298","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"DUP1","pc":"175","stack":["0x60fe47b1","0x55","0x38","0xc5","0x60"]},{"gas":"79295","gasCost":"3","op":"SWAP2","pc":"176","stack":["0x60fe47b1","0x55","0x38","0xc5","0x60","0x60"]},{"gas":"79292","gasCost":"3","op":"SUB","pc":"177","stack":["0x60fe47b1","0x55","0x38","0x60","0x60","0xc5"]},{"gas":"79289","gasCost":"3","op":"SWAP1","pc":"178","stack":["0x60fe47b1","0x55","0x38","0x60","0x65"]},{"gas":"79286","gasCost":"3","op":"PUSH1","pc":"179","stack":["0x60fe47b1","0x55","0x38","0x65","0x60"]},{"gas":"79283","gasCost":"32000","op":"CREATE","pc":"181","stack":["0x60fe47b1","0x55","0x38","0x65","0x60","0x00"]},{"gas":"47283","gasCost":"3","memory":[],"op":"PUSH1","pc":"0","stack":[]},{"gas":"47280","gasCost":"3","op":"PUSH1","pc":"2","stack":["0x60"]},{"gas":"47277","gasCost":"12","memexpand":"3","op":"MSTORE","pc":"4","stack":["0x60","0x40"]},{"gas":"47265","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"5","stack":[]},{"gas":"47262","gasCost":"3","op":"MLOAD","pc":"7","stack":["0x40"]},{"gas":"47259","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060"],"op":"PUSH1","pc":"8","stack":["0x60"]},{"gas":"47256","gasCost":"3","op":"DUP1","pc":"10","stack":["0x60","0x20"]},{"gas":"47253","gasCost":"3","op":"PUSH1","pc":"11","stack":["0x60","0x20","0x20"]},{"gas":"47250","gasCost":"3","op":"DUP4","pc":"13","stack":["0x60","0x20","0x20","0x45"]},{"gas":"47247","gasCost":"9","memexpand":"1","op":"CODECOPY","pc":"14","stack":["0x60","0x20","0x20","0x45","0x60"]},{"gas":"47238","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","000000000000000000000000000000000000000000000000000000000000002d"],"op":"DUP2","pc":"15","stack":["0x60","0x20"]},{"gas":"47235","gasCost":"3","op":"ADD","pc":"16","stack":["0x60","0x20","0x60"]},{"gas":"47232","gasCost":"3","op":"PUSH1","pc":"17","stack":["0x60","0x80"]},{"gas":"47229","gasCost":"3","op":"MSTORE","pc":"19","stack":["0x60","0x80","0x40"]},{"gas":"47226","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080","000000000000000000000000000000000000000000000000000000000000002d"],"op":"DUP1","pc":"20","stack":["0x60"]},{"gas":"47223","gasCost":"3","op":"DUP1","pc":"21","stack":["0x60","0x60"]},{"gas":"47220","gasCost":"3","op":"MLOAD","pc":"22","stack":["0x60","0x60","0x60"]},{"gas":"47217","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080","000000000000000000000000000000000000000000000000000000000000002d"],"op":"SWAP1","pc":"23","stack":["0x60","0x60","0x2d"]},{"gas":"47214","gasCost":"3","op":"PUSH1","pc":"24","stack":["0x60","0x2d","0x60"]},{"gas":"47211","gasCost":"3","op":"ADD","pc":"26","stack":["0x60","0x2d","0x60","0x20"]},{"gas":"47208","gasCost":"3","op":"SWAP1","pc":"27","stack":["0x60","0x2d","0x80"]},{"gas":"47205","gasCost":"3","op":"SWAP2","pc":"28","stack":["0x60","0x80","0x2d"]},{"gas":"47202","gasCost":"3","op":"SWAP1","pc":"29","stack":["0x2d","0x80","0x60"]},{"gas":"47199","gasCost":"2","op":"POP","pc":"30","stack":["0x2d","0x60","0x80"]},{"gas":"47197","gasCost":"2","op":"POP","pc":"31","stack":["0x2d","0x60"]},{"gas":"47195","gasCost":"1","op":"JUMPDEST","pc":"32","stack":["0x2d"]},{"gas":"47194","gasCost":"3","op":"DUP1","pc":"33","stack":["0x2d"]},{"gas":"47191","gasCost":"3","op":"PUSH1","pc":"34","stack":["0x2d","0x2d"]},{"gas":"47188","gasCost":"3","op":"ADD","pc":"36","stack":["0x2d","0x2d","0x01"]},{"gas":"47185","gasCost":"3","op":"PUSH1","pc":"37","stack":["0x2d","0x2e"]},{"gas":"47182","gasCost":"3","op":"PUSH1","pc":"39","stack":["0x2d","0x2e","0x00"]},{"gas":"47179","gasCost":"2","op":"POP","pc":"41","stack":["0x2d","0x2e","0x00","0x00"]},{"gas":"47177","gasCost":"3","op":"DUP2","pc":"42","stack":["0x2d","0x2e","0x00"]},{"gas":"47174","gasCost":"3","op":"SWAP1","pc":"43","stack":["0x2d","0x2e","0x00","0x2e"]},{"gas":"47171","gasCost":"20000","op":"SSTORE","pc":"44","stack":["0x2d","0x2e","0x2e","0x00"]},{"gas":"27171","gasCost":"2","op":"POP","pc":"45","stack":["0x2d","0x2e"]},{"gas":"27169","gasCost":"1","op":"JUMPDEST","pc":"46","stack":["0x2d"]},{"gas":"27168","gasCost":"2","op":"POP","pc":"47","stack":["0x2d"]},{"gas":"27166","gasCost":"3","op":"PUSH1","pc":"48","stack":[]},{"gas":"27163","gasCost":"3","op":"DUP1","pc":"50","stack":["0x0a"]},{"gas":"27160","gasCost":"3","op":"PUSH1","pc":"51","stack":["0x0a","0x0a"]},{"gas":"27157","gasCost":"3","op":"PUSH1","pc":"53","stack":["0x0a","0x0a","0x3b"]},{"gas":"27154","gasCost":"6","op":"CODECOPY","pc":"55","stack":["0x0a","0x0a","0x3b","0x00"]},{"gas":"27148","gasCost":"3","memory":["60606040526008565b0000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000080","000000000000000000000000000000000000000000000000000000000000002d"],"op":"PUSH1","pc":"56","stack":["0x0a"]},{"gas":"27145","gasCost":"0","op":"RETURN","pc":"58","stack":["0x0a","0x00"]},{"gas":"25145","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"PUSH1","pc":"182","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25142","gasCost":"3","memory":["0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000000","0000000000000000000000000000000000000000000000000000000000000060","6060604052604051602080604583398101604052808051906020019091905050","5b806001016000600050819055505b50600a80603b6000396000f36060604052","6008565b00000000000000000000000000000000000000000000000000000000","000000002d000000000000000000000000000000000000000000000000000000"],"op":"PUSH1","pc":"184","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01"]},{"gas":"25139","gasCost":"3","op":"PUSH2","pc":"186","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00"]},{"gas":"25136","gasCost":"10","op":"EXP","pc":"189","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0x0100"]},{"gas":"25126","gasCost":"3","op":"DUP2","pc":"190","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01"]},{"gas":"25123","gasCost":"50","op":"SLOAD","pc":"191","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x01"]},{"gas":"25073","gasCost":"3","op":"DUP2","pc":"192","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00"]},{"gas":"25070","gasCost":"3","op":"PUSH20","pc":"193","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0x01"]},{"gas":"25067","gasCost":"5","op":"MUL","pc":"214","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0x01","0xffffffffffffffffffffffffffffffffffffffff"]},{"gas":"25062","gasCost":"3","op":"NOT","pc":"215","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0xffffffffffffffffffffffffffffffffffffffff"]},{"gas":"25059","gasCost":"3","op":"AND","pc":"216","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00","0xffffffffffffffffffffffff0000000000000000000000000000000000000000"]},{"gas":"25056","gasCost":"3","op":"SWAP1","pc":"217","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x01","0x00"]},{"gas":"25053","gasCost":"3","op":"DUP4","pc":"218","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0x01"]},{"gas":"25050","gasCost":"5","op":"MUL","pc":"219","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0x01","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25045","gasCost":"3","op":"OR","pc":"220","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0x00","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25042","gasCost":"3","op":"SWAP1","pc":"221","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"25039","gasCost":"20000","op":"SSTORE","pc":"222","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95","0x01"]},{"gas":"5039","gasCost":"2","op":"POP","pc":"223","stack":["0x60fe47b1","0x55","0x38","0xd01f65e3472f24faf45f08f8698ec4da1bf32a95"]},{"gas":"5037","gasCost":"3","op":"PUSH1","pc":"224","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"5034","gasCost":"3","op":"DUP2","pc":"226","stack":["0x60fe47b1","0x55","0x38","0x22"]},{"gas":"5031","gasCost":"3","op":"ADD","pc":"227","stack":["0x60fe47b1","0x55","0x38","0x22","0x38"]},{"gas":"5028","gasCost":"3","op":"PUSH1","pc":"228","stack":["0x60fe47b1","0x55","0x38","0x5a"]},{"gas":"5025","gasCost":"3","op":"PUSH1","pc":"230","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00"]},{"gas":"5022","gasCost":"2","op":"POP","pc":"232","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00","0x00"]},{"gas":"5020","gasCost":"3","op":"DUP2","pc":"233","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00"]},{"gas":"5017","gasCost":"3","op":"SWAP1","pc":"234","stack":["0x60fe47b1","0x55","0x38","0x5a","0x00","0x5a"]},{"gas":"5014","gasCost":"5000","op":"SSTORE","pc":"235","stack":["0x60fe47b1","0x55","0x38","0x5a","0x5a","0x00"]},{"gas":"14","gasCost":"2","op":"POP","pc":"236","stack":["0x60fe47b1","0x55","0x38","0x5a"]},{"gas":"12","gasCost":"1","op":"JUMPDEST","pc":"237","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"11","gasCost":"2","op":"POP","pc":"238","stack":["0x60fe47b1","0x55","0x38"]},{"gas":"9","gasCost":"8","op":"JUMP","pc":"239","stack":["0x60fe47b1","0x55"]},{"gas":"1","gasCost":"1","op":"JUMPDEST","pc":"85","stack":["0x60fe47b1"]},{"gas":"0","gasCost":"0","op":"STOP","pc":"86","stack":["0x60fe47b1"]}]} + } +} diff --git a/test-browser/init.js b/remix-debugger/test-browser/test/init.js similarity index 98% rename from test-browser/init.js rename to remix-debugger/test-browser/test/init.js index f7d075545a..4078b00185 100644 --- a/test-browser/init.js +++ b/remix-debugger/test-browser/test/init.js @@ -2,7 +2,7 @@ module.exports = function (browser, callback) { extendBrowser(browser) browser .url('http://127.0.0.1:8080') - .injectScript('test/resources/insertTestWeb3.js', function () { + .injectScript('test-browser/resources/insertTestWeb3.js', function () { // wait for the script to load test web3... setTimeout(function () { callback() diff --git a/test-browser/sauce.js b/remix-debugger/test-browser/test/sauce.js similarity index 100% rename from test-browser/sauce.js rename to remix-debugger/test-browser/test/sauce.js diff --git a/test-browser/vmdebugger.js b/remix-debugger/test-browser/test/vmdebugger.js similarity index 100% rename from test-browser/vmdebugger.js rename to remix-debugger/test-browser/test/vmdebugger.js diff --git a/remix-lib/index.js b/remix-lib/index.js new file mode 100644 index 0000000000..2d379dfae7 --- /dev/null +++ b/remix-lib/index.js @@ -0,0 +1,40 @@ +'use strict' +var EventManager = require('./src/eventManager') +var traceHelper = require('./src/helpers/traceHelper') +var uiHelper = require('./src/helpers/uiHelper') +var SourceMappingDecoder = require('./src/sourceMappingDecoder') +var SourceLocationTracker = require('./src/sourceLocationTracker') +var init = require('./src/init') +var util = require('./src/util') +var Web3Providers = require('./src/web3Provider/web3Providers') +var DummyProvider = require('./src/web3Provider/dummyProvider') +var AstWalker = require('./src/astWalker') +var global = require('./src/global') + +if (typeof (module) !== 'undefined' && typeof (module.exports) !== 'undefined') { + module.exports = modules() +} + +if (typeof (window) !== 'undefined') { + window.remix = modules() +} + +function modules () { + return { + EventManager: EventManager, + helpers: { + trace: traceHelper, + ui: uiHelper + }, + vm: { + Web3Providers: Web3Providers, + DummyProvider: DummyProvider + }, + SourceMappingDecoder: SourceMappingDecoder, + SourceLocationTracker: SourceLocationTracker, + init: init, + util: util, + AstWalker: AstWalker, + global: global + } +} diff --git a/remix-lib/package.json b/remix-lib/package.json new file mode 100644 index 0000000000..94440b1125 --- /dev/null +++ b/remix-lib/package.json @@ -0,0 +1,43 @@ +{ + "name": "remix-lib", + "version": "0.0.2", + "description": "Ethereum IDE and tools for the web", + "contributors": [ + { + "name": "Yann Levreau", + "email": "yann@ethdev.com" + }, + { + "name": "Liana Husikyan", + "email": "liana@ethdev.com" + } + ], + "main": "./index.js", + "dependencies": { + "ethereumjs-util": "^4.5.0", + "web3": "^0.15.3", + "solc": "^0.4.13", + "standard": "^7.0.1", + "tape": "^4.6.0" + }, + "scripts": { + "test": "standard && tape ./test/tests.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ethereum/remix.git" + }, + "author": "cpp-ethereum team", + "license": "MIT", + "bugs": { + "url": "https://github.com/ethereum/remix/issues" + }, + "homepage": "https://github.com/ethereum/remix#readme", + "standard": { + "ignore": [ + "node_modules/*", + "build/*", + "test/resources/*" + ] + } +} diff --git a/src/util/astWalker.js b/remix-lib/src/astWalker.js similarity index 100% rename from src/util/astWalker.js rename to remix-lib/src/astWalker.js diff --git a/src/lib/eventManager.js b/remix-lib/src/eventManager.js similarity index 100% rename from src/lib/eventManager.js rename to remix-lib/src/eventManager.js diff --git a/remix-lib/src/global.js b/remix-lib/src/global.js new file mode 100644 index 0000000000..f710f7fb66 --- /dev/null +++ b/remix-lib/src/global.js @@ -0,0 +1,3 @@ +module.exports = { + web3: null +} diff --git a/src/helpers/traceHelper.js b/remix-lib/src/helpers/traceHelper.js similarity index 98% rename from src/helpers/traceHelper.js rename to remix-lib/src/helpers/traceHelper.js index 6e66c6cbd1..c3eef50e91 100644 --- a/src/helpers/traceHelper.js +++ b/remix-lib/src/helpers/traceHelper.js @@ -1,5 +1,5 @@ 'use strict' -var ui = require('../helpers/ui') +var ui = require('./uiHelper') module.exports = { // vmTraceIndex has to point to a CALL, CODECALL, ... resolveCalledAddress: function (vmTraceIndex, trace) { diff --git a/src/helpers/ui.js b/remix-lib/src/helpers/uiHelper.js similarity index 100% rename from src/helpers/ui.js rename to remix-lib/src/helpers/uiHelper.js diff --git a/src/util/web3Admin.js b/remix-lib/src/init.js similarity index 73% rename from src/util/web3Admin.js rename to remix-lib/src/init.js index 4ebb9c9107..4ab21588c0 100644 --- a/src/util/web3Admin.js +++ b/remix-lib/src/init.js @@ -1,5 +1,22 @@ 'use strict' +var Web3 = require('web3') + module.exports = { + loadWeb3: function () { + var web3 = new Web3() + web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')) + this.extend(web3) + return web3 + }, + + extendWeb3: function (web3) { + this.extend(web3) + }, + + setProvider: function (web3, url) { + web3.setProvider(new web3.providers.HttpProvider(url)) + }, + extend: function (web3) { if (!web3._extend) { return diff --git a/src/code/sourceLocationTracker.js b/remix-lib/src/sourceLocationTracker.js similarity index 93% rename from src/code/sourceLocationTracker.js rename to remix-lib/src/sourceLocationTracker.js index 4a676b240a..d4a83fdad8 100644 --- a/src/code/sourceLocationTracker.js +++ b/remix-lib/src/sourceLocationTracker.js @@ -1,8 +1,8 @@ 'use strict' -var EventManager = require('../lib/eventManager') -var helper = require('../helpers/traceHelper') -var SourceMappingDecoder = require('../util/sourceMappingDecoder') -var util = require('../helpers/util') +var EventManager = require('./eventManager') +var helper = require('./helpers/traceHelper') +var SourceMappingDecoder = require('./sourceMappingDecoder') +var util = require('./util') /** * Process the source code location for the current executing bytecode diff --git a/src/util/sourceMappingDecoder.js b/remix-lib/src/sourceMappingDecoder.js similarity index 99% rename from src/util/sourceMappingDecoder.js rename to remix-lib/src/sourceMappingDecoder.js index 898aa287bd..ce5fc50ed8 100644 --- a/src/util/sourceMappingDecoder.js +++ b/remix-lib/src/sourceMappingDecoder.js @@ -1,5 +1,5 @@ 'use strict' -var util = require('../helpers/util') +var util = require('./util') var AstWalker = require('./astWalker') /** diff --git a/src/helpers/util.js b/remix-lib/src/util.js similarity index 96% rename from src/helpers/util.js rename to remix-lib/src/util.js index 7fb9b54a8d..573baea487 100644 --- a/src/helpers/util.js +++ b/remix-lib/src/util.js @@ -1,6 +1,15 @@ 'use strict' var ethutil = require('ethereumjs-util') +/* + contains misc util: @TODO should be splitted + - hex convertion + - binary search + - CALL related look up + - sha3 calculation + - swarm hash extraction + - bytecode comparison +*/ module.exports = { /* ints: IntArray diff --git a/src/web3Provider/dummyProvider.js b/remix-lib/src/web3Provider/dummyProvider.js similarity index 100% rename from src/web3Provider/dummyProvider.js rename to remix-lib/src/web3Provider/dummyProvider.js diff --git a/src/web3Provider/web3Providers.js b/remix-lib/src/web3Provider/web3Providers.js similarity index 95% rename from src/web3Provider/web3Providers.js rename to remix-lib/src/web3Provider/web3Providers.js index 2dfb575545..ad53b8b2e6 100644 --- a/src/web3Provider/web3Providers.js +++ b/remix-lib/src/web3Provider/web3Providers.js @@ -1,5 +1,5 @@ var Web3VMProvider = require('./web3VmProvider') -var init = require('../helpers/init') +var init = require('../init') function Web3Providers () { this.modes = {} diff --git a/src/web3Provider/web3VmProvider.js b/remix-lib/src/web3Provider/web3VmProvider.js similarity index 99% rename from src/web3Provider/web3VmProvider.js rename to remix-lib/src/web3Provider/web3VmProvider.js index c4317b750a..3d63446e92 100644 --- a/src/web3Provider/web3VmProvider.js +++ b/remix-lib/src/web3Provider/web3VmProvider.js @@ -1,5 +1,5 @@ -var util = require('../helpers/util') -var uiutil = require('../helpers/ui') +var util = require('../util') +var uiutil = require('../helpers/uiHelper') var traceHelper = require('../helpers/traceHelper') var ethutil = require('ethereumjs-util') var Web3 = require('web3') diff --git a/test/astwalker.js b/remix-lib/test/astwalker.js similarity index 97% rename from test/astwalker.js rename to remix-lib/test/astwalker.js index 80ccb1c3cd..1191001333 100644 --- a/test/astwalker.js +++ b/remix-lib/test/astwalker.js @@ -1,6 +1,6 @@ 'use strict' var tape = require('tape') -var AstWalker = require('../src/util/astWalker') +var AstWalker = require('../src/astWalker') var node = require('./resources/ast') tape('ASTWalker', function (t) { diff --git a/test/eventManager.js b/remix-lib/test/eventManager.js similarity index 95% rename from test/eventManager.js rename to remix-lib/test/eventManager.js index 1e497504cf..41ca659fe1 100644 --- a/test/eventManager.js +++ b/remix-lib/test/eventManager.js @@ -1,6 +1,6 @@ 'use strict' var tape = require('tape') -var EventManager = require('../src/lib/eventManager') +var EventManager = require('../src/eventManager') tape('eventManager', function (t) { t.test('eventManager', function (st) { var events = new EventManager() diff --git a/test/resources/ast.js b/remix-lib/test/resources/ast.js similarity index 100% rename from test/resources/ast.js rename to remix-lib/test/resources/ast.js diff --git a/test/resources/sourceMapping.js b/remix-lib/test/resources/sourceMapping.js similarity index 100% rename from test/resources/sourceMapping.js rename to remix-lib/test/resources/sourceMapping.js diff --git a/test/util.js b/remix-lib/test/sourceMappingDecoder.js similarity index 63% rename from test/util.js rename to remix-lib/test/sourceMappingDecoder.js index 7113618e60..52ea53d14a 100644 --- a/test/util.js +++ b/remix-lib/test/sourceMappingDecoder.js @@ -1,40 +1,28 @@ 'use strict' -var sourceMapping = require('./resources/sourceMapping') -var index = require('../src/index') var tape = require('tape') -var util = require('../src/helpers/util') - -tape('Util', function (t) { - t.test('lowerbound', function (st) { - st.plan(7) - var array = [2, 5, 8, 9, 45, 56, 78] - var lowerBound = util.findLowerBound(10, array) - st.equal(lowerBound, 3) - - lowerBound = util.findLowerBound(3, array) - st.equal(lowerBound, 0) - - lowerBound = util.findLowerBound(100, array) - st.equal(lowerBound, 6) - - lowerBound = util.findLowerBound(1, array) - st.equal(lowerBound, -1) - - lowerBound = util.findLowerBound(45, array) - st.equal(lowerBound, 4) - - array = [2, 5, 8, 9, 9, 45, 56, 78] - lowerBound = util.findLowerBound(9, array) - st.equal(lowerBound, 4) - - lowerBound = util.findLowerBound(9, []) - st.equal(lowerBound, -1) +var sourceMapping = require('./resources/sourceMapping') +var SourceMappingDecoder = require('../src/sourceMappingDecoder') +var compiler = require('solc') + +tape('SourceMappingDecoder', function (t) { + t.test('SourceMappingDecoder.findNodeAtInstructionIndex', function (st) { + var output = compiler.compileStandardWrapper(compilerInput(contracts)) + output = JSON.parse(output) + var sourceMappingDecoder = new SourceMappingDecoder() + var node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 2, output.contracts['test.sol']['test'].evm.deployedBytecode.sourceMap, output.sources['test.sol']) + st.equal(node, null) + node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 80, output.contracts['test.sol']['test'].evm.deployedBytecode.sourceMap, output.sources['test.sol']) + st.notEqual(node, null) + if (node) { + st.equal(node.attributes.name, 'f1') + } + st.end() }) var testSourceMapping = {} t.test('sourceMappingDecoder', function (st) { st.plan(28) - var sourceMappingDecoder = new index.util.SourceMappingDecoder() + var sourceMappingDecoder = new SourceMappingDecoder() console.log('test decompressAll') var result = sourceMappingDecoder.decompressAll(sourceMapping.mapping) st.equal(result[0].start, 0) @@ -88,7 +76,7 @@ tape('Util', function (t) { t.test('sourceMappingLineColumnConverter', function (st) { st.plan(14) - var sourceMappingDecoder = new index.util.SourceMappingDecoder() + var sourceMappingDecoder = new SourceMappingDecoder() var linesbreak = sourceMappingDecoder.getLinebreakPositions(sourceMapping.source) st.equal(linesbreak[0], 16) st.equal(linesbreak[5], 84) @@ -116,3 +104,37 @@ tape('Util', function (t) { st.equal(result.end.column, 16) }) }) + +var contracts = `contract test { + function f1() returns (uint) { + uint t = 4; + return t; + } + + function f2() { + + } +} +` + +function compilerInput (contracts) { + return JSON.stringify({ + language: 'Solidity', + sources: { + 'test.sol': { + content: contracts + } + }, + settings: { + optimizer: { + enabled: false, + runs: 500 + } + }, + outputSelection: { + '*': { + '*': [ 'metadata', 'evm.bytecode', 'abi', 'legacyAST', 'metadata', 'evm.assembly', 'evm.methodIdentifiers', 'evm.gasEstimates' ] + } + } + }) +} diff --git a/remix-lib/test/tests.js b/remix-lib/test/tests.js new file mode 100644 index 0000000000..df5c04b8ab --- /dev/null +++ b/remix-lib/test/tests.js @@ -0,0 +1,4 @@ +require('./astwalker.js') +require('./eventManager.js') +require('./sourceMappingDecoder.js') +require('./util.js') diff --git a/remix-lib/test/util.js b/remix-lib/test/util.js new file mode 100644 index 0000000000..530fc52514 --- /dev/null +++ b/remix-lib/test/util.js @@ -0,0 +1,31 @@ +'use strict' +var tape = require('tape') +var util = require('../src/util') + +tape('Util', function (t) { + t.test('lowerbound', function (st) { + st.plan(7) + var array = [2, 5, 8, 9, 45, 56, 78] + var lowerBound = util.findLowerBound(10, array) + st.equal(lowerBound, 3) + + lowerBound = util.findLowerBound(3, array) + st.equal(lowerBound, 0) + + lowerBound = util.findLowerBound(100, array) + st.equal(lowerBound, 6) + + lowerBound = util.findLowerBound(1, array) + st.equal(lowerBound, -1) + + lowerBound = util.findLowerBound(45, array) + st.equal(lowerBound, 4) + + array = [2, 5, 8, 9, 9, 45, 56, 78] + lowerBound = util.findLowerBound(9, array) + st.equal(lowerBound, 4) + + lowerBound = util.findLowerBound(9, []) + st.equal(lowerBound, -1) + }) +}) diff --git a/remix-solidity/index.js b/remix-solidity/index.js new file mode 100644 index 0000000000..7ab792c37c --- /dev/null +++ b/remix-solidity/index.js @@ -0,0 +1,11 @@ +var InternalCallTree = require('./src/internalCallTree') +var SolidityProxy = require('./src/solidityProxy') +var localDecoder = require('./src/localDecoder') +var stateDecoder = require('./src/stateDecoder') + +module.exports = { + InternalCallTree: InternalCallTree, + SolidityProxy: SolidityProxy, + localDecoder: localDecoder, + stateDecoder: stateDecoder +} diff --git a/remix-solidity/package.json b/remix-solidity/package.json new file mode 100644 index 0000000000..beaa36523c --- /dev/null +++ b/remix-solidity/package.json @@ -0,0 +1,84 @@ +{ + "name": "remix-solidity", + "version": "0.0.2", + "description": "Ethereum IDE and tools for the web", + "contributors": [ + { + "name": "Yann Levreau", + "email": "yann@ethdev.com" + }, + { + "name": "Liana Husikyan", + "email": "liana@ethdev.com" + } + ], + "main": "./index.js", + "dependencies": { + "babel-preset-es2015": "^6.24.0", + "babel-plugin-transform-object-assign": "^6.22.0", + "babel-eslint": "^7.1.1", + "babelify": "^7.3.0", + "ethereumjs-util": "^4.5.0", + "ethereumjs-vm": "2.3.1", + "fast-async": "^6.1.2", + "npm-link-local": "^1.1.0", + "remix-core": "^0.0.1", + "remix-lib": "^0.0.1", + "solc": "^0.4.13", + "standard": "^7.0.1", + "tape": "^4.6.0" + }, + "scripts": { + "postinstall": "npm-link-local ../remix-lib && npm-link-local ../remix-core", + "test": "standard && tape ./test/tests.js" + }, + "standard": { + "ignore": [ + "node_modules/*", + "build/*" + ], + "parser": "babel-eslint" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/ethereum/remix.git" + }, + "author": "cpp-ethereum team", + "license": "MIT", + "bugs": { + "url": "https://github.com/ethereum/remix/issues" + }, + "homepage": "https://github.com/ethereum/remix#readme", + "browserify": { + "transform": [ + [ + "babelify", + { + "plugins": [ + [ + "fast-async", + { + "runtimePatten": null, + "compiler": { + "promises": true, + "es7": true, + "noRuntime": true, + "wrapAwait": true + } + } + ], + "transform-object-assign" + ] + } + ], + [ + "babelify", + { + "presets": [ + "es2015" + ] + } + ] + ] + } +} diff --git a/src/solidity/astHelper.js b/remix-solidity/src/astHelper.js similarity index 98% rename from src/solidity/astHelper.js rename to remix-solidity/src/astHelper.js index 8af6705ccd..88b3a63165 100644 --- a/src/solidity/astHelper.js +++ b/remix-solidity/src/astHelper.js @@ -1,5 +1,6 @@ 'use strict' -var AstWalker = require('../util/astWalker') +var remixLib = require('remix-lib') +var AstWalker = remixLib.AstWalker /** * return all contract definitions of the given @astList diff --git a/src/solidity/decodeInfo.js b/remix-solidity/src/decodeInfo.js similarity index 100% rename from src/solidity/decodeInfo.js rename to remix-solidity/src/decodeInfo.js diff --git a/src/util/internalCallTree.js b/remix-solidity/src/internalCallTree.js similarity index 97% rename from src/util/internalCallTree.js rename to remix-solidity/src/internalCallTree.js index dfe6560ec6..3cace1407c 100644 --- a/src/util/internalCallTree.js +++ b/remix-solidity/src/internalCallTree.js @@ -1,10 +1,11 @@ 'use strict' -var SourceLocationTracker = require('../code/sourceLocationTracker') -var AstWalker = require('./astWalker') -var EventManager = require('../lib/eventManager') -var decodeInfo = require('../solidity/decodeInfo') -var util = require('../helpers/util') -var traceHelper = require('../helpers/traceHelper') +var remixLib = require('remix-lib') +var SourceLocationTracker = remixLib.SourceLocationTracker +var AstWalker = remixLib.AstWalker +var EventManager = remixLib.EventManager +var decodeInfo = require('./decodeInfo') +var util = remixLib.util +var traceHelper = remixLib.helpers.trace /** * Tree representing internal jump into function. diff --git a/src/solidity/localDecoder.js b/remix-solidity/src/localDecoder.js similarity index 100% rename from src/solidity/localDecoder.js rename to remix-solidity/src/localDecoder.js diff --git a/src/solidity/solidityProxy.js b/remix-solidity/src/solidityProxy.js similarity index 97% rename from src/solidity/solidityProxy.js rename to remix-solidity/src/solidityProxy.js index b00f4bb3d5..63a42670e3 100644 --- a/src/solidity/solidityProxy.js +++ b/remix-solidity/src/solidityProxy.js @@ -1,8 +1,9 @@ 'use strict' -var traceHelper = require('../helpers/traceHelper') +var remixLib = require('remix-lib') +var traceHelper = remixLib.helpers.trace var stateDecoder = require('./stateDecoder') var astHelper = require('./astHelper') -var util = require('../helpers/util') +var util = remixLib.util class SolidityProxy { constructor (traceManager, codeManager) { diff --git a/src/solidity/stateDecoder.js b/remix-solidity/src/stateDecoder.js similarity index 100% rename from src/solidity/stateDecoder.js rename to remix-solidity/src/stateDecoder.js diff --git a/src/solidity/types/Address.js b/remix-solidity/src/types/Address.js similarity index 100% rename from src/solidity/types/Address.js rename to remix-solidity/src/types/Address.js diff --git a/src/solidity/types/ArrayType.js b/remix-solidity/src/types/ArrayType.js similarity index 95% rename from src/solidity/types/ArrayType.js rename to remix-solidity/src/types/ArrayType.js index f6ce23c0ac..d8edede107 100644 --- a/src/solidity/types/ArrayType.js +++ b/remix-solidity/src/types/ArrayType.js @@ -1,6 +1,7 @@ 'use strict' var util = require('./util') -var helper = require('../../helpers/util') +var remixLib = require('remix-lib') +var sha3256 = remixLib.util.sha3_256 var BN = require('ethereumjs-util').BN var RefType = require('./RefType') @@ -43,7 +44,7 @@ class ArrayType extends RefType { } if (this.arraySize === 'dynamic') { size = util.toBN('0x' + slotValue) - currentLocation.slot = helper.sha3_256(location.slot) + currentLocation.slot = sha3256(location.slot) } else { size = new BN(this.arraySize) } diff --git a/src/solidity/types/Bool.js b/remix-solidity/src/types/Bool.js similarity index 100% rename from src/solidity/types/Bool.js rename to remix-solidity/src/types/Bool.js diff --git a/src/solidity/types/DynamicByteArray.js b/remix-solidity/src/types/DynamicByteArray.js similarity index 93% rename from src/solidity/types/DynamicByteArray.js rename to remix-solidity/src/types/DynamicByteArray.js index f45fa8fa44..d879b5ef6a 100644 --- a/src/solidity/types/DynamicByteArray.js +++ b/remix-solidity/src/types/DynamicByteArray.js @@ -1,6 +1,7 @@ 'use strict' var util = require('./util') -var helper = require('../../helpers/util') +var remixLib = require('remix-lib') +var sha3256 = remixLib.util.sha3_256 var BN = require('ethereumjs-util').BN var RefType = require('./RefType') @@ -23,7 +24,7 @@ class DynamicByteArray extends RefType { var bn = new BN(value, 16) if (bn.testn(0)) { var length = bn.div(new BN(2)) - var dataPos = new BN(helper.sha3_256(location.slot).replace('0x', ''), 16) + var dataPos = new BN(sha3256(location.slot).replace('0x', ''), 16) var ret = '' var currentSlot = '0x' try { diff --git a/src/solidity/types/Enum.js b/remix-solidity/src/types/Enum.js similarity index 100% rename from src/solidity/types/Enum.js rename to remix-solidity/src/types/Enum.js diff --git a/src/solidity/types/FixedByteArray.js b/remix-solidity/src/types/FixedByteArray.js similarity index 100% rename from src/solidity/types/FixedByteArray.js rename to remix-solidity/src/types/FixedByteArray.js diff --git a/src/solidity/types/Int.js b/remix-solidity/src/types/Int.js similarity index 100% rename from src/solidity/types/Int.js rename to remix-solidity/src/types/Int.js diff --git a/src/solidity/types/Mapping.js b/remix-solidity/src/types/Mapping.js similarity index 100% rename from src/solidity/types/Mapping.js rename to remix-solidity/src/types/Mapping.js diff --git a/src/solidity/types/RefType.js b/remix-solidity/src/types/RefType.js similarity index 100% rename from src/solidity/types/RefType.js rename to remix-solidity/src/types/RefType.js diff --git a/src/solidity/types/StringType.js b/remix-solidity/src/types/StringType.js similarity index 100% rename from src/solidity/types/StringType.js rename to remix-solidity/src/types/StringType.js diff --git a/src/solidity/types/Struct.js b/remix-solidity/src/types/Struct.js similarity index 100% rename from src/solidity/types/Struct.js rename to remix-solidity/src/types/Struct.js diff --git a/src/solidity/types/Uint.js b/remix-solidity/src/types/Uint.js similarity index 100% rename from src/solidity/types/Uint.js rename to remix-solidity/src/types/Uint.js diff --git a/src/solidity/types/ValueType.js b/remix-solidity/src/types/ValueType.js similarity index 100% rename from src/solidity/types/ValueType.js rename to remix-solidity/src/types/ValueType.js diff --git a/src/solidity/types/util.js b/remix-solidity/src/types/util.js similarity index 100% rename from src/solidity/types/util.js rename to remix-solidity/src/types/util.js diff --git a/test/solidity/contracts/byteStorage.js b/remix-solidity/test/contracts/byteStorage.js similarity index 100% rename from test/solidity/contracts/byteStorage.js rename to remix-solidity/test/contracts/byteStorage.js diff --git a/test/solidity/contracts/intLocal.js b/remix-solidity/test/contracts/intLocal.js similarity index 100% rename from test/solidity/contracts/intLocal.js rename to remix-solidity/test/contracts/intLocal.js diff --git a/test/solidity/contracts/intStorage.js b/remix-solidity/test/contracts/intStorage.js similarity index 100% rename from test/solidity/contracts/intStorage.js rename to remix-solidity/test/contracts/intStorage.js diff --git a/test/solidity/contracts/miscContracts.js b/remix-solidity/test/contracts/miscContracts.js similarity index 100% rename from test/solidity/contracts/miscContracts.js rename to remix-solidity/test/contracts/miscContracts.js diff --git a/test/solidity/contracts/miscLocal.js b/remix-solidity/test/contracts/miscLocal.js similarity index 100% rename from test/solidity/contracts/miscLocal.js rename to remix-solidity/test/contracts/miscLocal.js diff --git a/test/solidity/contracts/simpleContract.js b/remix-solidity/test/contracts/simpleContract.js similarity index 100% rename from test/solidity/contracts/simpleContract.js rename to remix-solidity/test/contracts/simpleContract.js diff --git a/test/solidity/contracts/structArrayLocal.js b/remix-solidity/test/contracts/structArrayLocal.js similarity index 100% rename from test/solidity/contracts/structArrayLocal.js rename to remix-solidity/test/contracts/structArrayLocal.js diff --git a/test/solidity/contracts/structArrayStorage.js b/remix-solidity/test/contracts/structArrayStorage.js similarity index 100% rename from test/solidity/contracts/structArrayStorage.js rename to remix-solidity/test/contracts/structArrayStorage.js diff --git a/remix-solidity/test/decodeInfo.js b/remix-solidity/test/decodeInfo.js new file mode 100644 index 0000000000..5eee1d7ab3 --- /dev/null +++ b/remix-solidity/test/decodeInfo.js @@ -0,0 +1,116 @@ +'use strict' +var tape = require('tape') +var compiler = require('solc') +var astHelper = require('../src/astHelper') +var decodeInfo = require('../src/decodeInfo') +var stateDecoder = require('../src/stateDecoder') +var contracts = require('./contracts/miscContracts') +var simplecontracts = require('./contracts/simpleContract') + +tape('solidity', function (t) { + t.test('astHelper, decodeInfo', function (st) { + var output = compiler.compileStandardWrapper(compilerInput(contracts)) + output = JSON.parse(output) + + var state = astHelper.extractStateDefinitions('test.sol:contractUint', output.sources) + var states = astHelper.extractStatesDefinitions(output.sources) + var stateDef = state.stateDefinitions + var parsedType = decodeInfo.parseType(stateDef[0].attributes.type, states, 'contractUint') + checkDecodeInfo(st, parsedType, 1, 1, 'uint8') + parsedType = decodeInfo.parseType(stateDef[2].attributes.type, states, 'contractUint') + checkDecodeInfo(st, parsedType, 1, 32, 'uint256') + parsedType = decodeInfo.parseType(stateDef[3].attributes.type, states, 'contractUint') + checkDecodeInfo(st, parsedType, 1, 32, 'uint256') + parsedType = decodeInfo.parseType(stateDef[4].attributes.type, states, 'contractUint') + checkDecodeInfo(st, parsedType, 1, 16, 'bytes16') + + state = astHelper.extractStateDefinitions('test.sol:contractStructAndArray', output.sources) + stateDef = state.stateDefinitions + parsedType = decodeInfo.parseType(stateDef[1].attributes.type, states, 'contractStructAndArray') + checkDecodeInfo(st, parsedType, 2, 32, 'struct contractStructAndArray.structDef') + parsedType = decodeInfo.parseType(stateDef[2].attributes.type, states, 'contractStructAndArray') + checkDecodeInfo(st, parsedType, 6, 32, 'struct contractStructAndArray.structDef[3]') + parsedType = decodeInfo.parseType(stateDef[3].attributes.type, states, 'contractStructAndArray') + checkDecodeInfo(st, parsedType, 2, 32, 'bytes12[4]') + + state = astHelper.extractStateDefinitions('test.sol:contractArray', output.sources) + stateDef = state.stateDefinitions + parsedType = decodeInfo.parseType(stateDef[0].attributes.type, states, 'contractArray') + checkDecodeInfo(st, parsedType, 1, 32, 'uint32[5]') + parsedType = decodeInfo.parseType(stateDef[1].attributes.type, states, 'contractArray') + checkDecodeInfo(st, parsedType, 1, 32, 'int8[]') + parsedType = decodeInfo.parseType(stateDef[2].attributes.type, states, 'contractArray') + checkDecodeInfo(st, parsedType, 4, 32, 'int16[][3][][4]') + + state = astHelper.extractStateDefinitions('test.sol:contractEnum', output.sources) + stateDef = state.stateDefinitions + parsedType = decodeInfo.parseType(stateDef[1].attributes.type, states, 'contractEnum') + checkDecodeInfo(st, parsedType, 1, 2, 'enum') + + state = astHelper.extractStateDefinitions('test.sol:contractSmallVariable', output.sources) + stateDef = state.stateDefinitions + parsedType = decodeInfo.parseType(stateDef[0].attributes.type, states, 'contractSmallVariable') + checkDecodeInfo(st, parsedType, 1, 1, 'int8') + parsedType = decodeInfo.parseType(stateDef[1].attributes.type, states, 'contractSmallVariable') + checkDecodeInfo(st, parsedType, 1, 1, 'uint8') + parsedType = decodeInfo.parseType(stateDef[2].attributes.type, states, 'contractSmallVariable') + checkDecodeInfo(st, parsedType, 1, 2, 'uint16') + parsedType = decodeInfo.parseType(stateDef[3].attributes.type, states, 'contractSmallVariable') + checkDecodeInfo(st, parsedType, 1, 4, 'int32') + parsedType = decodeInfo.parseType(stateDef[4].attributes.type, states, 'contractSmallVariable') + checkDecodeInfo(st, parsedType, 1, 32, 'uint256') + parsedType = decodeInfo.parseType(stateDef[5].attributes.type, states, 'contractSmallVariable') + checkDecodeInfo(st, parsedType, 1, 2, 'int16') + + output = compiler.compileStandardWrapper(compilerInput(simplecontracts)) + output = JSON.parse(output) + + state = astHelper.extractStateDefinitions('test.sol:simpleContract', output.sources) + states = astHelper.extractStatesDefinitions(output.sources) + stateDef = state.stateDefinitions + parsedType = decodeInfo.parseType(stateDef[2].attributes.type, states, 'simpleContract') + checkDecodeInfo(st, parsedType, 2, 32, 'struct simpleContract.structDef') + parsedType = decodeInfo.parseType(stateDef[3].attributes.type, states, 'simpleContract') + checkDecodeInfo(st, parsedType, 6, 32, 'struct simpleContract.structDef[3]') + parsedType = decodeInfo.parseType(stateDef[4].attributes.type, states, 'simpleContract') + checkDecodeInfo(st, parsedType, 1, 1, 'enum') + + state = astHelper.extractStateDefinitions('test.sol:test2', output.sources) + stateDef = state.stateDefinitions + parsedType = decodeInfo.parseType(stateDef[0].attributes.type, states, 'test1') + checkDecodeInfo(st, parsedType, 0, 32, 'struct test1.str') + + state = stateDecoder.extractStateVariables('test.sol:test2', output.sources) + checkDecodeInfo(st, parsedType, 0, 32, 'struct test1.str') + + st.end() + }) +}) + +function checkDecodeInfo (st, decodeInfo, storageSlots, storageBytes, typeName) { + st.equal(decodeInfo.storageSlots, storageSlots) + st.equal(decodeInfo.storageBytes, storageBytes) + st.equal(decodeInfo.typeName, typeName) +} + +function compilerInput (contracts) { + return JSON.stringify({ + language: 'Solidity', + sources: { + 'test.sol': { + content: contracts + } + }, + settings: { + optimizer: { + enabled: false, + runs: 500 + } + }, + outputSelection: { + '*': { + '*': [ 'metadata', 'evm.bytecode', 'abi', 'legacyAST', 'metadata', 'evm.assembly', 'evm.methodIdentifiers', 'evm.gasEstimates' ] + } + } + }) +} diff --git a/test/solidity/localDecoder.js b/remix-solidity/test/localDecoder.js similarity index 68% rename from test/solidity/localDecoder.js rename to remix-solidity/test/localDecoder.js index db58beee1b..af9c0500ea 100644 --- a/test/solidity/localDecoder.js +++ b/remix-solidity/test/localDecoder.js @@ -6,13 +6,13 @@ var miscLocal = require('./contracts/miscLocal') var structArrayLocal = require('./contracts/structArrayLocal') var VM = require('ethereumjs-vm') var utileth = require('ethereumjs-util') -var Web3Providers = require('../../src/web3Provider/web3Providers') -var util = require('../../src/helpers/global') +var remixLib = require('remix-lib') +var Web3Providers = remixLib.vm.Web3Providers +var global = remixLib.global var intLocalTest = require('./localsTests/int') var miscLocalTest = require('./localsTests/misc') var misc2LocalTest = require('./localsTests/misc2') var structArrayLocalTest = require('./localsTests/structArray') -var helpers = require('../helpers.js') tape('solidity', function (t) { t.test('local decoder', function (st) { @@ -40,7 +40,7 @@ function initVM (st, address) { console.log(mes) st.fail(mes) } else { - util.web3 = obj + global.web3 = obj st.end() } }) @@ -48,19 +48,41 @@ function initVM (st, address) { } function test (st, vm, privateKey) { - var output = compiler.compileStandardWrapper(helpers.compilerInput(intLocal.contract)) + var output = compiler.compileStandardWrapper(compilerInput(intLocal.contract)) output = JSON.parse(output) intLocalTest(st, vm, privateKey, output.contracts['test.sol']['intLocal'].evm.bytecode.object, output, function () { - output = compiler.compileStandardWrapper(helpers.compilerInput(miscLocal.contract)) + output = compiler.compileStandardWrapper(compilerInput(miscLocal.contract)) output = JSON.parse(output) miscLocalTest(st, vm, privateKey, output.contracts['test.sol']['miscLocal'].evm.bytecode.object, output, function () { - output = compiler.compileStandardWrapper(helpers.compilerInput(miscLocal.contract)) + output = compiler.compileStandardWrapper(compilerInput(miscLocal.contract)) output = JSON.parse(output) misc2LocalTest(st, vm, privateKey, output.contracts['test.sol']['miscLocal2'].evm.bytecode.object, output, function () { - output = compiler.compileStandardWrapper(helpers.compilerInput(structArrayLocal.contract)) + output = compiler.compileStandardWrapper(compilerInput(structArrayLocal.contract)) output = JSON.parse(output) structArrayLocalTest(st, vm, privateKey, output.contracts['test.sol']['structArrayLocal'].evm.bytecode.object, output, function () {}) }) }) }) } + +function compilerInput (contracts) { + return JSON.stringify({ + language: 'Solidity', + sources: { + 'test.sol': { + content: contracts + } + }, + settings: { + optimizer: { + enabled: false, + runs: 500 + } + }, + outputSelection: { + '*': { + '*': [ 'metadata', 'evm.bytecode', 'abi', 'legacyAST', 'metadata', 'evm.assembly', 'evm.methodIdentifiers', 'evm.gasEstimates' ] + } + } + }) +} diff --git a/test/solidity/localsTests/helper.js b/remix-solidity/test/localsTests/helper.js similarity index 90% rename from test/solidity/localsTests/helper.js rename to remix-solidity/test/localsTests/helper.js index d4564123ca..2c7ea7bfd0 100644 --- a/test/solidity/localsTests/helper.js +++ b/remix-solidity/test/localsTests/helper.js @@ -1,5 +1,5 @@ 'use strict' -var localDecoder = require('../../../src/solidity/localDecoder') +var localDecoder = require('../../src/localDecoder') /* Decode local variable diff --git a/test/solidity/localsTests/int.js b/remix-solidity/test/localsTests/int.js similarity index 90% rename from test/solidity/localsTests/int.js rename to remix-solidity/test/localsTests/int.js index fd31e49592..ad686aa08e 100644 --- a/test/solidity/localsTests/int.js +++ b/remix-solidity/test/localsTests/int.js @@ -1,12 +1,15 @@ 'use strict' -var TraceManager = require('../../../src/trace/traceManager') -var CodeManager = require('../../../src/code/codeManager') +var remixCore = require('remix-core') +var TraceManager = remixCore.trace.TraceManager +var CodeManager = remixCore.code.CodeManager var vmSendTx = require('./vmCall') -var traceHelper = require('../../../src/helpers/traceHelper') -var util = require('../../../src/helpers/global') -var SolidityProxy = require('../../../src/solidity/solidityProxy') -var InternalCallTree = require('../../../src/util/internalCallTree') -var EventManager = require('../../../src/lib/eventManager') +var remixLib = require('remix-lib') + +var traceHelper = remixLib.helpers.trace +var global = remixLib.global +var SolidityProxy = require('../../src/solidityProxy') +var InternalCallTree = require('../../src/internalCallTree') +var EventManager = remixLib.EventManager var helper = require('./helper') module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { @@ -14,7 +17,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu if (error) { st.fail(error) } else { - util.web3.getTransaction(txHash, function (error, tx) { + global.web3.getTransaction(txHash, function (error, tx) { if (error) { st.fail(error) } else { diff --git a/test/solidity/localsTests/misc.js b/remix-solidity/test/localsTests/misc.js similarity index 86% rename from test/solidity/localsTests/misc.js rename to remix-solidity/test/localsTests/misc.js index 599b7493a6..182284b8c9 100644 --- a/test/solidity/localsTests/misc.js +++ b/remix-solidity/test/localsTests/misc.js @@ -1,12 +1,14 @@ 'use strict' -var TraceManager = require('../../../src/trace/traceManager') -var CodeManager = require('../../../src/code/codeManager') +var remixCore = require('remix-core') +var TraceManager = remixCore.trace.TraceManager +var CodeManager = remixCore.code.CodeManager var vmSendTx = require('./vmCall') -var traceHelper = require('../../../src/helpers/traceHelper') -var util = require('../../../src/helpers/global') -var SolidityProxy = require('../../../src/solidity/solidityProxy') -var InternalCallTree = require('../../../src/util/internalCallTree') -var EventManager = require('../../../src/lib/eventManager') +var remixLib = require('remix-lib') +var traceHelper = remixLib.helpers.trace +var global = remixLib.global +var SolidityProxy = require('../../src/solidityProxy') +var InternalCallTree = require('../../src/internalCallTree') +var EventManager = remixLib.EventManager var helper = require('./helper') module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { @@ -14,7 +16,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu if (error) { st.fail(error) } else { - util.web3.getTransaction(txHash, function (error, tx) { + global.web3.getTransaction(txHash, function (error, tx) { if (error) { st.fail(error) } else { diff --git a/test/solidity/localsTests/misc2.js b/remix-solidity/test/localsTests/misc2.js similarity index 80% rename from test/solidity/localsTests/misc2.js rename to remix-solidity/test/localsTests/misc2.js index 7feeea47fa..13cdfa814d 100644 --- a/test/solidity/localsTests/misc2.js +++ b/remix-solidity/test/localsTests/misc2.js @@ -1,12 +1,14 @@ 'use strict' -var TraceManager = require('../../../src/trace/traceManager') -var CodeManager = require('../../../src/code/codeManager') +var remixCore = require('remix-core') +var TraceManager = remixCore.trace.TraceManager +var CodeManager = remixCore.code.CodeManager var vmSendTx = require('./vmCall') -var traceHelper = require('../../../src/helpers/traceHelper') -var util = require('../../../src/helpers/global') -var SolidityProxy = require('../../../src/solidity/solidityProxy') -var InternalCallTree = require('../../../src/util/internalCallTree') -var EventManager = require('../../../src/lib/eventManager') +var remixLib = require('remix-lib') +var traceHelper = remixLib.helpers.trace +var global = remixLib.global +var SolidityProxy = require('../../src/solidityProxy') +var InternalCallTree = require('../../src/internalCallTree') +var EventManager = remixLib.EventManager var helper = require('./helper') module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { @@ -14,7 +16,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu if (error) { st.fail(error) } else { - util.web3.getTransaction(txHash, function (error, tx) { + global.web3.getTransaction(txHash, function (error, tx) { if (error) { st.fail(error) } else { diff --git a/test/solidity/localsTests/structArray.js b/remix-solidity/test/localsTests/structArray.js similarity index 94% rename from test/solidity/localsTests/structArray.js rename to remix-solidity/test/localsTests/structArray.js index 0adfafa078..1d8e445cfe 100644 --- a/test/solidity/localsTests/structArray.js +++ b/remix-solidity/test/localsTests/structArray.js @@ -1,12 +1,14 @@ 'use strict' -var TraceManager = require('../../../src/trace/traceManager') -var CodeManager = require('../../../src/code/codeManager') +var remixCore = require('remix-core') +var TraceManager = remixCore.trace.TraceManager +var CodeManager = remixCore.code.CodeManager var vmSendTx = require('./vmCall') -var traceHelper = require('../../../src/helpers/traceHelper') -var util = require('../../../src/helpers/global') -var SolidityProxy = require('../../../src/solidity/solidityProxy') -var InternalCallTree = require('../../../src/util/internalCallTree') -var EventManager = require('../../../src/lib/eventManager') +var remixLib = require('remix-lib') +var traceHelper = remixLib.helpers.trace +var global = remixLib.global +var SolidityProxy = require('../../src/solidityProxy') +var InternalCallTree = require('../../src/internalCallTree') +var EventManager = remixLib.EventManager var helper = require('./helper') module.exports = function (st, vm, privateKey, contractBytecode, compilationResult, cb) { @@ -14,7 +16,7 @@ module.exports = function (st, vm, privateKey, contractBytecode, compilationResu if (error) { st.fail(error) } else { - util.web3.getTransaction(txHash, function (error, tx) { + global.web3.getTransaction(txHash, function (error, tx) { if (error) { st.fail(error) } else { diff --git a/test/solidity/localsTests/vmCall.js b/remix-solidity/test/localsTests/vmCall.js similarity index 100% rename from test/solidity/localsTests/vmCall.js rename to remix-solidity/test/localsTests/vmCall.js diff --git a/test/solidity/mockStorageResolver.js b/remix-solidity/test/mockStorageResolver.js similarity index 91% rename from test/solidity/mockStorageResolver.js rename to remix-solidity/test/mockStorageResolver.js index bdf55ba575..a41d4f32f8 100644 --- a/test/solidity/mockStorageResolver.js +++ b/remix-solidity/test/mockStorageResolver.js @@ -1,5 +1,6 @@ 'use strict' -var util = require('../../src/helpers/util') +var remixLib = require('remix-lib') +var util = remixLib.util class MockStorageResolver { constructor (_storage) { diff --git a/test/solidity/storageDecoder.js b/remix-solidity/test/storageDecoder.js similarity index 95% rename from test/solidity/storageDecoder.js rename to remix-solidity/test/storageDecoder.js index 3d8eef2de9..ce3acc014b 100644 --- a/test/solidity/storageDecoder.js +++ b/remix-solidity/test/storageDecoder.js @@ -1,9 +1,8 @@ 'use strict' var tape = require('tape') var compiler = require('solc') -var stateDecoder = require('../../src/index').solidity.stateDecoder +var stateDecoder = require('../src/stateDecoder') var MockStorageResolver = require('./mockStorageResolver') -var helpers = require('../helpers.js') tape('solidity', function (t) { t.test('storage decoder', function (st) { @@ -19,7 +18,7 @@ tape('solidity', function (t) { function testIntStorage (st, cb) { var intStorage = require('./contracts/intStorage') - var output = compiler.compileStandardWrapper(helpers.compilerInput(intStorage.contract)) + var output = compiler.compileStandardWrapper(compilerInput(intStorage.contract)) output = JSON.parse(output) var mockStorageResolver for (var storage of [intStorage.fullStorage, shrinkStorage(intStorage.fullStorage)]) { @@ -66,7 +65,7 @@ function testIntStorage (st, cb) { function testByteStorage (st, cb) { var byteStorage = require('./contracts/byteStorage') - var output = compiler.compileStandardWrapper(helpers.compilerInput(byteStorage.contract)) + var output = compiler.compileStandardWrapper(compilerInput(byteStorage.contract)) output = JSON.parse(output) var mockStorageResolver for (var storage of [byteStorage.storage, shrinkStorage(byteStorage.storage)]) { @@ -179,7 +178,7 @@ function shrinkStorage (storage) { function testStructArrayStorage (st, cb) { var structArrayStorage = require('./contracts/structArrayStorage') - var output = compiler.compileStandardWrapper(helpers.compilerInput(structArrayStorage.contract)) + var output = compiler.compileStandardWrapper(compilerInput(structArrayStorage.contract)) output = JSON.parse(output) var mockStorageResolver = new MockStorageResolver(structArrayStorage.storage) stateDecoder.solidityState(mockStorageResolver, output.sources, 'structArrayStorage').then((decoded) => { @@ -270,3 +269,25 @@ function testStructArrayStorage (st, cb) { cb() }) } + +function compilerInput (contracts) { + return JSON.stringify({ + language: 'Solidity', + sources: { + 'test.sol': { + content: contracts + } + }, + settings: { + optimizer: { + enabled: false, + runs: 500 + } + }, + outputSelection: { + '*': { + '*': [ 'metadata', 'evm.bytecode', 'abi', 'legacyAST', 'metadata', 'evm.assembly', 'evm.methodIdentifiers', 'evm.gasEstimates' ] + } + } + }) +} diff --git a/test/solidity/storageLocation.js b/remix-solidity/test/storageLocation.js similarity index 66% rename from test/solidity/storageLocation.js rename to remix-solidity/test/storageLocation.js index fe102aec64..1eb9c9b73e 100644 --- a/test/solidity/storageLocation.js +++ b/remix-solidity/test/storageLocation.js @@ -1,31 +1,30 @@ 'use strict' var tape = require('tape') var compiler = require('solc') -var index = require('../../src/index') +var stateDecoder = require('../src/stateDecoder') var contracts = require('./contracts/miscContracts') -var helpers = require('../helpers.js') tape('solidity', function (t) { t.test('storage location', function (st) { - var output = compiler.compileStandardWrapper(helpers.compilerInput(contracts)) + var output = compiler.compileStandardWrapper(compilerInput(contracts)) output = JSON.parse(output) - var stateDec = index.solidity.stateDecoder.extractStateVariables('contractUint', output.sources) + var stateDec = stateDecoder.extractStateVariables('contractUint', output.sources) checkLocation(st, stateDec[0].storagelocation, 0, 0) checkLocation(st, stateDec[1].storagelocation, 1, 0) checkLocation(st, stateDec[2].storagelocation, 2, 0) checkLocation(st, stateDec[3].storagelocation, 3, 0) - stateDec = index.solidity.stateDecoder.extractStateVariables('contractStructAndArray', output.sources) + stateDec = stateDecoder.extractStateVariables('contractStructAndArray', output.sources) checkLocation(st, stateDec[0].storagelocation, 0, 0) checkLocation(st, stateDec[1].storagelocation, 2, 0) checkLocation(st, stateDec[2].storagelocation, 8, 0) - stateDec = index.solidity.stateDecoder.extractStateVariables('contractArray', output.sources) + stateDec = stateDecoder.extractStateVariables('contractArray', output.sources) checkLocation(st, stateDec[0].storagelocation, 0, 0) checkLocation(st, stateDec[1].storagelocation, 1, 0) checkLocation(st, stateDec[2].storagelocation, 2, 0) - stateDec = index.solidity.stateDecoder.extractStateVariables('contractSmallVariable', output.sources) + stateDec = stateDecoder.extractStateVariables('contractSmallVariable', output.sources) checkLocation(st, stateDec[0].storagelocation, 0, 0) checkLocation(st, stateDec[1].storagelocation, 0, 1) checkLocation(st, stateDec[2].storagelocation, 0, 2) @@ -33,7 +32,7 @@ tape('solidity', function (t) { checkLocation(st, stateDec[4].storagelocation, 1, 0) checkLocation(st, stateDec[5].storagelocation, 2, 0) - stateDec = index.solidity.stateDecoder.extractStateVariables('testSimpleStorage', output.sources) + stateDec = stateDecoder.extractStateVariables('testSimpleStorage', output.sources) checkLocation(st, stateDec[0].storagelocation, 0, 0) checkLocation(st, stateDec[1].storagelocation, 1, 0) checkLocation(st, stateDec[2].storagelocation, 2, 0) @@ -57,3 +56,24 @@ function checkLocation (st, location, slot, offset) { st.equal(location.slot, slot) } +function compilerInput (contracts) { + return JSON.stringify({ + language: 'Solidity', + sources: { + 'test.sol': { + content: contracts + } + }, + settings: { + optimizer: { + enabled: false, + runs: 500 + } + }, + outputSelection: { + '*': { + '*': [ 'metadata', 'evm.bytecode', 'abi', 'legacyAST', 'metadata', 'evm.assembly', 'evm.methodIdentifiers', 'evm.gasEstimates' ] + } + } + }) +} diff --git a/remix-solidity/test/tests.js b/remix-solidity/test/tests.js new file mode 100644 index 0000000000..13577ea0cd --- /dev/null +++ b/remix-solidity/test/tests.js @@ -0,0 +1,4 @@ +require('./decodeInfo.js') +require('./storageLocation.js') +require('./storageDecoder.js') +require('./localDecoder.js') diff --git a/src/helpers/global.js b/src/helpers/global.js deleted file mode 100644 index e652127824..0000000000 --- a/src/helpers/global.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict' -module.exports = { - extend: function (destination, source) { - for (var property in source) { - destination[property] = source[property] - } - }, - web3: null -} diff --git a/src/helpers/init.js b/src/helpers/init.js deleted file mode 100644 index fdf71cf492..0000000000 --- a/src/helpers/init.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict' -var Web3 = require('web3') -var Web3Admin = require('../util/web3Admin') - -module.exports = { - loadWeb3: function () { - var web3 = new Web3() - web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')) - Web3Admin.extend(web3) - return web3 - }, - - extendWeb3: function (web3) { - Web3Admin.extend(web3) - }, - - setProvider: function (web3, url) { - web3.setProvider(new web3.providers.HttpProvider(url)) - } -} diff --git a/src/index.js b/src/index.js deleted file mode 100644 index 671368af4c..0000000000 --- a/src/index.js +++ /dev/null @@ -1,62 +0,0 @@ -'use strict' -var VMDebugger = require('./ui/VmDebugger') -var Debugger = require('./ui/Ethdebugger') -var BasicPanel = require('./ui/BasicPanel') -var TreeView = require('./ui/TreeView') -var TraceManager = require('./trace/traceManager') -var CodeManager = require('./code/codeManager') -var disassembler = require('./code/disassembler') -var BreakpointManager = require('./code/breakpointManager') -var SourceMappingDecoder = require('./util/sourceMappingDecoder') -var AstWalker = require('./util/astWalker') -var decodeInfo = require('./solidity/decodeInfo') -var stateDecoder = require('./solidity/stateDecoder') -var astHelper = require('./solidity/astHelper') -var EventManager = require('./lib/eventManager') -var codeUtil = require('./helpers/util') -var web3VMProvider = require('./web3Provider/web3VmProvider') -var styleGuide = require('./ui/styles/style-guide') - -if (typeof (module) !== 'undefined' && typeof (module.exports) !== 'undefined') { - module.exports = modules() -} - -if (typeof (window) !== 'undefined') { - window.remix = modules() -} - -function modules () { - return { - code: { - codeManager: CodeManager, - disassembler: disassembler, - BreakpointManager: BreakpointManager - }, - trace: { - traceManager: TraceManager - }, - ui: { - Debugger: Debugger, - VMdebugger: VMDebugger, - BasicPanel: BasicPanel, - TreeView: TreeView, - styleGuide: styleGuide - }, - util: { - SourceMappingDecoder: SourceMappingDecoder, - AstWalker: AstWalker, - code: codeUtil - }, - solidity: { - decodeInfo: decodeInfo, - astHelper: astHelper, - stateDecoder: stateDecoder - }, - lib: { - EventManager: EventManager - }, - web3: { - web3VMProvider: web3VMProvider - } - } -} diff --git a/test/helpers.js b/test/helpers.js deleted file mode 100644 index e1d92bddac..0000000000 --- a/test/helpers.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict' - -module.exports = { - compilerInput: (contracts) => { - return JSON.stringify({ - language: 'Solidity', - sources: { - 'test.sol': { - content: contracts - } - }, - settings: { - optimizer: { - enabled: false, - runs: 500 - } - }, - outputSelection: { - '*': { - '*': [ 'metadata', 'evm.bytecode', 'abi', 'legacyAST', 'metadata', 'evm.assembly', 'evm.methodIdentifiers', 'evm.gasEstimates' ] - } - } - }) - } - -} diff --git a/test/index.js b/test/index.js deleted file mode 100644 index 3dc4dc0e23..0000000000 --- a/test/index.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict' -var tape = require('tape') -var init = require('../src/helpers/init') -tape('index', function (t) { - t.test('loadContext - web3', function (st) { - var web3 = init.loadWeb3() - st.notEqual(web3, undefined) - st.notEqual(web3, null) - st.end() - }) -}) diff --git a/test/solidity/decodeInfo.js b/test/solidity/decodeInfo.js deleted file mode 100644 index 67909f8c9f..0000000000 --- a/test/solidity/decodeInfo.js +++ /dev/null @@ -1,93 +0,0 @@ -'use strict' -var tape = require('tape') -var compiler = require('solc') -var index = require('../../src/index') -var contracts = require('./contracts/miscContracts') -var simplecontracts = require('./contracts/simpleContract') -var helpers = require('../helpers.js') - -tape('solidity', function (t) { - t.test('astHelper, decodeInfo', function (st) { - var output = compiler.compileStandardWrapper(helpers.compilerInput(contracts)) - output = JSON.parse(output) - - var state = index.solidity.astHelper.extractStateDefinitions('test.sol:contractUint', output.sources) - var states = index.solidity.astHelper.extractStatesDefinitions(output.sources) - var stateDef = state.stateDefinitions - var decodeInfo = index.solidity.decodeInfo.parseType(stateDef[0].attributes.type, states, 'contractUint') - checkDecodeInfo(st, decodeInfo, 1, 1, 'uint8') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[2].attributes.type, states, 'contractUint') - checkDecodeInfo(st, decodeInfo, 1, 32, 'uint256') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[3].attributes.type, states, 'contractUint') - checkDecodeInfo(st, decodeInfo, 1, 32, 'uint256') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[4].attributes.type, states, 'contractUint') - checkDecodeInfo(st, decodeInfo, 1, 16, 'bytes16') - - state = index.solidity.astHelper.extractStateDefinitions('test.sol:contractStructAndArray', output.sources) - stateDef = state.stateDefinitions - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[1].attributes.type, states, 'contractStructAndArray') - checkDecodeInfo(st, decodeInfo, 2, 32, 'struct contractStructAndArray.structDef') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[2].attributes.type, states, 'contractStructAndArray') - checkDecodeInfo(st, decodeInfo, 6, 32, 'struct contractStructAndArray.structDef[3]') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[3].attributes.type, states, 'contractStructAndArray') - checkDecodeInfo(st, decodeInfo, 2, 32, 'bytes12[4]') - - state = index.solidity.astHelper.extractStateDefinitions('test.sol:contractArray', output.sources) - stateDef = state.stateDefinitions - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[0].attributes.type, states, 'contractArray') - checkDecodeInfo(st, decodeInfo, 1, 32, 'uint32[5]') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[1].attributes.type, states, 'contractArray') - checkDecodeInfo(st, decodeInfo, 1, 32, 'int8[]') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[2].attributes.type, states, 'contractArray') - checkDecodeInfo(st, decodeInfo, 4, 32, 'int16[][3][][4]') - - state = index.solidity.astHelper.extractStateDefinitions('test.sol:contractEnum', output.sources) - stateDef = state.stateDefinitions - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[1].attributes.type, states, 'contractEnum') - checkDecodeInfo(st, decodeInfo, 1, 2, 'enum') - - state = index.solidity.astHelper.extractStateDefinitions('test.sol:contractSmallVariable', output.sources) - stateDef = state.stateDefinitions - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[0].attributes.type, states, 'contractSmallVariable') - checkDecodeInfo(st, decodeInfo, 1, 1, 'int8') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[1].attributes.type, states, 'contractSmallVariable') - checkDecodeInfo(st, decodeInfo, 1, 1, 'uint8') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[2].attributes.type, states, 'contractSmallVariable') - checkDecodeInfo(st, decodeInfo, 1, 2, 'uint16') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[3].attributes.type, states, 'contractSmallVariable') - checkDecodeInfo(st, decodeInfo, 1, 4, 'int32') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[4].attributes.type, states, 'contractSmallVariable') - checkDecodeInfo(st, decodeInfo, 1, 32, 'uint256') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[5].attributes.type, states, 'contractSmallVariable') - checkDecodeInfo(st, decodeInfo, 1, 2, 'int16') - - output = compiler.compileStandardWrapper(helpers.compilerInput(simplecontracts)) - output = JSON.parse(output) - - state = index.solidity.astHelper.extractStateDefinitions('test.sol:simpleContract', output.sources) - states = index.solidity.astHelper.extractStatesDefinitions(output.sources) - stateDef = state.stateDefinitions - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[2].attributes.type, states, 'simpleContract') - checkDecodeInfo(st, decodeInfo, 2, 32, 'struct simpleContract.structDef') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[3].attributes.type, states, 'simpleContract') - checkDecodeInfo(st, decodeInfo, 6, 32, 'struct simpleContract.structDef[3]') - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[4].attributes.type, states, 'simpleContract') - checkDecodeInfo(st, decodeInfo, 1, 1, 'enum') - - state = index.solidity.astHelper.extractStateDefinitions('test.sol:test2', output.sources) - stateDef = state.stateDefinitions - decodeInfo = index.solidity.decodeInfo.parseType(stateDef[0].attributes.type, states, 'test1') - checkDecodeInfo(st, decodeInfo, 0, 32, 'struct test1.str') - - state = index.solidity.stateDecoder.extractStateVariables('test.sol:test2', output.sources) - checkDecodeInfo(st, decodeInfo, 0, 32, 'struct test1.str') - - st.end() - }) -}) - -function checkDecodeInfo (st, decodeInfo, storageSlots, storageBytes, typeName) { - st.equal(decodeInfo.storageSlots, storageSlots) - st.equal(decodeInfo.storageBytes, storageBytes) - st.equal(decodeInfo.typeName, typeName) -} diff --git a/test/sourceMappingDecoder.js b/test/sourceMappingDecoder.js deleted file mode 100644 index 6a6579a0e9..0000000000 --- a/test/sourceMappingDecoder.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict' -var tape = require('tape') -var SourceMappingDecoder = require('../src/util/sourceMappingDecoder') -var compiler = require('solc') -var helpers = require('./helpers.js') - -tape('SourceMappingDecoder', function (t) { - t.test('SourceMappingDecoder.findNodeAtInstructionIndex', function (st) { - var output = compiler.compileStandardWrapper(helpers.compilerInput(contracts)) - output = JSON.parse(output) - var sourceMappingDecoder = new SourceMappingDecoder() - var node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 2, output.contracts['test.sol']['test'].evm.deployedBytecode.sourceMap, output.sources['test.sol']) - st.equal(node, null) - node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 80, output.contracts['test.sol']['test'].evm.deployedBytecode.sourceMap, output.sources['test.sol']) - st.notEqual(node, null) - if (node) { - st.equal(node.attributes.name, 'f1') - } - st.end() - }) -}) - -var contracts = `contract test { - function f1() returns (uint) { - uint t = 4; - return t; - } - - function f2() { - - } -} -` diff --git a/test/tests.js b/test/tests.js deleted file mode 100644 index bcdab7bd47..0000000000 --- a/test/tests.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict' -require('./index.js') -require('./traceManager.js') -require('./codeManager.js') -require('./util.js') -require('./astwalker.js') -require('./disassembler.js') -require('./eventManager.js') -require('./sourceMappingDecoder.js') -require('./solidity/decodeInfo.js') -require('./solidity/storageLocation.js') -require('./solidity/storageDecoder.js') -require('./solidity/localDecoder.js') -