Fix and add tests.

pull/1/head
chriseth 8 years ago
parent 999b91930a
commit 6017b95993
  1. 2
      package.json
  2. 2
      src/app/staticanalysis/modules/gasCosts.js
  3. 32
      test-browser/tests/staticanalysis.js

@ -10,7 +10,7 @@
"browser-test-remote-ie": "nightwatch --config nightwatch.js --env ie",
"browser-test-remote-safari": "nightwatch --config nightwatch.js --env safari",
"browser-test-remote-parallel": "nightwatch --config nightwatch.js --env safari,ie,default,chrome",
"build": "mkdir -p build; browserify src/index.js -g yo-yoify -o build/app.js; babel build/app.js -s --out-file build/app.js",
"build": "mkdir -p build; browserify src/index.js -g yo-yoify -o build/app.js; babel build/app.js --out-file build/app.js",
"csslint": "csslint --ignore=order-alphabetical --errors='errors,duplicate-properties,empty-rules' --exclude-list='assets/css/font-awesome.min.css' assets/css/",
"downloadsolc": "rm soljson.js; wget https://ethereum.github.io/solc-bin/soljson.js",
"lint": "standard",

@ -19,7 +19,7 @@ gasCosts.prototype.report = function (compilationResults) {
if (fallback === null || fallback >= 2100) {
report.push({
warning: `Fallback function of contract ${contractName} requires too much gas (${fallback}).\n
If the fallback function requires too much gas, the contract cannot receive Ether.`
If the fallback function requires more than 2300 gas, the contract cannot receive Ether.`
})
}
}

@ -5,7 +5,13 @@ var sauce = require('./sauce')
var sources = {
'sources': {
'Untitled': `contract test1 { address test = tx.origin; } contract test2 {}`
'Untitled': `
contract test1 { address test = tx.origin; }
contract test2 {}
contract TooMuchGas {
uint x;
function() { x++; }
}`
}
}
@ -22,15 +28,33 @@ module.exports = {
tearDown: sauce
}
function findText (browser, selector, textToFind) {
var found = false
browser
.elements('css selector', selector, function (warnings) {
warnings.value.forEach(function (warning) {
browser.elementIdText(warning.ELEMENT, function (text) {
if (text.indexOf(textToFind) >= 0) {
found = true
}
})
})
})
browser.assert.equal(found, true)
}
function runTests (browser) {
browser
.waitForElementVisible('.newFile', 10000)
contractHelper.testContracts(browser, sources.sources.Untitled, ['test1', 'test2'], function () {
contractHelper.testContracts(browser, sources.sources.Untitled, ['TooMuchGas', 'test1', 'test2'], function () {
browser
.click('.staticanalysisView')
.click('#staticanalysisView button')
.waitForElementPresent('#staticanalysisresult .warning')
.assert.containsText('#staticanalysisresult .warning pre', 'Untitled:1:33: use of tx.origin')
.end()
findText(browser, '#staticanalysisresult .warning span',
'Untitled:2:33: use of tx.origin')
findText(browser, '#staticanalysisresult .warning span',
'Fallback function of contract TooMuchGas requires too much gas')
browser.end()
})
}

Loading…
Cancel
Save