Merge branch 'master' of https://github.com/ethereum/remix-project into remixd
commit
c027b3915a
@ -0,0 +1,167 @@ |
|||||||
|
'use strict' |
||||||
|
|
||||||
|
import { NightwatchBrowser } from 'nightwatch' |
||||||
|
import init from '../helpers/init' |
||||||
|
import sauce from './sauce' |
||||||
|
import examples from '../examples/example-contracts' |
||||||
|
|
||||||
|
const sources = [ |
||||||
|
{'browser/Untitled.sol': { content: examples.ballot_0_4_11.content }} |
||||||
|
] |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
before: function (browser: NightwatchBrowser, done: VoidFunction) { |
||||||
|
init(browser, done, null, false) |
||||||
|
}, |
||||||
|
'@sources': function () { |
||||||
|
return sources |
||||||
|
}, |
||||||
|
'Compile Ballot with compiler version 0.4.11': function (browser: NightwatchBrowser) { |
||||||
|
browser |
||||||
|
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000) |
||||||
|
.clickLaunchIcon('solidity') |
||||||
|
.setSolidityCompilerVersion('soljson-v0.4.11+commit.68ef5810.js') |
||||||
|
.waitForElementVisible('[for="autoCompile"]') |
||||||
|
.click('[for="autoCompile"]') |
||||||
|
.verify.elementPresent('[data-id="compilerContainerAutoCompile"]:checked') |
||||||
|
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot']) |
||||||
|
|
||||||
|
}, |
||||||
|
|
||||||
|
'Deploy Ballot': function (browser: NightwatchBrowser) { |
||||||
|
browser.pause(500) |
||||||
|
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot']) |
||||||
|
.clickLaunchIcon('udapp') |
||||||
|
.selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c') |
||||||
|
.setValue('input[placeholder="uint8 _numProposals"]', '2') |
||||||
|
.click('*[data-id="Deploy - transact (not payable)"]') |
||||||
|
.waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]') |
||||||
|
.click('*[data-id="universalDappUiTitleExpander"]') |
||||||
|
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}) |
||||||
|
.testFunction('0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3', |
||||||
|
{ |
||||||
|
status: 'true Transaction mined and execution succeed', |
||||||
|
'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3', |
||||||
|
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' } |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
'Debug Ballot / delegate': function (browser: NightwatchBrowser) { |
||||||
|
browser.pause(500) |
||||||
|
.click('*[data-id="txLoggerDebugButton0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3"]') |
||||||
|
.pause(2000) |
||||||
|
.click('*[data-id="buttonNavigatorJumpPreviousBreakpoint"]') |
||||||
|
.pause(2000) |
||||||
|
.goToVMTraceStep(20) |
||||||
|
.pause(1000) |
||||||
|
.checkVariableDebug('callstackpanel', ["0x692a70D2e424a56D2C6C27aA97D1a86395877b3A"]) |
||||||
|
}, |
||||||
|
|
||||||
|
'Access Ballot via at address': function (browser: NightwatchBrowser) { |
||||||
|
browser.clickLaunchIcon('udapp') |
||||||
|
.click('*[data-id="universalDappUiUdappClose"]') |
||||||
|
.addFile('ballot.abi', { content: ballotABI }) |
||||||
|
.addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3B', true, false) |
||||||
|
.clickLaunchIcon('fileExplorers') |
||||||
|
.addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3A', true, true) |
||||||
|
.pause(500) |
||||||
|
.waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]') |
||||||
|
.click('*[data-id="universalDappUiTitleExpander"]') |
||||||
|
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}) |
||||||
|
.testFunction('0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803', |
||||||
|
{ |
||||||
|
status: 'true Transaction mined and execution succeed', |
||||||
|
'transaction hash': '0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803', |
||||||
|
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' } |
||||||
|
}) |
||||||
|
}, |
||||||
|
|
||||||
|
'Deploy and use Ballot using external web3': function (browser: NightwatchBrowser) { |
||||||
|
browser |
||||||
|
.click('*[data-id="settingsWeb3Mode"]') |
||||||
|
.modalFooterOKClick() |
||||||
|
.clickLaunchIcon('solidity') |
||||||
|
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot']) |
||||||
|
.clickLaunchIcon('udapp') |
||||||
|
.setValue('input[placeholder="uint8 _numProposals"]', '2') |
||||||
|
.click('*[data-id="Deploy - transact (not payable)"]') |
||||||
|
.clickInstance(0) |
||||||
|
.click('*[data-id="terminalClearConsole"]') |
||||||
|
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'}) |
||||||
|
.journalLastChildIncludes('Ballot.delegate(address)') |
||||||
|
.journalLastChildIncludes('data: 0x5c1...a733c') |
||||||
|
.end() |
||||||
|
}, |
||||||
|
|
||||||
|
tearDown: sauce |
||||||
|
} |
||||||
|
|
||||||
|
const ballotABI = `[
|
||||||
|
{ |
||||||
|
"constant": false, |
||||||
|
"inputs": [ |
||||||
|
{ |
||||||
|
"name": "to", |
||||||
|
"type": "address" |
||||||
|
} |
||||||
|
], |
||||||
|
"name": "delegate", |
||||||
|
"outputs": [], |
||||||
|
"payable": false, |
||||||
|
"type": "function", |
||||||
|
"stateMutability": "nonpayable" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"constant": false, |
||||||
|
"inputs": [], |
||||||
|
"name": "winningProposal", |
||||||
|
"outputs": [ |
||||||
|
{ |
||||||
|
"name": "_winningProposal", |
||||||
|
"type": "uint8" |
||||||
|
} |
||||||
|
], |
||||||
|
"payable": false, |
||||||
|
"type": "function", |
||||||
|
"stateMutability": "nonpayable" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"constant": false, |
||||||
|
"inputs": [ |
||||||
|
{ |
||||||
|
"name": "toVoter", |
||||||
|
"type": "address" |
||||||
|
} |
||||||
|
], |
||||||
|
"name": "giveRightToVote", |
||||||
|
"outputs": [], |
||||||
|
"payable": false, |
||||||
|
"type": "function", |
||||||
|
"stateMutability": "nonpayable" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"constant": false, |
||||||
|
"inputs": [ |
||||||
|
{ |
||||||
|
"name": "toProposal", |
||||||
|
"type": "uint8" |
||||||
|
} |
||||||
|
], |
||||||
|
"name": "vote", |
||||||
|
"outputs": [], |
||||||
|
"payable": false, |
||||||
|
"type": "function", |
||||||
|
"stateMutability": "nonpayable" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"inputs": [ |
||||||
|
{ |
||||||
|
"name": "_numProposals", |
||||||
|
"type": "uint8" |
||||||
|
} |
||||||
|
], |
||||||
|
"payable": false, |
||||||
|
"type": "constructor", |
||||||
|
"stateMutability": "nonpayable" |
||||||
|
} |
||||||
|
]` |
@ -1,101 +0,0 @@ |
|||||||
import tape from "tape"; |
|
||||||
import { AstWalker, AstNodeLegacy } from "../src"; |
|
||||||
import node from "./resources/legacyAST"; |
|
||||||
|
|
||||||
|
|
||||||
tape("ASTWalker Legacy", (t: tape.Test) => { |
|
||||||
t.test("ASTWalker.walk && .walkAST", (st: tape.Test) => { |
|
||||||
st.plan(17); |
|
||||||
// New Ast Object
|
|
||||||
const astWalker = new AstWalker(); |
|
||||||
// EventListener
|
|
||||||
astWalker.on("node", node => { |
|
||||||
if (node.name === "ContractDefinition") { |
|
||||||
checkContract(st, node); |
|
||||||
} |
|
||||||
if (node.name === "FunctionDefinition") { |
|
||||||
checkSetFunction(st, node); |
|
||||||
checkGetFunction(st, node); |
|
||||||
} |
|
||||||
if (node.name === "VariableDeclaration") { |
|
||||||
checkSetFunction(st, node); |
|
||||||
checkGetFunction(st, node); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
// Callback pattern
|
|
||||||
astWalker.walk(node.legacyAST, (node: AstNodeLegacy) => { |
|
||||||
if (node.name === "ContractDefinition") { |
|
||||||
checkContract(st, node); |
|
||||||
} |
|
||||||
if (node.name === "FunctionDefinition") { |
|
||||||
checkSetFunction(st, node); |
|
||||||
checkGetFunction(st, node); |
|
||||||
} |
|
||||||
if (node.name === "VariableDeclaration") { |
|
||||||
checkSetFunction(st, node); |
|
||||||
checkGetFunction(st, node); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
// Callback Object
|
|
||||||
var callback: any = {}; |
|
||||||
callback.FunctionDefinition = function(node: AstNodeLegacy): boolean { |
|
||||||
st.equal(node.name, "FunctionDefinition"); |
|
||||||
|
|
||||||
return true; |
|
||||||
}; |
|
||||||
// Calling walk function with cb
|
|
||||||
astWalker.walk(node.legacyAST, callback); |
|
||||||
|
|
||||||
// Calling walk function without cb
|
|
||||||
astWalker.walk(node.legacyAST); |
|
||||||
|
|
||||||
// Calling WALKASTLIST function
|
|
||||||
astWalker.walkAstList(node); |
|
||||||
// Calling walkASTList with new AST format
|
|
||||||
astWalker.walkAstList(node); |
|
||||||
|
|
||||||
// Calling WALKASTLIST function with cb
|
|
||||||
astWalker.walkAstList(node, node => { |
|
||||||
return true; |
|
||||||
}); |
|
||||||
st.end(); |
|
||||||
}); |
|
||||||
}); |
|
||||||
|
|
||||||
function checkContract(st: tape.Test, node: AstNodeLegacy) { |
|
||||||
st.equal(node.attributes.name, "Greeter"); |
|
||||||
st.equal(node.children[1].attributes.name, "greeting"); |
|
||||||
st.equal(node.children[1].attributes.type, "string"); |
|
||||||
st.equal(node.children[2].name, "FunctionDefinition"); |
|
||||||
st.equal(node.children[2].attributes.name, ""); |
|
||||||
} |
|
||||||
|
|
||||||
function checkSetFunction(st: tape.Test, node: AstNodeLegacy) { |
|
||||||
if (node.attributes.name === "set") { |
|
||||||
st.equal(node.children[0].name, "ParameterList"); |
|
||||||
st.equal(node.children[1].name, "ParameterList"); |
|
||||||
st.equal(node.children[2].name, "Block"); |
|
||||||
st.equal(node.children[2].children[1].name, "ExpressionStatement"); |
|
||||||
checkExpressionStatement(st, node.children[2].children[0]); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
function checkGetFunction(st: tape.Test, node: AstNodeLegacy) { |
|
||||||
if (node.attributes.name === "get") { |
|
||||||
st.equal(node.children[0].name, "ParameterList"); |
|
||||||
st.equal(node.children[1].name, "ParameterList"); |
|
||||||
st.equal(node.children[2].name, "Block"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
function checkExpressionStatement(st: tape.Test, node: AstNodeLegacy) { |
|
||||||
st.equal(node.children[0].name, "Assignment"); |
|
||||||
st.equal(node.children[0].attributes.operator, "="); |
|
||||||
st.equal(node.children[0].attributes.type, "int256"); |
|
||||||
st.equal(node.children[0].children[0].name, "Identifier"); |
|
||||||
st.equal(node.children[0].children[0].attributes.value, "x"); |
|
||||||
st.equal(node.children[0].children[1].name, "Identifier"); |
|
||||||
st.equal(node.children[0].children[1].attributes.value, "_x"); |
|
||||||
} |
|
@ -0,0 +1,33 @@ |
|||||||
|
class Debug { |
||||||
|
constructor (executionContext) { |
||||||
|
this.executionContext = executionContext |
||||||
|
} |
||||||
|
|
||||||
|
methods () { |
||||||
|
return { |
||||||
|
debug_traceTransaction: this.debug_traceTransaction.bind(this), |
||||||
|
debug_preimage: this.debug_preimage.bind(this), |
||||||
|
debug_storageRangeAt: this.debug_storageRangeAt.bind(this), |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
debug_traceTransaction (payload, cb) { |
||||||
|
this.executionContext.web3().debug.traceTransaction(payload.params[0], {}, cb) |
||||||
|
} |
||||||
|
|
||||||
|
debug_preimage (payload, cb) { |
||||||
|
this.executionContext.web3().debug.preimage(payload.params[0], cb) |
||||||
|
} |
||||||
|
|
||||||
|
debug_storageRangeAt (payload, cb) { |
||||||
|
this.executionContext.web3().debug.storageRangeAt( |
||||||
|
payload.params[0], |
||||||
|
payload.params[1], |
||||||
|
payload.params[2], |
||||||
|
payload.params[3], |
||||||
|
payload.params[4], |
||||||
|
cb) |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = Debug |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue