remix-project mirror
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.
remix-project/test-browser/tests/ballot.js

134 lines
4.7 KiB

'use strict'
var contractHelper = require('../helpers/contracts')
var examples = require('../../src/app/editor/example-contracts')
var init = require('../helpers/init')
var sauce = require('./sauce')
var sources = [
7 years ago
{'browser/Untitled.sol': {content: examples.ballot.content}}
]
8 years ago
module.exports = {
before: function (browser, done) {
init(browser, done)
},
'@sources': function () {
return sources
},
8 years ago
'Ballot': function (browser) {
runTests(browser)
},
tearDown: sauce
}
8 years ago
function runTests (browser, testData) {
browser.testFunction = contractHelper.testFunction
8 years ago
browser
.waitForElementVisible('.newFile', 10000)
7 years ago
.click('.compileView')
7 years ago
contractHelper.testContracts(browser, 'Untitled.sol', sources[0]['browser/Untitled.sol'], ['Ballot'], function () {
browser
.click('.runView')
.setValue('input[placeholder="uint8 _numProposals"]', '1', () => {})
.click('#runTabView div[class^="create"]')
.testFunction('delegate - transact (not payable)', '0xd3cd54e2f76f3993078ecf9e1b54a148def4520afc141a182293b3610bddf10f',
7 years ago
'[vm] from:0xca3...a733c, to:Ballot.delegate(address) 0x692...77b3a, value:0 wei, data:0x5c1...4d2db, 0 logs, hash:0xd3c...df10f',
{types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}, null, null)
.click('span#tx0xd3cd54e2f76f3993078ecf9e1b54a148def4520afc141a182293b3610bddf10f button[class^="debug"]')
.pause(1000)
.click('#jumppreviousbreakpoint')
.click('#stepdetail .title')
.click('#asmcodes .title')
.pause(500)
.perform(function (client, done) {
contractHelper.goToVMtraceStep(browser, 39, () => {
done()
})
})
7 years ago
.pause(5000)
.perform(function (client, done) {
contractHelper.checkDebug(browser, 'soliditystate', stateCheck, () => {
done()
})
})
.perform(function (client, done) {
contractHelper.checkDebug(browser, 'soliditylocals', localsCheck, () => {
done()
7 years ago
})
})
.click('div[class^="udappClose"]')
.perform(function (client, done) {
contractHelper.addFile(client, 'ballot.abi', ballotABI, () => {
contractHelper.addInstance(client, '0x692a70d2e424a56d2c6c27aa97d1a86395877b3a', () => {
browser.testFunction('delegate - transact (not payable)', '0x8a0de532559a9c20b98d451b4873bb78ec723c585cb1c170bdcd30ccda0afa76',
'[vm] from:0xca3...a733c, to:Ballot.delegate(address) 0x692...77b3a, value:0 wei, data:0x5c1...4d2db, 0 logs, hash:0x8a0...afa76',
{types: 'address to', values: '"0x4b0897b0513fdc7c541b6d9d7e929c4e5364d2db"'}, null, null).perform(() => {
done()
browser.end()
})
})
})
})
})
}
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'
},
'vote': {
'value': '0',
'type': 'uint8'
},
'delegate': {
'value': '0x0000000000000000000000000000000000000000',
'type': 'address'
}
},
'type': 'struct Ballot.Voter'
}
},
'type': 'mapping(address => struct Ballot.Voter)',
'constant': false
},
'proposals': {
'value': [
{
'value': {
'voteCount': {
'value': '0',
'type': 'uint256'
}
},
'type': 'struct Ballot.Proposal'
}
],
'length': '0x1',
'type': 'struct Ballot.Proposal[]',
'constant': false
}
}
7 years ago
var ballotABI = '[{"constant":false,"inputs":[{"name":"to","type":"address"}],"name":"delegate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"winningProposal","outputs":[{"name":"_winningProposal","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"toVoter","type":"address"}],"name":"giveRightToVote","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"toProposal","type":"uint8"}],"name":"vote","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_numProposals","type":"uint8"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]'