|
|
|
@ -2,15 +2,6 @@ |
|
|
|
|
var init = require('../helpers/init') |
|
|
|
|
var sauce = require('./sauce') |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* both are declared, sending data |
|
|
|
|
* both are declared - receive called, sending wei |
|
|
|
|
* both are declared - fallback should fail cause not payable, sending data and wei |
|
|
|
|
* receive is declared, failing, fallback is not declared, sending data |
|
|
|
|
* receive is not declared, fallback is payable, sending wei |
|
|
|
|
* receive is not declared, fallback is payable, sending data and wei |
|
|
|
|
* both are not declared, sending data and wei, should fail |
|
|
|
|
*/ |
|
|
|
|
module.exports = { |
|
|
|
|
before: function (browser, done) { |
|
|
|
|
init(browser, done) |
|
|
|
@ -36,6 +27,18 @@ module.exports = { |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
'Use special functions receive/follback - both are declared - receive called, failing sending data < 1 byte': function (browser) { |
|
|
|
|
// don't need to redeploy it, same contract
|
|
|
|
|
browser.perform((done) => { |
|
|
|
|
browser.getAddressAtPosition(0, (address) => { |
|
|
|
|
browser.sendLowLevelTx(address, '0', '0xa') |
|
|
|
|
.pause(1000) |
|
|
|
|
.waitForElementVisible(`#instance${address} label[id="deployAndRunLLTxError"]`) |
|
|
|
|
.assert.containsText(`#instance${address} label[id="deployAndRunLLTxError"]`, `size of at least one byte`) |
|
|
|
|
.perform(done) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
'Use special functions receive/follback - both are declared - receive called, sending wei': function (browser) { |
|
|
|
|
// don't need to redeploy it, same contract
|
|
|
|
|
browser.perform((done) => { |
|
|
|
@ -61,7 +64,7 @@ module.exports = { |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
'Use special functions receive/follback - receive is declared, failing, fallback is not declared, sending data': function (browser) { |
|
|
|
|
'Use special functions receive/follback - only receive is declared, sending wei': function (browser) { |
|
|
|
|
browser.waitForElementVisible('#icon-panel', 10000) |
|
|
|
|
.testContracts('receiveOnly.sol', sources[1]['browser/receiveOnly.sol'], ['CheckSpecials']) |
|
|
|
|
.clickLaunchIcon('udapp') |
|
|
|
@ -69,16 +72,29 @@ module.exports = { |
|
|
|
|
.createContract('') |
|
|
|
|
.clickInstance(1) |
|
|
|
|
.perform((done) => { |
|
|
|
|
browser.getAddressAtPosition(1, (address) => { |
|
|
|
|
browser.sendLowLevelTx(address, '1', '') |
|
|
|
|
.pause(1000) |
|
|
|
|
.journalLastChildIncludes('to:CheckSpecials.(receive)') |
|
|
|
|
.journalLastChildIncludes('value:1 wei') |
|
|
|
|
.journalLastChildIncludes('data:0x') |
|
|
|
|
.perform(done) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
'Use special functions receive/follback - only receive is declared, failing, fallback is not declared, sending data': function (browser) { |
|
|
|
|
// don't need to redeploy it, same contract
|
|
|
|
|
browser.perform((done) => { |
|
|
|
|
browser.getAddressAtPosition(1, (address) => { |
|
|
|
|
browser.sendLowLevelTx(address, '0', '0xaa') |
|
|
|
|
.pause(1000) |
|
|
|
|
.waitForElementVisible(`#instance${address} label[id="deployAndRunLLTxError"]`) |
|
|
|
|
.assert.containsText(`#instance${address} label[id="deployAndRunLLTxError"]`, `'fallback' function is not defined`) |
|
|
|
|
.assert.containsText(`#instance${address} label[id="deployAndRunLLTxError"]`, `'Fallback' function is not defined`) |
|
|
|
|
.perform(done) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
'Use special functions receive/fallback - receive is not declared, fallback is payable, sending wei': function (browser) { |
|
|
|
|
'Use special functions receive/fallback - only fallback is payable, sending wei': function (browser) { |
|
|
|
|
browser.waitForElementVisible('#icon-panel', 10000) |
|
|
|
|
.testContracts('fallbackOnlyPayable.sol', sources[2]['browser/fallbackOnlyPayable.sol'], ['CheckSpecials']) |
|
|
|
|
.clickLaunchIcon('udapp') |
|
|
|
@ -96,7 +112,7 @@ module.exports = { |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
'Use special functions receive/follback - receive is not declared, fallback is payable, sending data and wei': function (browser) { |
|
|
|
|
'Use special functions receive/follback - only fallback is diclared and is payable, sending data and wei': function (browser) { |
|
|
|
|
// don't need to redeploy it, same contract
|
|
|
|
|
browser.perform((done) => { |
|
|
|
|
browser.getAddressAtPosition(2, (address) => { |
|
|
|
@ -109,7 +125,7 @@ module.exports = { |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
'Use special functions receive/fallback - receive is not declared, fallback should fail cause not payable, sending wei': function (browser) { |
|
|
|
|
'Use special functions receive/fallback - only fallback is declared, fallback should fail cause not payable, sending wei': function (browser) { |
|
|
|
|
browser.waitForElementVisible('#icon-panel', 10000) |
|
|
|
|
.testContracts('fallbackOnlyNotPayable.sol', sources[3]['browser/fallbackOnlyNotPayable.sol'], ['CheckSpecials']) |
|
|
|
|
.clickLaunchIcon('udapp') |
|
|
|
@ -136,7 +152,7 @@ module.exports = { |
|
|
|
|
.setValue('#value', 0) |
|
|
|
|
.createContract('') |
|
|
|
|
.clickInstance(4) |
|
|
|
|
.pause(10000) |
|
|
|
|
.pause(1000) |
|
|
|
|
.perform((done) => { |
|
|
|
|
browser.getAddressAtPosition(4, (address) => { |
|
|
|
|
browser.sendLowLevelTx(address, '1', '0xaa') |
|
|
|
@ -147,6 +163,27 @@ module.exports = { |
|
|
|
|
.perform(done) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
'Use special functions receive/fallback - receive and fallback are not declared, sending nothing': function (browser) { |
|
|
|
|
browser.waitForElementVisible('#icon-panel', 10000) |
|
|
|
|
.testContracts('notSpecial.sol', sources[5]['browser/notSpecial.sol'], ['CheckSpecials']) |
|
|
|
|
.clickLaunchIcon('udapp') |
|
|
|
|
.selectContract('CheckSpecials') |
|
|
|
|
.waitForElementVisible('#value') |
|
|
|
|
.clearValue('#value') |
|
|
|
|
.setValue('#value', 0) |
|
|
|
|
.createContract('') |
|
|
|
|
.clickInstance(5) |
|
|
|
|
.pause(1000) |
|
|
|
|
.perform((done) => { |
|
|
|
|
browser.getAddressAtPosition(5, (address) => { |
|
|
|
|
browser.sendLowLevelTx(address, '0', '') |
|
|
|
|
.pause(1000) |
|
|
|
|
.waitForElementVisible(`#instance${address} label[id="deployAndRunLLTxError"]`) |
|
|
|
|
.assert.containsText(`#instance${address} label[id="deployAndRunLLTxError"]`, `Both 'receive' and 'fallback' functions are not defined`) |
|
|
|
|
.perform(done) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
.end() |
|
|
|
|
}, |
|
|
|
|
tearDown: sauce |
|
|
|
@ -199,5 +236,14 @@ var sources = [ |
|
|
|
|
} |
|
|
|
|
` |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
'browser/notSpecial.sol': { |
|
|
|
|
content: ` |
|
|
|
|
contract CheckSpecials { |
|
|
|
|
function otherFallback() payable external {} |
|
|
|
|
} |
|
|
|
|
` |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|