You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
317 lines
7.9 KiB
317 lines
7.9 KiB
8 years ago
|
'use strict'
|
||
7 years ago
|
var examples = require('../../src/app/editor/example-contracts')
|
||
8 years ago
|
var init = require('../helpers/init')
|
||
8 years ago
|
var sauce = require('./sauce')
|
||
8 years ago
|
|
||
7 years ago
|
var sources = [
|
||
7 years ago
|
{'browser/Untitled.sol': {content: examples.ballot.content}}
|
||
7 years ago
|
]
|
||
8 years ago
|
|
||
|
module.exports = {
|
||
8 years ago
|
before: function (browser, done) {
|
||
|
init(browser, done)
|
||
|
},
|
||
8 years ago
|
'@sources': function () {
|
||
8 years ago
|
return sources
|
||
|
},
|
||
5 years ago
|
'Deploy Ballot': function (browser) {
|
||
|
browser
|
||
5 years ago
|
.waitForElementVisible('*[data-id="remixIdeIconPanel"]', 10000)
|
||
6 years ago
|
.clickLaunchIcon('solidity')
|
||
5 years ago
|
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
|
||
5 years ago
|
.clickLaunchIcon('udapp')
|
||
5 years ago
|
.selectAccount('0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c')
|
||
5 years ago
|
.setValue('input[placeholder="bytes32[] proposalNames"]', '["0x48656c6c6f20576f726c64210000000000000000000000000000000000000000"]')
|
||
5 years ago
|
.click('*[data-id="Deploy - transact (not payable)"]')
|
||
5 years ago
|
.waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]')
|
||
5 years ago
|
.click('*[data-id="universalDappUiTitleExpander"]')
|
||
5 years ago
|
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'})
|
||
|
.testFunction('0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
|
||
5 years ago
|
{
|
||
|
status: '0x1 Transaction mined and execution succeed',
|
||
|
'transaction hash': '0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3',
|
||
|
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
|
||
5 years ago
|
})
|
||
5 years ago
|
},
|
||
|
|
||
|
'Debug Ballot / delegate': function (browser) {
|
||
|
browser.pause(500)
|
||
5 years ago
|
.click('*[data-id="txLoggerDebugButton0x41fab8ea5b1d9fba5e0a6545ca1a2d62fff518578802c033c2b9a031a01c31b3"]')
|
||
5 years ago
|
.pause(2000)
|
||
5 years ago
|
// .clickLaunchIcon('debugger')
|
||
5 years ago
|
.click('*[data-id="buttonNavigatorJumpPreviousBreakpoint"]')
|
||
5 years ago
|
.pause(2000)
|
||
5 years ago
|
.goToVMTraceStep(79)
|
||
5 years ago
|
.pause(1000)
|
||
|
.checkVariableDebug('soliditystate', stateCheck)
|
||
5 years ago
|
.checkVariableDebug('soliditylocals', localsCheck)
|
||
5 years ago
|
},
|
||
|
|
||
|
'Access Ballot via at address': function (browser) {
|
||
5 years ago
|
browser.clickLaunchIcon('udapp')
|
||
5 years ago
|
.click('*[data-id="universalDappUiUdappClose"]')
|
||
5 years ago
|
.addFile('ballot.abi', { content: ballotABI })
|
||
|
.addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3B', true, false)
|
||
|
.clickLaunchIcon('fileExplorers')
|
||
|
.addAtAddressInstance('0x692a70D2e424a56D2C6C27aA97D1a86395877b3A', true, true)
|
||
|
.pause(500)
|
||
5 years ago
|
.waitForElementPresent('*[data-id="universalDappUiContractActionWrapper"]')
|
||
|
.click('*[data-id="universalDappUiTitleExpander"]')
|
||
|
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'})
|
||
|
.testFunction('0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
|
||
5 years ago
|
{
|
||
|
status: '0x0 Transaction mined but execution failed',
|
||
|
'transaction hash': '0xca58080c8099429caeeffe43b8104df919c2c543dceb9edf9242fa55f045c803',
|
||
|
'decoded input': { 'address to': '0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB' }
|
||
|
})
|
||
5 years ago
|
},
|
||
|
|
||
|
'Deploy and use Ballot using external web3': function (browser) {
|
||
|
browser
|
||
5 years ago
|
.click('*[data-id="settingsWeb3Mode"]')
|
||
5 years ago
|
.modalFooterOKClick()
|
||
|
.clickLaunchIcon('solidity')
|
||
|
.testContracts('Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'])
|
||
|
.clickLaunchIcon('udapp')
|
||
|
.setValue('input[placeholder="bytes32[] proposalNames"]', '["0x48656c6c6f20576f726c64210000000000000000000000000000000000000000"]')
|
||
5 years ago
|
.click('*[data-id="Deploy - transact (not payable)"]')
|
||
5 years ago
|
.clickInstance(0)
|
||
5 years ago
|
.click('*[data-id="terminalClearConsole"]')
|
||
5 years ago
|
.clickFunction('delegate - transact (not payable)', {types: 'address to', values: '0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c'})
|
||
|
.journalLastChildIncludes('Ballot.delegate(address)')
|
||
|
.journalLastChildIncludes('data:0x5c1...a733c')
|
||
5 years ago
|
.end()
|
||
5 years ago
|
},
|
||
5 years ago
|
|
||
5 years ago
|
tearDown: sauce
|
||
8 years ago
|
}
|
||
7 years ago
|
|
||
|
var localsCheck = {
|
||
|
'to': {
|
||
|
'value': '0x4B0897B0513FDC7C541B6D9D7E929C4E5364D2DB',
|
||
|
'type': 'address'
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var stateCheck = {
|
||
|
'chairperson': {
|
||
|
'value': '0xCA35B7D915458EF540ADE6068DFE2F44E8FA733C',
|
||
|
'type': 'address',
|
||
|
'constant': false
|
||
|
},
|
||
|
'voters': {
|
||
|
'value': {
|
||
|
'000000000000000000000000ca35b7d915458ef540ade6068dfe2f44e8fa733c': {
|
||
|
'value': {
|
||
|
'weight': {
|
||
|
'value': '1',
|
||
|
'type': 'uint256'
|
||
|
},
|
||
|
'voted': {
|
||
|
'value': false,
|
||
|
'type': 'bool'
|
||
|
},
|
||
|
'delegate': {
|
||
|
'value': '0x0000000000000000000000000000000000000000',
|
||
|
'type': 'address'
|
||
5 years ago
|
},
|
||
|
'vote': {
|
||
|
'value': '0',
|
||
|
'type': 'uint256'
|
||
7 years ago
|
}
|
||
|
},
|
||
|
'type': 'struct Ballot.Voter'
|
||
|
}
|
||
|
},
|
||
|
'type': 'mapping(address => struct Ballot.Voter)',
|
||
|
'constant': false
|
||
|
},
|
||
|
'proposals': {
|
||
|
'value': [
|
||
|
{
|
||
|
'value': {
|
||
5 years ago
|
'name': {
|
||
|
'value': '0x48656C6C6F20576F726C64210000000000000000000000000000000000000000',
|
||
|
'type': 'bytes32'
|
||
|
},
|
||
7 years ago
|
'voteCount': {
|
||
|
'value': '0',
|
||
|
'type': 'uint256'
|
||
|
}
|
||
|
},
|
||
|
'type': 'struct Ballot.Proposal'
|
||
|
}
|
||
|
],
|
||
|
'length': '0x1',
|
||
|
'type': 'struct Ballot.Proposal[]',
|
||
|
'constant': false
|
||
|
}
|
||
|
}
|
||
7 years ago
|
|
||
5 years ago
|
var ballotABI = `[
|
||
|
{
|
||
|
"inputs": [
|
||
|
{
|
||
|
"internalType": "bytes32[]",
|
||
|
"name": "proposalNames",
|
||
|
"type": "bytes32[]"
|
||
|
}
|
||
|
],
|
||
|
"payable": false,
|
||
|
"stateMutability": "nonpayable",
|
||
|
"type": "constructor"
|
||
|
},
|
||
|
{
|
||
|
"constant": true,
|
||
|
"inputs": [],
|
||
|
"name": "chairperson",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"internalType": "address",
|
||
|
"name": "",
|
||
|
"type": "address"
|
||
|
}
|
||
|
],
|
||
|
"payable": false,
|
||
|
"stateMutability": "view",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": false,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"internalType": "address",
|
||
|
"name": "to",
|
||
|
"type": "address"
|
||
|
}
|
||
|
],
|
||
|
"name": "delegate",
|
||
|
"outputs": [],
|
||
|
"payable": false,
|
||
|
"stateMutability": "nonpayable",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": false,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"internalType": "address",
|
||
|
"name": "voter",
|
||
|
"type": "address"
|
||
|
}
|
||
|
],
|
||
|
"name": "giveRightToVote",
|
||
|
"outputs": [],
|
||
|
"payable": false,
|
||
|
"stateMutability": "nonpayable",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": true,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"internalType": "uint256",
|
||
|
"name": "",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"name": "proposals",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"internalType": "bytes32",
|
||
|
"name": "name",
|
||
|
"type": "bytes32"
|
||
|
},
|
||
|
{
|
||
|
"internalType": "uint256",
|
||
|
"name": "voteCount",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"payable": false,
|
||
|
"stateMutability": "view",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": false,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"internalType": "uint256",
|
||
|
"name": "proposal",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"name": "vote",
|
||
|
"outputs": [],
|
||
|
"payable": false,
|
||
|
"stateMutability": "nonpayable",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": true,
|
||
|
"inputs": [
|
||
|
{
|
||
|
"internalType": "address",
|
||
|
"name": "",
|
||
|
"type": "address"
|
||
|
}
|
||
|
],
|
||
|
"name": "voters",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"internalType": "uint256",
|
||
|
"name": "weight",
|
||
|
"type": "uint256"
|
||
|
},
|
||
|
{
|
||
|
"internalType": "bool",
|
||
|
"name": "voted",
|
||
|
"type": "bool"
|
||
|
},
|
||
|
{
|
||
|
"internalType": "address",
|
||
|
"name": "delegate",
|
||
|
"type": "address"
|
||
|
},
|
||
|
{
|
||
|
"internalType": "uint256",
|
||
|
"name": "vote",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"payable": false,
|
||
|
"stateMutability": "view",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": true,
|
||
|
"inputs": [],
|
||
|
"name": "winnerName",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"internalType": "bytes32",
|
||
|
"name": "winnerName_",
|
||
|
"type": "bytes32"
|
||
|
}
|
||
|
],
|
||
|
"payable": false,
|
||
|
"stateMutability": "view",
|
||
|
"type": "function"
|
||
|
},
|
||
|
{
|
||
|
"constant": true,
|
||
|
"inputs": [],
|
||
|
"name": "winningProposal",
|
||
|
"outputs": [
|
||
|
{
|
||
|
"internalType": "uint256",
|
||
|
"name": "winningProposal_",
|
||
|
"type": "uint256"
|
||
|
}
|
||
|
],
|
||
|
"payable": false,
|
||
|
"stateMutability": "view",
|
||
|
"type": "function"
|
||
|
}
|
||
|
]`
|