Unverified Commit 43fd1f97 authored by yann300's avatar yann300 Committed by GitHub

Merge branch 'master' into include_remix_test_sol

parents f74d765a 0afe8e3e
...@@ -11,3 +11,4 @@ package-lock.json ...@@ -11,3 +11,4 @@ package-lock.json
.tern-port .tern-port
TODO TODO
soljson.js soljson.js
lerna-debug.log
[submodule "remixd"]
path = remixd
url = https://github.com/ethereum/remixd
language: node_js
node_js:
- stable
env:
- TEST_DIR=remix-lib
- TEST_DIR=remix-solidity
- TEST_DIR=remix-debug
- TEST_DIR=remix-tests
- TEST_DIR=remix-simulator
script:
- cd $TEST_DIR && npm install && npm test
deploy:
provider: script
script: remix-debugger/ci/deploy_from_travis.sh
skip_cleanup: true
on:
branch: master
condition: $TEST_DIR = remix-debugger
cache: false
# Remix # Remix
[![Join the chat at https://gitter.im/ethereum/remix](https://badges.gitter.im/ethereum/remix.svg)](https://gitter.im/ethereum/remix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join the chat at https://gitter.im/ethereum/remix](https://badges.gitter.im/ethereum/remix.svg)](https://gitter.im/ethereum/remix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![CircleCI](https://circleci.com/gh/ethereum/remix.svg?style=svg)](https://circleci.com/gh/ethereum/remix) [![CircleCI](https://circleci.com/gh/ethereum/remix/tree/master.svg?style=svg)](https://circleci.com/gh/ethereum/remix/tree/master)
[![Documentation Status](https://readthedocs.org/projects/docs/badge/?version=latest)](https://remix.readthedocs.io/en/latest/) [![Documentation Status](https://readthedocs.org/projects/docs/badge/?version=latest)](https://remix.readthedocs.io/en/latest/)
Ethereum tools for the web. Ethereum tools for the web.
...@@ -50,6 +50,7 @@ Remix is built out of several different modules: ...@@ -50,6 +50,7 @@ Remix is built out of several different modules:
+ [`remix-lib`](remix-lib/README.md) + [`remix-lib`](remix-lib/README.md)
+ [`remix-debug`](remix-debugger/README.md) is now *deprecated*. It contains the debugger. + [`remix-debug`](remix-debugger/README.md) is now *deprecated*. It contains the debugger.
+ [`remix-tests`](remix-tests/README.md) contains our tests. + [`remix-tests`](remix-tests/README.md) contains our tests.
+ [`remixd`](https://github.com/ethereum/remixd/tree/master) CLI which allow accessing local element from Remix IDE (see https://remix.readthedocs.io/en/latest/tutorial_remixd_filesystem.html)
Each generally has their own npm package and test suite, as well as basic documentation. Each generally has their own npm package and test suite, as well as basic documentation.
......
...@@ -10,8 +10,11 @@ The code of RemixD can be checked out ...@@ -10,8 +10,11 @@ The code of RemixD can be checked out
Remixd can be globally installed using the following command: Remixd can be globally installed using the following command:
`npm install -g remixd`. `npm install -g remixd`.
Then `remixd -s <absolute-path-to-the-shared-folder>` will start Remixd Then `remixd -s <absolute-path-to-the-shared-folder> --remix-ide <your-remix-ide-URL-instance>` will start Remixd
and share the given folder. and share the given folder.
For example, to sync your local folder to the official Remix IDE,
`remixd -s <absolute-path-to-the-shared-folder> --remix-ide https://remix.ethereum.org`
The folder is shared using a websocket connection between `Remix IDE` The folder is shared using a websocket connection between `Remix IDE`
and `Remixd`. and `Remixd`.
......
...@@ -24,8 +24,12 @@ This execute tests. The execution is run in a separate environment and the resul ...@@ -24,8 +24,12 @@ This execute tests. The execution is run in a separate environment and the resul
| `Assert.greaterThan()` | `uint`, `int` | | `Assert.greaterThan()` | `uint`, `int` |
| `Assert.lesserThan()` | `uint`, `int` | | `Assert.lesserThan()` | `uint`, `int` |
see [https://github.com/ethereum/remix/blob/master/remix-tests/tests/examples_4/SafeMath_test.sol](https://github.com/ethereum/remix/blob/master/remix-tests/tests/examples_4/SafeMath_test.sol) for some code sample
Continuous integration Continuous integration
---------------------- ----------------------
remix-tests is also a CLI, it can be used in a continuous integration environement which support node.js. remix-tests is also a CLI, it can be used in a continuous integration environement which support node.js.
Please find more information in the [remix-test repository](https://github.com/ethereum/remix/tree/master/remix-tests) Please find more information in the [remix-test repository](https://github.com/ethereum/remix/tree/master/remix-tests)
See also: example [Su Squares contract](https://github.com/su-squares/ethereum-contract/tree/e542f37d4f8f6c7b07d90a6554424268384a4186) and [https://travis-ci.org/su-squares/ethereum-contract/builds/446186067](Travis build) that uses remix-tests for continuous integration testing.
...@@ -10,5 +10,5 @@ This tutorial was used in workshops at ethCC, Edcon, and DappCon. ...@@ -10,5 +10,5 @@ This tutorial was used in workshops at ethCC, Edcon, and DappCon.
You can [watch the Edcon presentation talk](https://www.youtube.com/watch?v=nAI_Cr5Y8JY) and here are the [workshop slides](https://slides.com/ninabreznik/deck-11-13#/). You can [watch the Edcon presentation talk](https://www.youtube.com/watch?v=nAI_Cr5Y8JY) and here are the [workshop slides](https://slides.com/ninabreznik/deck-11-13#/).
(May 3, 2018) (May 3, 2018)
Here are the [DappCon slides (hosted on swarm)](https://30400.swarm-gateways.net/bzz:/2271229d214f8aef9b1176bc22dbc09e384cd8c577a87c60ebece68aebc59d3a/) and here are the [DappCon slides (not on swarm)](https://www.updig.is/pdf/remix-at-dappcon.pdf). Here are the [latest slides (hosted on swarm)](http://30400.swarm-gateways.net/bzz:/49277e2a16baf5576c9f54204c70dc403a425c3df85424864fe04ad6dfc609bc/) and here are the [latest slides (not on swarm)](https://www.updig.is/pdf/remix-chez-coinhouse.pdf).
(July 19, 2018) (Oct 16, 2018)
\ No newline at end of file \ No newline at end of file
#!/usr/bin/env node
'use strict';
var gulp = require('gulp');
var exec = require('child_process').exec;
var packageJSON = require('./package.json');
gulp.task('publishTag', function () {
exec("git tag v"+ packageJSON.version +"; git push --tags");
});
...@@ -8,5 +8,14 @@ ...@@ -8,5 +8,14 @@
"remix-tests", "remix-tests",
"remix-simulator" "remix-simulator"
], ],
"command": {
"init": {
"exact": true
},
"publish": {
"exact": true,
"skipGit": true
}
},
"version": "independent" "version": "independent"
} }
{ {
"devDependencies": { "version": "0.1.3",
"lerna": "^2.10.2" "devDependencies": {
}, "gulp": "^3.9.1",
"scripts": { "lerna": "^2.10.2"
"bootstrap": "lerna bootstrap", },
"publish": "lerna publish" "scripts": {
} "diff": "lerna diff",
"updated": "lerna updated",
"bootstrap": "lerna bootstrap",
"publish": "lerna publish",
"release": "lerna bootstrap; lerna publish;",
"tag": "gulp; gulp publishTag;"
}
} }
# Release process
This document details steps for publishing packages and tag the code base accordingly:
- checkout a new branch
- npm run publish
- commit
- increment root package.json version
- commit
- merge the branch
- fetch origin/master
- checkout origin/master
- npm run tag
- github-changes -o ethereum -r remix -a --only-pulls --use-commit-body --only-merges --between-tags <previous>...<next>
- create a new release out of the changelog.md
- in changelog put list of published packages with version
{ {
"name": "remix-analyzer", "name": "remix-analyzer",
"version": "0.2.8", "version": "0.2.12",
"description": "Remix Analyzer", "description": "Remix Analyzer",
"main": "./index.js", "main": "./index.js",
"contributors": [ "contributors": [
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
"babel-eslint": "^7.1.1", "babel-eslint": "^7.1.1",
"babel-plugin-transform-object-assign": "^6.22.0", "babel-plugin-transform-object-assign": "^6.22.0",
"babel-preset-es2015": "^6.24.0", "babel-preset-es2015": "^6.24.0",
"remix-lib": "^0.3.8", "remix-lib": "0.3.12",
"solc": "^0.4.24",
"standard": "^7.0.1", "standard": "^7.0.1",
"tape": "^4.6.0" "tape": "^4.6.0"
}, },
...@@ -38,5 +37,8 @@ ...@@ -38,5 +37,8 @@
}, },
"author": "Remix Team", "author": "Remix Team",
"license": "MIT", "license": "MIT",
"homepage": "https://github.com/ethereum/remix#readme" "homepage": "https://github.com/ethereum/remix#readme",
"devDependencies": {
"npm-install-version": "^6.0.2"
}
} }
...@@ -11,12 +11,18 @@ function lowLevelCalls () { ...@@ -11,12 +11,18 @@ function lowLevelCalls () {
lowLevelCalls.prototype.visit = function (node) { lowLevelCalls.prototype.visit = function (node) {
if (common.isLowLevelCallInst(node)) { if (common.isLowLevelCallInst(node)) {
this.llcNodes.push({node: node, type: common.lowLevelCallTypes.CALL}) this.llcNodes.push({node: node, type: common.lowLevelCallTypes.CALL})
} else if (common.isLowLevelCallInst050(node)) {
this.llcNodes.push({node: node, type: common.lowLevelCallTypes.CALL})
} else if (common.isLowLevelCallcodeInst(node)) { } else if (common.isLowLevelCallcodeInst(node)) {
this.llcNodes.push({node: node, type: common.lowLevelCallTypes.CALLCODE}) this.llcNodes.push({node: node, type: common.lowLevelCallTypes.CALLCODE})
} else if (common.isLowLevelDelegatecallInst(node)) { } else if (common.isLowLevelDelegatecallInst(node)) {
this.llcNodes.push({node: node, type: common.lowLevelCallTypes.DELEGATECALL}) this.llcNodes.push({node: node, type: common.lowLevelCallTypes.DELEGATECALL})
} else if (common.isLowLevelSendInst(node)) { } else if (common.isLowLevelSendInst(node)) {
this.llcNodes.push({node: node, type: common.lowLevelCallTypes.SEND}) this.llcNodes.push({node: node, type: common.lowLevelCallTypes.SEND})
} else if (common.isLowLevelSendInst050(node)) {
this.llcNodes.push({node: node, type: common.lowLevelCallTypes.SEND})
} else if (common.isLLDelegatecallInst050(node)) {
this.llcNodes.push({node: node, type: common.lowLevelCallTypes.DELEGATECALL})
} }
} }
......
...@@ -33,6 +33,7 @@ var basicTypes = { ...@@ -33,6 +33,7 @@ var basicTypes = {
UINT: 'uint256', UINT: 'uint256',
BOOL: 'bool', BOOL: 'bool',
ADDRESS: 'address', ADDRESS: 'address',
PAYABLE_ADDRESS: 'address payable',
BYTES32: 'bytes32', BYTES32: 'bytes32',
STRING_MEM: 'string memory', STRING_MEM: 'string memory',
BYTES_MEM: 'bytes memory', BYTES_MEM: 'bytes memory',
...@@ -52,7 +53,9 @@ var basicRegex = { ...@@ -52,7 +53,9 @@ var basicRegex = {
var basicFunctionTypes = { var basicFunctionTypes = {
SEND: buildFunctionSignature([basicTypes.UINT], [basicTypes.BOOL], false), SEND: buildFunctionSignature([basicTypes.UINT], [basicTypes.BOOL], false),
CALL: buildFunctionSignature([], [basicTypes.BOOL], true), CALL: buildFunctionSignature([], [basicTypes.BOOL], true),
'CALL-v0.5': buildFunctionSignature([basicTypes.BYTES_MEM], [basicTypes.BOOL, basicTypes.BYTES_MEM], true),
DELEGATECALL: buildFunctionSignature([], [basicTypes.BOOL], false), DELEGATECALL: buildFunctionSignature([], [basicTypes.BOOL], false),
'DELEGATECALL-v0.5': buildFunctionSignature([basicTypes.BYTES_MEM], [basicTypes.BOOL, basicTypes.BYTES_MEM], false),
TRANSFER: buildFunctionSignature([basicTypes.UINT], [], false) TRANSFER: buildFunctionSignature([basicTypes.UINT], [], false)
} }
...@@ -65,6 +68,7 @@ var builtinFunctions = { ...@@ -65,6 +68,7 @@ var builtinFunctions = {
'addmod(uint256,uint256,uint256)': true, 'addmod(uint256,uint256,uint256)': true,
'mulmod(uint256,uint256,uint256)': true, 'mulmod(uint256,uint256,uint256)': true,
'selfdestruct(address)': true, 'selfdestruct(address)': true,
'selfdestruct(address payable)': true,
'revert()': true, 'revert()': true,
'revert(string memory)': true, 'revert(string memory)': true,
'assert(bool)': true, 'assert(bool)': true,
...@@ -77,8 +81,10 @@ var builtinFunctions = { ...@@ -77,8 +81,10 @@ var builtinFunctions = {
var lowLevelCallTypes = { var lowLevelCallTypes = {
CALL: { ident: 'call', type: basicFunctionTypes.CALL }, CALL: { ident: 'call', type: basicFunctionTypes.CALL },
'CALL-v0.5': { ident: 'call', type: basicFunctionTypes['CALL-v0.5'] },
CALLCODE: { ident: 'callcode', type: basicFunctionTypes.CALL }, CALLCODE: { ident: 'callcode', type: basicFunctionTypes.CALL },
DELEGATECALL: { ident: 'delegatecall', type: basicFunctionTypes.DELEGATECALL }, DELEGATECALL: { ident: 'delegatecall', type: basicFunctionTypes.DELEGATECALL },
'DELEGATECALL-v0.5': { ident: 'delegatecall', type: basicFunctionTypes['DELEGATECALL-v0.5'] },
SEND: { ident: 'send', type: basicFunctionTypes.SEND }, SEND: { ident: 'send', type: basicFunctionTypes.SEND },
TRANSFER: { ident: 'transfer', type: basicFunctionTypes.TRANSFER } TRANSFER: { ident: 'transfer', type: basicFunctionTypes.TRANSFER }
} }
...@@ -588,7 +594,7 @@ function isStorageVariableDeclaration (node) { ...@@ -588,7 +594,7 @@ function isStorageVariableDeclaration (node) {
* @return {bool} * @return {bool}
*/ */
function isInteraction (node) { function isInteraction (node) {
return isLLCall(node) || isLLSend(node) || isExternalDirectCall(node) || isTransfer(node) return isLLCall(node) || isLLSend(node) || isExternalDirectCall(node) || isTransfer(node) || isLLCall050(node) || isLLSend050(node)
} }
/** /**
...@@ -833,11 +839,25 @@ function isLowLevelCall (node) { ...@@ -833,11 +839,25 @@ function isLowLevelCall (node) {
return isLLCall(node) || return isLLCall(node) ||
isLLCallcode(node) || isLLCallcode(node) ||
isLLDelegatecall(node) || isLLDelegatecall(node) ||
isLLSend(node) isLLSend(node) ||
isLLSend050(node) ||
isLLCall050(node) ||
isLLDelegatecall050(node)
} }
/** /**
* True if low level send * True if low level send (solidity >= 0.5)
* @node {ASTNode} some AstNode
* @return {bool}
*/
function isLLSend050 (node) {
return isMemberAccess(node,
exactMatch(util.escapeRegExp(lowLevelCallTypes.SEND.type)),
undefined, exactMatch(basicTypes.PAYABLE_ADDRESS), exactMatch(lowLevelCallTypes.SEND.ident))
}
/**
* True if low level send (solidity < 0.5)
* @node {ASTNode} some AstNode * @node {ASTNode} some AstNode
* @return {bool} * @return {bool}
*/ */
...@@ -859,6 +879,17 @@ function isLLCall (node) { ...@@ -859,6 +879,17 @@ function isLLCall (node) {
} }
/** /**
* True if low level payable call (solidity >= 0.5)
* @node {ASTNode} some AstNode
* @return {bool}
*/
function isLLCall050 (node) {
return isMemberAccess(node,
exactMatch(util.escapeRegExp(lowLevelCallTypes['CALL-v0.5'].type)),
undefined, exactMatch(basicTypes.PAYABLE_ADDRESS), exactMatch(lowLevelCallTypes['CALL-v0.5'].ident))
}
/**
* True if low level callcode * True if low level callcode
* @node {ASTNode} some AstNode * @node {ASTNode} some AstNode
* @return {bool} * @return {bool}
...@@ -881,6 +912,17 @@ function isLLDelegatecall (node) { ...@@ -881,6 +912,17 @@ function isLLDelegatecall (node) {
} }
/** /**
* True if low level delegatecall (solidity >= 0.5)
* @node {ASTNode} some AstNode
* @return {bool}
*/
function isLLDelegatecall050 (node) {
return isMemberAccess(node,
exactMatch(util.escapeRegExp(lowLevelCallTypes['DELEGATECALL-v0.5'].type)),
undefined, matches(basicTypes.PAYABLE_ADDRESS, basicTypes.ADDRESS), exactMatch(lowLevelCallTypes['DELEGATECALL-v0.5'].ident))
}
/**
* True if transfer call * True if transfer call
* @node {ASTNode} some AstNode * @node {ASTNode} some AstNode
* @return {bool} * @return {bool}
...@@ -888,7 +930,7 @@ function isLLDelegatecall (node) { ...@@ -888,7 +930,7 @@ function isLLDelegatecall (node) {
function isTransfer (node) { function isTransfer (node) {
return isMemberAccess(node, return isMemberAccess(node,
exactMatch(util.escapeRegExp(lowLevelCallTypes.TRANSFER.type)), exactMatch(util.escapeRegExp(lowLevelCallTypes.TRANSFER.type)),
undefined, exactMatch(basicTypes.ADDRESS), exactMatch(lowLevelCallTypes.TRANSFER.ident)) undefined, matches(basicTypes.ADDRESS, basicTypes.PAYABLE_ADDRESS), exactMatch(lowLevelCallTypes.TRANSFER.ident))
} }
function isStringToBytesConversion (node) { function isStringToBytesConversion (node) {
...@@ -962,6 +1004,14 @@ function exactMatch (regexStr) { ...@@ -962,6 +1004,14 @@ function exactMatch (regexStr) {
return '^' + regexStr + '$' return '^' + regexStr + '$'
} }
function matches () {
var args = []
for (var k = 0; k < arguments.length; k++) {
args.push(arguments[k])
}
return '(' + args.join('|') + ')'
}
/** /**
* Builds an function signature as used in the AST of the solc-json AST * Builds an function signature as used in the AST of the solc-json AST
* @param {Array} paramTypes * @param {Array} paramTypes
...@@ -1048,6 +1098,9 @@ module.exports = { ...@@ -1048,6 +1098,9 @@ module.exports = {
isTransfer: isTransfer, isTransfer: isTransfer,
isLowLevelCall: isLowLevelCall, isLowLevelCall: isLowLevelCall,
isLowLevelCallInst: isLLCall, isLowLevelCallInst: isLLCall,
isLowLevelCallInst050: isLLCall050,
isLowLevelSendInst050: isLLSend050,
isLLDelegatecallInst050: isLLDelegatecall050,
isLowLevelCallcodeInst: isLLCallcode, isLowLevelCallcodeInst: isLLCallcode,
isLowLevelDelegatecallInst: isLLDelegatecall, isLowLevelDelegatecallInst: isLLDelegatecall,
isLowLevelSendInst: isLLSend, isLowLevelSendInst: isLLSend,
......
...@@ -10,7 +10,7 @@ function txOrigin () { ...@@ -10,7 +10,7 @@ function txOrigin () {
txOrigin.prototype.visit = function (node) { txOrigin.prototype.visit = function (node) {
if (node.name === 'MemberAccess' && if (node.name === 'MemberAccess' &&
node.attributes.member_name === 'origin' && node.attributes.member_name === 'origin' &&
node.attributes.type === 'address' && (node.attributes.type === 'address' || node.attributes.type === 'address payable') &&
node.children && node.children.length && node.children && node.children.length &&
node.children[0].attributes.type === 'tx' && node.children[0].attributes.type === 'tx' &&
node.children[0].attributes.value === 'tx') { node.children[0].attributes.value === 'tx') {
......
...@@ -4,10 +4,13 @@ var remixLib = require('remix-lib') ...@@ -4,10 +4,13 @@ var remixLib = require('remix-lib')
var StatRunner = require('../../src/solidity-analyzer') var StatRunner = require('../../src/solidity-analyzer')
var compilerInput = remixLib.helpers.compiler.compilerInput var compilerInput = remixLib.helpers.compiler.compilerInput
var compiler = require('solc') const niv = require('npm-install-version')
niv.install('solc@0.5.0')
var compiler = niv.require('solc@0.5.0')
var fs = require('fs') var fs = require('fs')
var path = require('path') var path = require('path')
var folder = 'solidity-v0.5'
var testFiles = [ var testFiles = [
'KingOfTheEtherThrone.sol', 'KingOfTheEtherThrone.sol',
...@@ -40,8 +43,8 @@ var testFiles = [ ...@@ -40,8 +43,8 @@ var testFiles = [
var testFileAsts = {} var testFileAsts = {}
testFiles.forEach((fileName) => { testFiles.forEach((fileName) => {
var content = fs.readFileSync(path.join(__dirname, 'test-contracts', fileName), 'utf8') var content = fs.readFileSync(path.join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
testFileAsts[fileName] = JSON.parse(compiler.compileStandardWrapper(compilerInput(content))) testFileAsts[fileName] = JSON.parse(compiler.compile(compilerInput(content)))
}) })
test('Integration test thisLocal.js', function (t) { test('Integration test thisLocal.js', function (t) {
...@@ -131,7 +134,7 @@ test('Integration test constantFunctions.js', function (t) { ...@@ -131,7 +134,7 @@ test('Integration test constantFunctions.js', function (t) {
'ballot.sol': 0, 'ballot.sol': 0,
'ballot_reentrant.sol': 0, 'ballot_reentrant.sol': 0,
'ballot_withoutWarnings.sol': 0, 'ballot_withoutWarnings.sol': 0,
'cross_contract.sol': 1, 'cross_contract.sol': 0,
'inheritance.sol': 0, 'inheritance.sol': 0,
'modifier1.sol': 1, 'modifier1.sol': 1,
'modifier2.sol': 0, 'modifier2.sol': 0,
...@@ -143,7 +146,7 @@ test('Integration test constantFunctions.js', function (t) { ...@@ -143,7 +146,7 @@ test('Integration test constantFunctions.js', function (t) {
'transfer.sol': 0, 'transfer.sol': 0,
'ctor.sol': 0, 'ctor.sol': 0,
'forgottenReturn.sol': 0, 'forgottenReturn.sol': 0,
'selfdestruct.sol': 1, 'selfdestruct.sol': 0,
'deleteDynamicArray.sol': 0, 'deleteDynamicArray.sol': 0,
'deleteFromDynamicArray.sol': 0, 'deleteFromDynamicArray.sol': 0,
'blockLevelCompare.sol': 0, 'blockLevelCompare.sol': 0,
...@@ -281,7 +284,7 @@ test('Integration test similarVariableNames.js', function (t) { ...@@ -281,7 +284,7 @@ test('Integration test similarVariableNames.js', function (t) {
'KingOfTheEtherThrone.sol': 0, 'KingOfTheEtherThrone.sol': 0,
'assembly.sol': 0, 'assembly.sol': 0,
'ballot.sol': 2, 'ballot.sol': 2,
'ballot_reentrant.sol': 3, 'ballot_reentrant.sol': 11,
'ballot_withoutWarnings.sol': 0, 'ballot_withoutWarnings.sol': 0,
'cross_contract.sol': 0, 'cross_contract.sol': 0,
'inheritance.sol': 0, 'inheritance.sol': 0,
...@@ -462,6 +465,10 @@ test('Integration test blockBlockhash.js', function (t) { ...@@ -462,6 +465,10 @@ test('Integration test blockBlockhash.js', function (t) {
}) })
}) })
/*
! No return gives compilation error with solidity 0.5.0
test('Integration test noReturn.js', function (t) { test('Integration test noReturn.js', function (t) {
t.plan(testFiles.length) t.plan(testFiles.length)
...@@ -499,6 +506,7 @@ test('Integration test noReturn.js', function (t) { ...@@ -499,6 +506,7 @@ test('Integration test noReturn.js', function (t) {
t.equal(report.length, lengthCheck[file], `${file} has right amount of noReturn warnings`) t.equal(report.length, lengthCheck[file], `${file} has right amount of noReturn warnings`)
}) })
}) })
*/
test('Integration test selfdestruct.js', function (t) { test('Integration test selfdestruct.js', function (t) {
t.plan(testFiles.length) t.plan(testFiles.length)
......
...@@ -4,13 +4,16 @@ var remixLib = require('remix-lib') ...@@ -4,13 +4,16 @@ var remixLib = require('remix-lib')
var StatRunner = require('../../src/solidity-analyzer') var StatRunner = require('../../src/solidity-analyzer')
var compilerInput = remixLib.helpers.compiler.compilerInput var compilerInput = remixLib.helpers.compiler.compilerInput
var compiler = require('solc') const niv = require('npm-install-version')
niv.install('solc@0.4.24')
var compiler = niv.require('solc@0.4.24')
var fs = require('fs') var fs = require('fs')
var path = require('path') var path = require('path')
var folder = 'solidity-v0.4.24'
function compile (fileName) { function compile (fileName) {
var content = fs.readFileSync(path.join(__dirname, 'test-contracts', fileName), 'utf8') var content = fs.readFileSync(path.join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
return JSON.parse(compiler.compileStandardWrapper(compilerInput(content))) return JSON.parse(compiler.compileStandardWrapper(compilerInput(content)))
} }
......
var test = require('tape')
var remixLib = require('remix-lib')
var StatRunner = require('../../src/solidity-analyzer')
var compilerInput = remixLib.helpers.compiler.compilerInput
const niv = require('npm-install-version')
niv.install('solc@0.5.0')
var compiler = niv.require('solc@0.5.0')
var fs = require('fs')
var path = require('path')
var folder = 'solidity-v0.5'
function compile (fileName) {
var content = fs.readFileSync(path.join(__dirname, 'test-contracts/' + folder, fileName), 'utf8')
return JSON.parse(compiler.compile(compilerInput(content)))
}
test('staticAnalysisIssues.functionParameterPassingError', function (t) {
// https://github.com/ethereum/remix-ide/issues/889#issuecomment-351746474
t.plan(2)
var res = compile('functionParameters.sol')
var module = require('../../src/solidity-analyzer/modules/checksEffectsInteraction')
var statRunner = new StatRunner()
t.doesNotThrow(() => {
statRunner.runWithModuleList(res, [{ name: module.name, mod: new module.Module() }], (reports) => {
})
}, true, 'Analysis should not throw')
statRunner.runWithModuleList(res, [{ name: module.name, mod: new module.Module() }], (reports) => {
t.ok(!reports.some((mod) => mod.report.some((rep) => rep.warning.includes('INTERNAL ERROR')), 'Should not have internal errors'))
})
})
pragma solidity >=0.4.9 <0.6.0;
contract EIP20 {
uint public decimals = 12;
// optional
function name() public pure returns (string memory) {
return "MYTOKEN";
}
// optional
function symbol() public pure returns (string memory) {
return "MT";
}
// optional
//function decimals() internal pure returns (uint8) {
// return 12;
//}
function totalSupply() public pure returns (uint256) {
return 12000;
}
function balanceOf(address _owner) public pure returns (uint256) {
return 0;
}
function transfer(address _to, uint256 _value) public pure returns (bool success) {
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public pure returns (bool) {
return true;
}
function approve(address _spender, uint256 _value) public pure returns (bool) {
return true;
}
function allowance(address _owner, address _spender) public pure returns (uint256) {
return 0;
}
}
\ No newline at end of file
// return value send
contract KingOfTheEtherThrone{
struct Monarch {
// address of the king .
address payable ethAddr ;
string name ;
// how much he pays to previous king
uint claimPrice ;
uint coronationTimestamp;
}
Monarch public currentMonarch ;
function claimThrone ( string memory name ) public {
address wizardAddress;
uint compensation = 100;
uint valuePaid = 10;
if ( currentMonarch.ethAddr != wizardAddress )
if (currentMonarch.ethAddr.send( compensation )) revert();
currentMonarch = Monarch(msg.sender,name,valuePaid,block.timestamp);
}
}
pragma solidity >=0.4.9 <0.6.0;
contract test {
address owner;
function at(address _addr) public returns (bytes memory o_code) {
assert(_addr != address(0x0));
assembly {
// retrieve the size of the code, this needs assembly
let size := extcodesize(_addr)
// allocate output byte array - this could also be done without assembly
// by using o_code = new bytes(size)
o_code := mload(0x40)
// new "memory end" including padding
mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
// store length in memory
mstore(o_code, size)
// actually retrieve the code, this needs assembly
extcodecopy(_addr, add(o_code, 0x20), 0, size)
}
}
function bla() public {
require(tx.origin == owner);
msg.sender.send(19);
assembly {
}
}
}
pragma solidity >=0.4.9 <0.6.0;
/// @title Voting with delegation.
contract Ballot {
// This declares a new complex type which will
// be used for variables later.
// It will represent a single voter.
struct Voter {
uint weight; // weight is accumulated by delegation
bool voted; // if true, that person already voted
address delegate; // person delegated to
uint vote; // index of the voted proposal
}
// This is a type for a single proposal.
struct Proposal
{
bytes32 name; // short name (up to 32 bytes)
uint voteCount; // number of accumulated votes
}
address public chairperson;
// This declares a state variable that
// stores a `Voter` struct for each possible address.
mapping(address => Voter) public voters;
// A dynamically-sized array of `Proposal` structs.
Proposal[] public proposals;
/// Create a new ballot to choose one of `proposalNames`.
constructor(bytes32[] memory proposalNames) public {
chairperson = msg.sender;
voters[chairperson].weight = 1;
// For each of the provided proposal names,
// create a new proposal object and add it
// to the end of the array.
for (uint i = 0; i < proposalNames.length; i++) {
// `Proposal({...})` creates a temporary
// Proposal object and `proposals.push(...)`
// appends it to the end of `proposals`.
proposals.push(Proposal({
name: proposalNames[i],
voteCount: 0
}));
}
}
// Give `voter` the right to vote on this ballot.
// May only be called by `chairperson`.
function giveRightToVote(address voter) public {
if (msg.sender != chairperson || voters[voter].voted) {
// `throw` terminates and reverts all changes to
// the state and to Ether balances. It is often
// a good idea to use this if functions are
// called incorrectly. But watch out, this
// will also consume all provided gas.
revert();
}
voters[voter].weight = 1;
}
/// Delegate your vote to the voter `to`.
function delegate(address to) public {
// assigns reference
Voter memory sender = voters[msg.sender];
if (sender.voted)
revert();
// Forward the delegation as long as
// `to` also delegated.
// In general, such loops are very dangerous,
// because if they run too long, they might
// need more gas than is available in a block.
// In this case, the delegation will not be executed,
// but in other situations, such loops might
// cause a contract to get "stuck" completely.
while (
voters[to].delegate != address(0) &&
voters[to].delegate != msg.sender
) {
to = voters[to].delegate;
}
// We found a loop in the delegation, not allowed.
if (to == msg.sender) {
revert();
}
// Since `sender` is a reference, this
// modifies `voters[msg.sender].voted`
sender.voted = true;
sender.delegate = to;
Voter memory delegate = voters[to];
if (delegate.voted) {
// If the delegate already voted,
// directly add to the number of votes
proposals[delegate.vote].voteCount += sender.weight;
} else {
// If the delegate did not vote yet,
// add to her weight.
delegate.weight += sender.weight;
}
}
/// Give your vote (including votes delegated to you)
/// to proposal `proposals[proposal].name`.
function vote(uint proposal) public {
Voter memory sender = voters[msg.sender];
if (sender.voted)
revert();
sender.voted = true;
sender.vote = proposal;
// If `proposal` is out of the range of the array,
// this will throw automatically and revert all
// changes.
proposals[proposal].voteCount += sender.weight;
}
/// @dev Computes the winning proposal taking all
/// previous votes into account.
function winningProposal() view public
returns (uint winningProposal)
{
uint winningVoteCount = 0;
for (uint p = 0; p < proposals.length; p++) {
if (proposals[p].voteCount > winningVoteCount) {
winningVoteCount = proposals[p].voteCount;
winningProposal = p;
}
}
}
// Calls winningProposal() function to get the index
// of the winner contained in the proposals array and then
// returns the name of the winner
function winnerName() view public
returns (bytes32 winnerName)
{
winnerName = proposals[winningProposal()].name;
}
}
pragma solidity >=0.4.9 <0.6.0;
contract InfoFeed {
function info() public payable returns (uint ret);
function call1(uint a) public payable returns (bool);
}
contract Ballot {
InfoFeed feed;
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
struct Proposal {
uint voteCount;
}
address chairperson;
mapping(address => Voter) voters;
Proposal[] proposals;
function send1(address a) public {
giveRightToVote(a,a);
}
/// Create a new ballot with $(_numProposals) different proposals.
constructor(uint8 _numProposals) public {
address payable d;
(bool success, bytes memory data) = d.delegatecall.gas(800)(abi.encodeWithSignature('function_name', 'arg1', 'arg2'));
if(!success) revert();
(bool success2, bytes memory data2) = d.delegatecall.gas(800)(abi.encodeWithSignature('function_name', 'arg1', 'arg2'));
if(!success2) revert();
(bool success3, bytes memory data3) = d.call.value(10).gas(800)(abi.encodeWithSignature('function_name', 'arg1', 'arg2'));
if(!success3) revert();
(bool success4, bytes memory data4) = d.call.value(10).gas(800)(abi.encodeWithSignature('function_name', 'arg1', 'arg2'));
if(!success4) revert();
address payable o = msg.sender;
if(!o.send(1 wei)) revert();
(bool success5, bytes memory data5) = d.call(abi.encodeWithSignature('function_name', 'arg1', 'arg2'));
if(!success5) revert();
uint a = now;
uint c = block.timestamp;
if(block.timestamp < 100){}
chairperson = msg.sender;
voters[chairperson].weight = 1;
proposals.length = _numProposals;
if(!d.send(1 wei)) revert();
feed.info.value(10).gas(800)();
feed.call1(1);
this.send1(d);
}
/// Give $(voter) the right to vote on this ballot.
/// May only be called by $(chairperson).
function giveRightToVote(address voter, address b) public payable returns (bool){
if (msg.sender != chairperson || voters[voter].voted) return false;
voters[voter].weight = 1;
return true;
}
/// Delegate your vote to the voter $(to).
function delegate(address to) public {
Voter memory sender = voters[msg.sender]; // assigns reference
if (sender.voted) return;
while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender)
to = voters[to].delegate;
if (to == msg.sender) return;
sender.voted = true;
sender.delegate = to;
Voter memory delegate = voters[to];
if (delegate.voted)
proposals[delegate.vote].voteCount += sender.weight;
else
delegate.weight += sender.weight;
}
/// Give a single vote to proposal $(proposal).
function vote(uint8 proposal) public {
Voter memory sender = voters[msg.sender];
if (sender.voted || proposal >= proposals.length) return;
sender.voted = true;
sender.vote = proposal;
proposals[proposal].voteCount += sender.weight;
}
function winningProposal() view public returns (uint8 winningProposal) {
uint256 winningVoteCount = 0;
for (uint8 proposal = 0; proposal < proposals.length; proposal++)
if (proposals[proposal].voteCount > winningVoteCount) {
winningVoteCount = proposals[proposal].voteCount;
winningProposal = proposal;
}
}
}
pragma solidity >=0.4.9 <0.6.0;
/// @title Voting with delegation.
contract Ballot {
struct Proposal
{
bytes32 name; // short name (up to 32 bytes)
uint voteCount; // number of accumulated votes
}
// A dynamically-sized array of `Proposal` structs.
Proposal[] public proposals;
/// @dev Computes the winning proposal taking all
/// previous votes into account.
function winningProposal() public view
returns (uint winningProposal)
{
winningProposal = 0;
}
// Calls winningProposal() function to get the index
// of the winner contained in the proposals array and then
// returns the name of the winner
function winnerName() public view
returns (bytes32 winnerName)
{
winnerName = proposals[winningProposal()].name;
}
}
pragma solidity >=0.4.9 <0.6.0;
contract grr {
bool breaker;
function() external {
uint a = 1;
string memory sig = "withdraw()";
uint b = 3;
bytes4 selector = bytes4(keccak256(abi.encodePacked(sig)));
abi.encode(a,b);
abi.encodePacked(a,b);
a = -b;
a == b;
if(a == b) {
abi.encodeWithSelector(selector, a, b);
abi.encodeWithSignature(sig, a, b);
}
if(b < 4) { a == b; }
if(b > 4) b == a;
while(true) a == b;
for(int i = 0; i < 3; i++) b == a;
while(false) {
int c = 3;
uint(c) + a;
c == 5;
}
a + b;
breaker = false;
}
}
\ No newline at end of file
pragma solidity >=0.4.9 <0.6.0;
contract a {
uint x;
function foo() public {
x++;
}
}
contract b {
a x;
function bar() public {
address payable a;
a.send(100 wei);
x.foo();
}
}
contract c {
uint x;
uint x_abc;
constructor(uint _x, uint _abc) public {
x=_x;
x_abc=_abc;
}
}
\ No newline at end of file
pragma solidity >=0.4.9 <0.6.0;
contract arr {
uint[] users;
bytes access_rights_per_user;
uint user_index;
address owner;
string grr = "message";
uint[100] last_100_users;
constructor(address owner1) public {
owner = owner1;
user_index = 0;
}
function addUser(uint id, byte rights) public{
users[user_index] = id;
last_100_users[user_index % 100] = id;
access_rights_per_user[user_index] = rights;
user_index++;
}
function resetState() public{
require(msg.sender == owner, grr);
delete users;
delete access_rights_per_user;
delete last_100_users;
}
function bla(string memory bal) public {
grr = bal;
}
}
\ No newline at end of file
pragma solidity >=0.4.9 <0.6.0;
contract arr {
uint[] array = [1,2,3];
function removeAtIndex() public returns (uint[] memory) {
delete array[1];
return array;
}
// TODO: deleteFromDynamicArray should not generate warnings if array item is shifted and removed
/* function safeRemoveAtIndex(uint index) returns (uint[] memory) {
if (index >= array.length) return;
for (uint i = index; i < array.length-1; i++) {
array[i] = array[i+1];
}
delete array[array.length-1];
array.length--;
return array;
} */
}
pragma solidity >=0.4.9 <0.6.0;
contract forLoopArr {
uint[] array;
constructor(uint[] memory _array) public {
array = _array;
}
function shiftArrItem(uint index) public returns(uint[] memory) {
// TODO: for (uint i = index; i < array.length-1; i++) should also generate warning
for (uint i = index; i < array.length; i++) {
array[i] = array[i+1];
}
return array;
}
}
contract Sheep {
string public name;
string public dna;
bool g = true;
constructor(string memory _name, string memory _dna) public {
name = _name;
dna = _dna;
}
function geneticallyEngineer(string memory _dna) public returns (bool) {
dna = _dna;
}
}
\ No newline at end of file
pragma solidity >=0.4.9 <0.6.0;
contract B {
function plus(uint a, uint b) pure internal returns (uint) {
return a + b;
}
function eval(function (uint, uint) pure internal returns (uint) f, uint x, uint y) pure internal returns (uint) {
return f(x, y);
}
function calc(uint x, uint y) pure public returns (uint) {
return eval(plus, x, y);
// return plus(x, y);
}
}
\ No newline at end of file
pragma solidity >=0.4.9 <0.6.0;
contract bla {
uint brr;
function duper() public {
brr++;
}
}
contract a is bla {
function blub() public {
brr++;
}
function r () public payable {
address payable a;
bytes32 hash;
uint8 v;
bytes32 r;
bytes32 s;
blockhash(1);
block.coinbase;
block.difficulty;
block.gaslimit;
block.number;
block.timestamp;
msg.data;
gasleft();
msg.sender;
msg.value;
now;
tx.gasprice;
tx.origin;
// assert(1 == 2);
// require(1 == 1);
keccak256(abi.encodePacked(a));
sha256(abi.encodePacked(a));
ripemd160(abi.encodePacked(a));
ecrecover(hash, v, r, s);
addmod(1, 2, 2);
mulmod(4,4,12);
a.balance;
blub();
a.send(a.balance);
super.duper();
//a.transfer(a.balance);
selfdestruct(a);
//revert();
assert(a.balance == 0);
}
}
\ No newline at end of file
pragma solidity >=0.4.9 <0.6.0;
contract r {
function s() public view {}
}
contract a is r {
uint x = 1;
function getX() public view returns (uint) {
return x;
}
}
contract b is a {
uint y = 2;
uint x = 3;
function getY(uint z, bool r) public returns (uint) {
return y++;
}
function getY(string storage n) internal view returns (uint) { return 10; }
}
contract c is b {
string x;
function d() public returns (uint a, uint b) {
//d();
//sha3("bla");
address payable o = msg.sender;
o.call.gas(200000).value(address(this).balance)(abi.encode("pay()"));
//x++;
getY(x);
a = getX() + getY(1, false);
b = getX() + getY(x);
}
}
pragma solidity >=0.4.9 <0.6.0;
contract CharityCampaign {
mapping (address => uint) contributions;
int128 feePercentage;
uint p2;
address payable processor;
address payable beneficiary;
constructor(address payable _beneficiary, int128 _feePercentage) public {
processor = msg.sender;
beneficiary = _beneficiary;
feePercentage = _feePercentage;
}
function contribute() payable public returns (uint feeCollected) {
uint fee = msg.value * uint256(feePercentage / 100);
fee = msg.value * (p2 / 100);
contributions[msg.sender] = msg.value - fee;
processor.transfer(fee);
return fee;
}
function endCampaign() public returns (bool) {
require(msg.sender == processor || msg.sender == beneficiary);
selfdestruct(beneficiary);
return true;
}
// FALSE POSITIVE FOR SELFDESTRUCT TERMINAL
function endAmbiguous() public {
if(msg.sender == address(0x0)) {
selfdestruct(beneficiary);
} else {
selfdestruct(processor);
}
}
}
\ No newline at end of file
pragma solidity >=0.4.9 <0.6.0;
library Set {
// We define a new struct datatype that will be used to
// hold its data in the calling contract.
struct Data { mapping(uint => bool) flags; }
// Note that the first parameter is of type "storage
// reference" and thus only its storage address and not
// its contents is passed as part of the call. This is a
// special feature of library functions. It is idiomatic
// to call the first parameter 'self', if the function can
// be seen as a method of that object.
function insert(Data storage self, uint value) public
returns (bool)
{
if (self.flags[value])
return false; // already there
self.flags[value] = true;
return true;
}
function remove(Data storage self, uint value) public
returns (bool)
{
if (!self.flags[value])
return false; // not there
self.flags[value] = false;
return true;
}
function contains(Data storage self, uint value) public
returns (bool)
{
return self.flags[value];
}
}
contract C {
Set.Data knownValues;
function register(uint value) public {
// The library functions can be called without a
// specific instance of the library, since the
// "instance" will be the current contract.
address payable a;
a.send(10 wei);
if (!Set.insert(knownValues, value))
revert();
}
// In this contract, we can also directly access knownValues.flags, if we want.
}
\ No newline at end of file
pragma solidity >=0.4.9 <0.6.0;
contract test {
address owner;
modifier onlyOwner {
uint a = 0;
if (msg.sender != owner)
revert();
_;
}
function b(address a) public onlyOwner returns (bool) {
return true;
}
}
\ No newline at end of file
pragma solidity >=0.4.9 <0.6.0;
contract owned {
uint r=0;
modifier ntimes(uint n) {
for(uint i=0;i<n-1;i++){
_;
}
_;
}
modifier plus100 {
uint bla=1;
r+=100;
_;
}
function a() ntimes(10) plus100 public payable returns (uint) {
{
uint bla=5;
r += bla;
}
return r;
}
}
pragma solidity >=0.4.9 <0.6.0;
contract Fund {
/// Mapping of ether shares of the contract.
mapping(address => uint) shares;
/// Withdraw your share.
function withdraw() public {
uint share = shares[msg.sender];
shares[msg.sender] = 0;
if (!msg.sender.send(share))
revert();
}
}
pragma solidity >=0.4.9 <0.6.0;
contract InfoFeed {
uint c;
function info() constant returns (uint ret) {return c;}
function call1(uint a) constant returns (bool) {return true;}
}
// THIS CONTRACT CONTAINS A BUG - DO NOT USE
contract Fund {
/// Mapping of ether shares of the contract.
//mapping(address => uint) shares;
/// Withdraw your share.
uint c = 0;
function withdraw() constant {
InfoFeed f;
//shares[msg.sender] /= 1;
f.info();
//if (msg.sender.send(shares[msg.sender])) throw;
// shares[msg.sender] = 0;
b(true, false);
//shares[msg.sender]++;
//c++;
}
mapping(address => uint) shares;
function b(bool a, bool b) returns (bool) {
mapping(address => uint) c = shares;
c[msg.sender] = 0;
//f();
//withdraw();
//shares[msg.sender]++;
//c++;
return true;
}
function f() {
c++;
withdraw();
}
}
contract sd {
uint x = 0;
function() external payable { }
function c () public {
selfdestruct(address(0xdeadbeef));
}
function b () public {
selfdestruct(address(0xdeadbeef));
x = 1;
}
}
\ No newline at end of file
pragma solidity >=0.4.9 <0.6.0;
contract bytesString {
function length(string memory a) public pure returns(uint) {
bytes memory x = bytes(a);
return x.length;
}
}
\ No newline at end of file
pragma solidity >=0.4.9 <0.6.0;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
baz foo;
}
struct baz{
uint bar;
}
mapping(address => Voter) voters;
/// Create a new ballot with $(_numProposals) different proposals.
function bla(address payable a) public {
Voter storage x = voters[a];
if (!a.send(10))
revert();
//voters[a] = Voter(10,true,1,a);
//x.foo.bar *= 100;
bli(x);
}
//function bla(){}
function bli(Voter storage x) private {
x.foo.bar++;
}
}
pragma solidity >=0.4.9 <0.6.0;
contract test {
function () external {
address payable x;
this.b(x);
x.call('something');
x.send(1 wei);
}
function b(address a) public returns (bool) {
}
}
contract c {
uint x;
function f(address payable r) public payable {
r.transfer(1);
x = 2;
}
}
\ No newline at end of file
require('./analysis/staticAnalysisCommon-test.js') require('./analysis/staticAnalysisCommon-test.js')
require('./analysis/staticAnalysisIntegration-test.js')
require('./analysis/staticAnalysisIssues-test.js') require('./analysis/staticAnalysisIntegration-test-0.4.24.js')
require('./analysis/staticAnalysisIssues-test-0.4.24.js')
require('./analysis/staticAnalysisIntegration-test-0.5.0.js')
require('./analysis/staticAnalysisIssues-test-0.5.0.js')
{ {
"name": "remix-debug", "name": "remix-debug",
"version": "0.2.9", "version": "0.2.13",
"description": "Ethereum IDE and tools for the web", "description": "Ethereum IDE and tools for the web",
"contributors": [ "contributors": [
{ {
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
"fast-async": "^6.1.2", "fast-async": "^6.1.2",
"notify-error": "^1.2.0", "notify-error": "^1.2.0",
"npm-run-all": "^4.1.2", "npm-run-all": "^4.1.2",
"remix-lib": "^0.3.8", "remix-lib": "0.3.12",
"solc": "^0.4.24" "solc": "^0.5.0"
}, },
"devDependencies": { "devDependencies": {
"standard": "^7.0.1", "standard": "^7.0.1",
......
...@@ -6,10 +6,10 @@ module.exports = { ...@@ -6,10 +6,10 @@ module.exports = {
enum enum1 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63, e64, e65, e66, e67, e68, e69, e70, e71, e72, e73, e74, e75, e76, e77, e78, e79, e80, e81, e82, e83, e84, e85, e86, e87, e88, e89, e90, e91, e92, e93, e94, e95, e96, e97, e98, e99, e100, e101, e102, e103, e104, e105, e106, e107, e108, e109, e110, e111, e112, e113, e114, e115, e116, e117, e118, e119, e120, e121, e122, e123, e124, e125, e126, e127, e128, e129, e130, e131, e132, e133, e134, e135, e136, e137, e138, e139, e140, e141, e142, e143, e144, e145, e146, e147, e148, e149, e150, e151, e152, e153, e154, e155, e156, e157, e158, e159, e160, e161, e162, e163, e164, e165, e166, e167, e168, e169, e170, e171, e172, e173, e174, e175, e176, e177, e178, e179, e180, e181, e182, e183, e184, e185, e186, e187, e188, e189, e190, e191, e192, e193, e194, e195, e196, e197, e198, e199, e200, e201, e202, e203, e204, e205, e206, e207, e208, e209, e210, e211, e212, e213, e214, e215, e216, e217, e218, e219, e220, e221, e222, e223, e224, e225, e226, e227, e228, e229, e230, e231, e232, e233, e234, e235, e236, e237, e238, e239, e240, e241, e242, e243, e244, e245, e246, e247, e248, e249, e250, e251, e252, e253, e254, e255, e256, e257, e258, e259, e260 } enum enum1 { e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63, e64, e65, e66, e67, e68, e69, e70, e71, e72, e73, e74, e75, e76, e77, e78, e79, e80, e81, e82, e83, e84, e85, e86, e87, e88, e89, e90, e91, e92, e93, e94, e95, e96, e97, e98, e99, e100, e101, e102, e103, e104, e105, e106, e107, e108, e109, e110, e111, e112, e113, e114, e115, e116, e117, e118, e119, e120, e121, e122, e123, e124, e125, e126, e127, e128, e129, e130, e131, e132, e133, e134, e135, e136, e137, e138, e139, e140, e141, e142, e143, e144, e145, e146, e147, e148, e149, e150, e151, e152, e153, e154, e155, e156, e157, e158, e159, e160, e161, e162, e163, e164, e165, e166, e167, e168, e169, e170, e171, e172, e173, e174, e175, e176, e177, e178, e179, e180, e181, e182, e183, e184, e185, e186, e187, e188, e189, e190, e191, e192, e193, e194, e195, e196, e197, e198, e199, e200, e201, e202, e203, e204, e205, e206, e207, e208, e209, e210, e211, e212, e213, e214, e215, e216, e217, e218, e219, e220, e221, e222, e223, e224, e225, e226, e227, e228, e229, e230, e231, e232, e233, e234, e235, e236, e237, e238, e239, e240, e241, e242, e243, e244, e245, e246, e247, e248, e249, e250, e251, e252, e253, e254, e255, e256, e257, e258, e259, e260 }
bool b1 = false; bool b1 = false;
address a1 = 0xfe350f199f244ac9a79038d254400b632a633225; address a1 = 0xfE350f199F244ac9A79038d254400b632a633225;
bool b2 = true; bool b2 = true;
bytes dynb1 = "dynamicbytes"; bytes dynb1 = "dynamicbytes";
byte stab = 0x1; byte stab = 0x01;
bytes1 stab1 = hex"12"; bytes1 stab1 = hex"12";
bytes2 stab2 = hex"1579"; bytes2 stab2 = hex"1579";
bytes3 stab3 = hex"359356"; bytes3 stab3 = hex"359356";
......
...@@ -9,7 +9,7 @@ contract proxy { ...@@ -9,7 +9,7 @@ contract proxy {
} }
} }
contract intLocal { contract intLocal {
function intLocal () { constructor () public {
proxy.testStruct memory p; proxy.testStruct memory p;
uint8 ui8 = 130; uint8 ui8 = 130;
uint16 ui16 = 456; uint16 ui16 = 456;
...@@ -31,11 +31,11 @@ contract intLocal { ...@@ -31,11 +31,11 @@ contract intLocal {
level11(); level11();
} }
function level11() { function level11() public {
uint8 ui8 = 123; uint8 ui8 = 123;
level12(); level12();
} }
function level12() { function level12() public {
uint8 ui81 = 12; uint8 ui81 = 12;
} }
} }
......
module.exports = { module.exports = {
contract: ` contract: `
pragma solidity ^0.4.19; pragma solidity ^0.5.0;
contract SimpleMappingState { contract SimpleMappingState {
uint _num; uint _num;
mapping(string => uint) _iBreakSolidityState; mapping(string => uint) _iBreakSolidityState;
mapping(uint => uint) _iBreakSolidityStateInt; mapping(uint => uint) _iBreakSolidityStateInt;
function updateNum(uint num, string str) public { function updateNum(uint num, string memory str) public {
_num = num; _num = num;
_iBreakSolidityState[str] = num; _iBreakSolidityState[str] = num;
_iBreakSolidityStateInt[num] = num; _iBreakSolidityStateInt[num] = num;
......
...@@ -9,7 +9,7 @@ contract miscLocal { ...@@ -9,7 +9,7 @@ contract miscLocal {
three, three,
four four
} }
function miscLocal () { constructor () public {
bool boolFalse = false; bool boolFalse = false;
bool boolTrue = true; bool boolTrue = true;
enumDef testEnum; enumDef testEnum;
...@@ -31,7 +31,7 @@ contract miscLocal { ...@@ -31,7 +31,7 @@ contract miscLocal {
} }
contract miscLocal2 { contract miscLocal2 {
function miscLocal2 () { constructor () public {
bytes memory dynbytes = "dynamicbytes"; bytes memory dynbytes = "dynamicbytes";
string memory smallstring = "test_test_test"; string memory smallstring = "test_test_test";
} }
......
...@@ -17,6 +17,7 @@ module.exports = ` ...@@ -17,6 +17,7 @@ module.exports = `
contract test1 { contract test1 {
struct str { struct str {
uint8 ui;
} }
} }
......
...@@ -24,7 +24,7 @@ contract structArrayLocal { ...@@ -24,7 +24,7 @@ contract structArrayLocal {
enumdef c; enumdef c;
} }
function structArrayLocal () { constructor () public {
bytes memory bytesSimple = "test_super"; bytes memory bytesSimple = "test_super";
teststruct memory e; teststruct memory e;
e.a = "test"; e.a = "test";
......
...@@ -25,7 +25,7 @@ module.exports = { ...@@ -25,7 +25,7 @@ module.exports = {
string str; string str;
} }
simpleStruct[][3] arrayStruct; simpleStruct[][3] arrayStruct;
function structArrayStorage () { constructor () public {
intStructDec.i8 = 32; intStructDec.i8 = 32;
intStructDec.i16 = -54; intStructDec.i16 = -54;
intStructDec.ui32 = 128; intStructDec.ui32 = 128;
......
...@@ -12,7 +12,7 @@ var util = require('../../src/solidity-decoder/types/util') ...@@ -12,7 +12,7 @@ var util = require('../../src/solidity-decoder/types/util')
tape('solidity', function (t) { tape('solidity', function (t) {
t.test('astHelper, decodeInfo', function (st) { t.test('astHelper, decodeInfo', function (st) {
var output = compiler.compileStandardWrapper(compilerInput(contracts)) var output = compiler.compile(compilerInput(contracts))
output = JSON.parse(output) output = JSON.parse(output)
var state = astHelper.extractStateDefinitions('test.sol:contractUint', output.sources) var state = astHelper.extractStateDefinitions('test.sol:contractUint', output.sources)
...@@ -65,9 +65,8 @@ tape('solidity', function (t) { ...@@ -65,9 +65,8 @@ tape('solidity', function (t) {
parsedType = decodeInfo.parseType(stateDef[5].attributes.type, states, 'contractSmallVariable', util.extractLocationFromAstVariable(stateDef[5])) parsedType = decodeInfo.parseType(stateDef[5].attributes.type, states, 'contractSmallVariable', util.extractLocationFromAstVariable(stateDef[5]))
checkDecodeInfo(st, parsedType, 1, 2, 'int16') checkDecodeInfo(st, parsedType, 1, 2, 'int16')
output = compiler.compileStandardWrapper(compilerInput(simplecontracts)) output = compiler.compile(compilerInput(simplecontracts))
output = JSON.parse(output) output = JSON.parse(output)
state = astHelper.extractStateDefinitions('test.sol:simpleContract', output.sources) state = astHelper.extractStateDefinitions('test.sol:simpleContract', output.sources)
states = astHelper.extractStatesDefinitions(output.sources) states = astHelper.extractStatesDefinitions(output.sources)
stateDef = state.stateDefinitions stateDef = state.stateDefinitions
...@@ -81,10 +80,10 @@ tape('solidity', function (t) { ...@@ -81,10 +80,10 @@ tape('solidity', function (t) {
state = astHelper.extractStateDefinitions('test.sol:test2', output.sources) state = astHelper.extractStateDefinitions('test.sol:test2', output.sources)
stateDef = state.stateDefinitions stateDef = state.stateDefinitions
parsedType = decodeInfo.parseType(stateDef[0].attributes.type, states, 'test1', util.extractLocationFromAstVariable(stateDef[0])) parsedType = decodeInfo.parseType(stateDef[0].attributes.type, states, 'test1', util.extractLocationFromAstVariable(stateDef[0]))
checkDecodeInfo(st, parsedType, 0, 32, 'struct test1.str') checkDecodeInfo(st, parsedType, 1, 32, 'struct test1.str')
state = stateDecoder.extractStateVariables('test.sol:test2', output.sources) state = stateDecoder.extractStateVariables('test.sol:test2', output.sources)
checkDecodeInfo(st, parsedType, 0, 32, 'struct test1.str') checkDecodeInfo(st, parsedType, 1, 32, 'struct test1.str')
st.end() st.end()
}) })
......
...@@ -21,16 +21,16 @@ tape('solidity', function (t) { ...@@ -21,16 +21,16 @@ tape('solidity', function (t) {
}) })
function test (st, vm, privateKey) { function test (st, vm, privateKey) {
var output = compiler.compileStandardWrapper(compilerInput(intLocal.contract)) var output = compiler.compile(compilerInput(intLocal.contract))
output = JSON.parse(output) output = JSON.parse(output)
intLocalTest(st, vm, privateKey, output.contracts['test.sol']['intLocal'].evm.bytecode.object, output, function () { intLocalTest(st, vm, privateKey, output.contracts['test.sol']['intLocal'].evm.bytecode.object, output, function () {
output = compiler.compileStandardWrapper(compilerInput(miscLocal.contract)) output = compiler.compile(compilerInput(miscLocal.contract))
output = JSON.parse(output) output = JSON.parse(output)
miscLocalTest(st, vm, privateKey, output.contracts['test.sol']['miscLocal'].evm.bytecode.object, output, function () { miscLocalTest(st, vm, privateKey, output.contracts['test.sol']['miscLocal'].evm.bytecode.object, output, function () {
output = compiler.compileStandardWrapper(compilerInput(miscLocal.contract)) output = compiler.compile(compilerInput(miscLocal.contract))
output = JSON.parse(output) output = JSON.parse(output)
misc2LocalTest(st, vm, privateKey, output.contracts['test.sol']['miscLocal2'].evm.bytecode.object, output, function () { misc2LocalTest(st, vm, privateKey, output.contracts['test.sol']['miscLocal2'].evm.bytecode.object, output, function () {
output = compiler.compileStandardWrapper(compilerInput(structArrayLocal.contract)) output = compiler.compile(compilerInput(structArrayLocal.contract))
output = JSON.parse(output) output = JSON.parse(output)
structArrayLocalTest(st, vm, privateKey, output.contracts['test.sol']['structArrayLocal'].evm.bytecode.object, output, function () { structArrayLocalTest(st, vm, privateKey, output.contracts['test.sol']['structArrayLocal'].evm.bytecode.object, output, function () {
st.end() st.end()
......
...@@ -13,7 +13,7 @@ module.exports = function testMappingStorage (st, cb) { ...@@ -13,7 +13,7 @@ module.exports = function testMappingStorage (st, cb) {
var mappingStorage = require('../contracts/mappingStorage') var mappingStorage = require('../contracts/mappingStorage')
var privateKey = Buffer.from('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', 'hex') var privateKey = Buffer.from('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', 'hex')
var vm = vmCall.initVM(st, privateKey) var vm = vmCall.initVM(st, privateKey)
var output = compiler.compileStandardWrapper(compilerInput(mappingStorage.contract)) var output = compiler.compile(compilerInput(mappingStorage.contract))
output = JSON.parse(output) output = JSON.parse(output)
vmCall.sendTx(vm, {nonce: 0, privateKey: privateKey}, null, 0, output.contracts['test.sol']['SimpleMappingState'].evm.bytecode.object, function (error, txHash) { vmCall.sendTx(vm, {nonce: 0, privateKey: privateKey}, null, 0, output.contracts['test.sol']['SimpleMappingState'].evm.bytecode.object, function (error, txHash) {
if (error) { if (error) {
...@@ -48,7 +48,7 @@ function testMapping (st, vm, privateKey, contractAddress, output, cb) { ...@@ -48,7 +48,7 @@ function testMapping (st, vm, privateKey, contractAddress, output, cb) {
var traceManager = new TraceManager({web3: vm.web3}) var traceManager = new TraceManager({web3: vm.web3})
traceManager.resolveTrace(tx, () => { traceManager.resolveTrace(tx, () => {
var storageViewer = new StorageViewer({ var storageViewer = new StorageViewer({
stepIndex: 213, stepIndex: 268,
tx: tx, tx: tx,
address: contractAddress address: contractAddress
}, new StorageResolver({web3: vm.web3}), traceManager) }, new StorageResolver({web3: vm.web3}), traceManager)
......
...@@ -23,7 +23,7 @@ tape('solidity', function (t) { ...@@ -23,7 +23,7 @@ tape('solidity', function (t) {
function testIntStorage (st, cb) { function testIntStorage (st, cb) {
var intStorage = require('./contracts/intStorage') var intStorage = require('./contracts/intStorage')
var output = compiler.compileStandardWrapper(compilerInput(intStorage.contract)) var output = compiler.compile(compilerInput(intStorage.contract))
output = JSON.parse(output) output = JSON.parse(output)
var mockStorageResolver var mockStorageResolver
for (var storage of [intStorage.fullStorage, shrinkStorage(intStorage.fullStorage)]) { for (var storage of [intStorage.fullStorage, shrinkStorage(intStorage.fullStorage)]) {
...@@ -70,7 +70,7 @@ function testIntStorage (st, cb) { ...@@ -70,7 +70,7 @@ function testIntStorage (st, cb) {
function testByteStorage (st, cb) { function testByteStorage (st, cb) {
var byteStorage = require('./contracts/byteStorage') var byteStorage = require('./contracts/byteStorage')
var output = compiler.compileStandardWrapper(compilerInput(byteStorage.contract)) var output = compiler.compile(compilerInput(byteStorage.contract))
output = JSON.parse(output) output = JSON.parse(output)
var mockStorageResolver var mockStorageResolver
for (var storage of [byteStorage.storage, shrinkStorage(byteStorage.storage)]) { for (var storage of [byteStorage.storage, shrinkStorage(byteStorage.storage)]) {
...@@ -183,7 +183,7 @@ function shrinkStorage (storage) { ...@@ -183,7 +183,7 @@ function shrinkStorage (storage) {
function testStructArrayStorage (st, cb) { function testStructArrayStorage (st, cb) {
var structArrayStorage = require('./contracts/structArrayStorage') var structArrayStorage = require('./contracts/structArrayStorage')
var output = compiler.compileStandardWrapper(compilerInput(structArrayStorage.contract)) var output = compiler.compile(compilerInput(structArrayStorage.contract))
output = JSON.parse(output) output = JSON.parse(output)
var mockStorageResolver = new MockStorageResolver(structArrayStorage.storage) var mockStorageResolver = new MockStorageResolver(structArrayStorage.storage)
stateDecoder.solidityState(mockStorageResolver, output.sources, 'structArrayStorage').then((decoded) => { stateDecoder.solidityState(mockStorageResolver, output.sources, 'structArrayStorage').then((decoded) => {
......
...@@ -8,7 +8,7 @@ var compilerInput = remixLib.helpers.compiler.compilerInput ...@@ -8,7 +8,7 @@ var compilerInput = remixLib.helpers.compiler.compilerInput
tape('solidity', function (t) { tape('solidity', function (t) {
t.test('storage location', function (st) { t.test('storage location', function (st) {
var output = compiler.compileStandardWrapper(compilerInput(contracts)) var output = compiler.compile(compilerInput(contracts))
output = JSON.parse(output) output = JSON.parse(output)
var stateDec = stateDecoder.extractStateVariables('contractUint', output.sources) var stateDec = stateDecoder.extractStateVariables('contractUint', output.sources)
checkLocation(st, stateDec[0].storagelocation, 0, 0) checkLocation(st, stateDec[0].storagelocation, 0, 0)
......
...@@ -17,7 +17,7 @@ tape('debug contract', function (t) { ...@@ -17,7 +17,7 @@ tape('debug contract', function (t) {
t.plan(12) t.plan(12)
var privateKey = Buffer.from('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', 'hex') var privateKey = Buffer.from('dae9801649ba2d95a21e688b56f77905e5667c44ce868ec83f82e838712a2c7a', 'hex')
var vm = vmCall.initVM(t, privateKey) var vm = vmCall.initVM(t, privateKey)
var output = compiler.compileStandardWrapper(compilerInput(ballot)) var output = compiler.compile(compilerInput(ballot))
output = JSON.parse(output) output = JSON.parse(output)
var web3VM = new remixLib.vm.Web3VMProvider() var web3VM = new remixLib.vm.Web3VMProvider()
web3VM.setVM(vm) web3VM.setVM(vm)
...@@ -109,8 +109,8 @@ function testDebugging (t, debugManager) { ...@@ -109,8 +109,8 @@ function testDebugging (t, debugManager) {
breakPointManager.event.register('breakpointHit', function (sourceLocation, step) { breakPointManager.event.register('breakpointHit', function (sourceLocation, step) {
console.log('breakpointHit') console.log('breakpointHit')
t.equal(JSON.stringify(sourceLocation), JSON.stringify({ start: 591, length: 1, file: 0, jump: '-' })) t.equal(JSON.stringify(sourceLocation), JSON.stringify({ start: 587, length: 1, file: 0, jump: '-' }))
t.equal(step, 75) t.equal(step, 74)
}) })
breakPointManager.event.register('noBreakpointHit', function () { breakPointManager.event.register('noBreakpointHit', function () {
...@@ -120,7 +120,7 @@ function testDebugging (t, debugManager) { ...@@ -120,7 +120,7 @@ function testDebugging (t, debugManager) {
breakPointManager.jumpNextBreakpoint(0, true) breakPointManager.jumpNextBreakpoint(0, true)
} }
var ballot = `pragma solidity ^0.4.0; var ballot = `pragma solidity ^0.5.0;
contract Ballot { contract Ballot {
struct Voter { struct Voter {
...@@ -138,13 +138,13 @@ contract Ballot { ...@@ -138,13 +138,13 @@ contract Ballot {
Proposal[] proposals; Proposal[] proposals;
/// Create a new ballot with $(_numProposals) different proposals. /// Create a new ballot with $(_numProposals) different proposals.
function Ballot() public { constructor() public {
uint p = 45; uint p = 45;
chairperson = msg.sender; chairperson = msg.sender;
address addressLocal = msg.sender; // copy of state variable address addressLocal = msg.sender; // copy of state variable
voters[chairperson].weight = 1; voters[chairperson].weight = 1;
proposals.length = 1; proposals.length = 1;
Proposal[] proposalsLocals = proposals; // copy of state variable Proposal[] storage proposalsLocals = proposals; // copy of state variable
} }
/// Give $(toVoter) the right to vote on this ballot. /// Give $(toVoter) the right to vote on this ballot.
...@@ -179,7 +179,7 @@ contract Ballot { ...@@ -179,7 +179,7 @@ contract Ballot {
proposals[toProposal].voteCount += sender.weight; proposals[toProposal].voteCount += sender.weight;
} }
function winningProposal() public constant returns (uint8 _winningProposal) { function winningProposal() public view returns (uint8 _winningProposal) {
uint256 winningVoteCount = 0; uint256 winningVoteCount = 0;
for (uint8 prop = 0; prop < proposals.length; prop++) for (uint8 prop = 0; prop < proposals.length; prop++)
if (proposals[prop].voteCount > winningVoteCount) { if (proposals[prop].voteCount > winningVoteCount) {
......
{ {
"name": "remix-lib", "name": "remix-lib",
"version": "0.3.8", "version": "0.3.12",
"description": "Ethereum IDE and tools for the web", "description": "Ethereum IDE and tools for the web",
"contributors": [ "contributors": [
{ {
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"ethereumjs-vm": "^2.3.3", "ethereumjs-vm": "^2.3.3",
"ethers": "^3.0.15", "ethers": "^3.0.15",
"fast-async": "^6.1.2", "fast-async": "^6.1.2",
"solc": "^0.4.13", "solc": "^0.5.0",
"standard": "^7.0.1", "standard": "^7.0.1",
"tape": "^4.6.0", "tape": "^4.6.0",
"web3": "0.20.6" "web3": "0.20.6"
......
...@@ -85,6 +85,7 @@ function ExecutionContext () { ...@@ -85,6 +85,7 @@ function ExecutionContext () {
this.blockGasLimitDefault = 4300000 this.blockGasLimitDefault = 4300000
this.blockGasLimit = this.blockGasLimitDefault this.blockGasLimit = this.blockGasLimitDefault
this.customNetWorks = {}
this.init = function (config) { this.init = function (config) {
if (config.get('settings/always-use-vm')) { if (config.get('settings/always-use-vm')) {
...@@ -134,6 +135,20 @@ function ExecutionContext () { ...@@ -134,6 +135,20 @@ function ExecutionContext () {
} }
} }
this.removeProvider = function (name) {
if (name && this.customNetWorks[name]) {
delete this.customNetWorks[name]
self.event.trigger('removeProvider', [name])
}
}
this.addProvider = function (network) {
if (network && network.name && network.url) {
this.customNetWorks[network.name] = network
self.event.trigger('addProvider', [network])
}
}
this.internalWeb3 = function () { this.internalWeb3 = function () {
return web3 return web3
} }
...@@ -182,6 +197,11 @@ function ExecutionContext () { ...@@ -182,6 +197,11 @@ function ExecutionContext () {
if (context === 'web3') { if (context === 'web3') {
confirmCb(cb) confirmCb(cb)
} }
if (this.customNetWorks[context]) {
var provider = this.customNetWorks[context]
setProviderFromEndpoint(provider.url, provider.name, () => { cb() })
}
} }
this.currentblockGasLimit = function () { this.currentblockGasLimit = function () {
......
...@@ -122,6 +122,7 @@ web3VmProvider.prototype.txProcessed = function (self, data) { ...@@ -122,6 +122,7 @@ web3VmProvider.prototype.txProcessed = function (self, data) {
} }
self.txsReceipt[self.processingHash].logs = logs self.txsReceipt[self.processingHash].logs = logs
self.txsReceipt[self.processingHash].transactionHash = self.processingHash self.txsReceipt[self.processingHash].transactionHash = self.processingHash
self.txsReceipt[self.processingHash].status = '0x' + data.vm.exception.toString(16)
if (data.createdAddress) { if (data.createdAddress) {
var address = util.hexConvert(data.createdAddress) var address = util.hexConvert(data.createdAddress)
......
...@@ -7,7 +7,7 @@ var compilerInput = require('../src/helpers/compilerHelper').compilerInput ...@@ -7,7 +7,7 @@ var compilerInput = require('../src/helpers/compilerHelper').compilerInput
tape('SourceMappingDecoder', function (t) { tape('SourceMappingDecoder', function (t) {
t.test('SourceMappingDecoder.findNodeAtInstructionIndex', function (st) { t.test('SourceMappingDecoder.findNodeAtInstructionIndex', function (st) {
var output = compiler.compileStandardWrapper(compilerInput(contracts)) var output = compiler.compile(compilerInput(contracts))
output = JSON.parse(output) output = JSON.parse(output)
var sourceMappingDecoder = new SourceMappingDecoder() var sourceMappingDecoder = new SourceMappingDecoder()
var node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 2, output.contracts['test.sol']['test'].evm.deployedBytecode.sourceMap, output.sources['test.sol']) var node = sourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', 2, output.contracts['test.sol']['test'].evm.deployedBytecode.sourceMap, output.sources['test.sol'])
...@@ -107,12 +107,12 @@ tape('SourceMappingDecoder', function (t) { ...@@ -107,12 +107,12 @@ tape('SourceMappingDecoder', function (t) {
}) })
var contracts = `contract test { var contracts = `contract test {
function f1() returns (uint) { function f1() public returns (uint) {
uint t = 4; uint t = 4;
return t; return t;
} }
function f2() { function f2() public {
} }
} }
......
This diff is collapsed.
{ {
"name": "remix-simulator", "name": "remix-simulator",
"version": "0.0.4", "version": "0.0.7",
"description": "Ethereum IDE and tools for the web", "description": "Ethereum IDE and tools for the web",
"contributors": [ "contributors": [
{ {
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"main": "./index.js", "main": "./index.js",
"dependencies": { "dependencies": {
"ansi-gray": "^0.1.1", "ansi-gray": "^0.1.1",
"babel-eslint": "^7.1.1",
"babel-plugin-transform-object-assign": "^6.22.0", "babel-plugin-transform-object-assign": "^6.22.0",
"babel-preset-es2017": "^6.24.1", "babel-preset-es2017": "^6.24.1",
"babelify": "^7.3.0", "babelify": "^7.3.0",
...@@ -23,7 +24,7 @@ ...@@ -23,7 +24,7 @@
"express": "^4.16.3", "express": "^4.16.3",
"fast-async": "^6.3.7", "fast-async": "^6.3.7",
"merge": "^1.2.0", "merge": "^1.2.0",
"remix-lib": "^0.2.5", "remix-lib": "0.3.12",
"standard": "^10.0.3", "standard": "^10.0.3",
"time-stamp": "^2.0.0", "time-stamp": "^2.0.0",
"web3": "1.0.0-beta.27" "web3": "1.0.0-beta.27"
......
...@@ -3,10 +3,15 @@ var Web3 = require('web3') ...@@ -3,10 +3,15 @@ var Web3 = require('web3')
var Accounts = function () { var Accounts = function () {
this.web3 = new Web3() this.web3 = new Web3()
// TODO: make it random and/or use remix-libs // TODO: make it random and/or use remix-libs
this.accounts = [this.web3.eth.accounts.create(['abcd'])] this.accounts = [this.web3.eth.accounts.create(['abcd']), this.web3.eth.accounts.create(['ef12']), this.web3.eth.accounts.create(['ef34'])]
this.accounts[this.accounts[0].address.toLowerCase()] = this.accounts[0] this.accounts[this.accounts[0].address.toLowerCase()] = this.accounts[0]
this.accounts[this.accounts[1].address.toLowerCase()] = this.accounts[1]
this.accounts[this.accounts[2].address.toLowerCase()] = this.accounts[2]
this.accounts[this.accounts[0].address.toLowerCase()].privateKey = Buffer.from(this.accounts[this.accounts[0].address.toLowerCase()].privateKey.slice(2), 'hex') this.accounts[this.accounts[0].address.toLowerCase()].privateKey = Buffer.from(this.accounts[this.accounts[0].address.toLowerCase()].privateKey.slice(2), 'hex')
this.accounts[this.accounts[1].address.toLowerCase()].privateKey = Buffer.from(this.accounts[this.accounts[1].address.toLowerCase()].privateKey.slice(2), 'hex')
this.accounts[this.accounts[2].address.toLowerCase()].privateKey = Buffer.from(this.accounts[this.accounts[2].address.toLowerCase()].privateKey.slice(2), 'hex')
} }
Accounts.prototype.methods = function () { Accounts.prototype.methods = function () {
......
...@@ -39,7 +39,7 @@ Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) { ...@@ -39,7 +39,7 @@ Transactions.prototype.eth_getTransactionReceipt = function (payload, cb) {
'cumulativeGasUsed': '0x06345f', 'cumulativeGasUsed': '0x06345f',
'contractAddress': receipt.contractAddress, 'contractAddress': receipt.contractAddress,
'logs': receipt.logs, 'logs': receipt.logs,
'status': 1 'status': receipt.status
} }
cb(null, r) cb(null, r)
......
{ {
"name": "remix-solidity", "name": "remix-solidity",
"version": "0.2.8", "version": "0.2.13",
"description": "Ethereum IDE and tools for the web", "description": "Ethereum IDE and tools for the web",
"contributors": [ "contributors": [
{ {
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
"ethereumjs-vm": "^2.3.3", "ethereumjs-vm": "^2.3.3",
"fast-async": "^6.1.2", "fast-async": "^6.1.2",
"npm-run-all": "^4.0.2", "npm-run-all": "^4.0.2",
"remix-lib": "^0.3.8", "remix-lib": "0.3.12",
"solc": "^0.4.24", "solc": "^0.5.0",
"standard": "^7.0.1", "standard": "^7.0.1",
"tape": "^4.6.0", "tape": "^4.6.0",
"webworkify": "^1.2.1" "webworkify": "^1.2.1"
......
...@@ -22,7 +22,7 @@ module.exports = function (self) { ...@@ -22,7 +22,7 @@ module.exports = function (self) {
compileJSON = function (input) { compileJSON = function (input) {
try { try {
return compiler.compileStandardWrapper(input, function (path) { return compiler.compile(input, function (path) {
missingInputs.push(path) missingInputs.push(path)
return { 'error': 'Deferred import' } return { 'error': 'Deferred import' }
}) })
......
...@@ -90,7 +90,7 @@ function Compiler (handleImportCall) { ...@@ -90,7 +90,7 @@ function Compiler (handleImportCall) {
var result var result
try { try {
var input = compilerInput(source.sources, {optimize: optimize, target: source.target}) var input = compilerInput(source.sources, {optimize: optimize, target: source.target})
result = compiler.compileStandardWrapper(input, missingInputsCallback) result = compiler.compile(input, missingInputsCallback)
result = JSON.parse(result) result = JSON.parse(result)
} catch (exception) { } catch (exception) {
result = { error: { formattedMessage: 'Uncaught JavaScript exception:\n' + exception, severity: 'error', mode: 'panic' } } result = { error: { formattedMessage: 'Uncaught JavaScript exception:\n' + exception, severity: 'error', mode: 'panic' } }
...@@ -313,7 +313,7 @@ function Compiler (handleImportCall) { ...@@ -313,7 +313,7 @@ function Compiler (handleImportCall) {
while ((match = importRegex.exec(files[fileName].content))) { while ((match = importRegex.exec(files[fileName].content))) {
var importFilePath = match[1] var importFilePath = match[1]
if (importFilePath.startsWith('./')) { if (importFilePath.startsWith('./')) {
var path = /(.*\/).*/.exec(target) var path = /(.*\/).*/.exec(fileName)
if (path !== null) { if (path !== null) {
importFilePath = importFilePath.replace('./', path[1]) importFilePath = importFilePath.replace('./', path[1])
} else { } else {
......
[![Build Status](https://travis-ci.org/ethereum/remix-tests.svg?branch=master)](https://travis-ci.org/ethereum/remix-tests)
Remix-Tests Remix-Tests
--- ---
...@@ -43,6 +41,8 @@ contract MyTest { ...@@ -43,6 +41,8 @@ contract MyTest {
} }
``` ```
See also: example [Su Squares contract](https://github.com/su-squares/ethereum-contract/tree/e542f37d4f8f6c7b07d90a6554424268384a4186) and [https://travis-ci.org/su-squares/ethereum-contract/builds/446186067](Travis build) that uses remix-tests for continuous integration testing.
Available special functions: Available special functions:
* `beforeEach()` - runs before each test * `beforeEach()` - runs before each test
* `beforeAll()` - runs before all tests * `beforeAll()` - runs before all tests
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment