From 08a807d6c52f8105658ab979defa8e3afc162db6 Mon Sep 17 00:00:00 2001 From: LianaHus Date: Fri, 24 Jan 2020 10:43:23 +0100 Subject: [PATCH] added a test --- test-browser/commands/sendLowLevelTx.js | 18 ++++++++ test-browser/tests/specialFunctions.js | 58 +++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 test-browser/commands/sendLowLevelTx.js create mode 100644 test-browser/tests/specialFunctions.js diff --git a/test-browser/commands/sendLowLevelTx.js b/test-browser/commands/sendLowLevelTx.js new file mode 100644 index 0000000000..0b95caf045 --- /dev/null +++ b/test-browser/commands/sendLowLevelTx.js @@ -0,0 +1,18 @@ +const EventEmitter = require('events') +class sendLowLevelTx extends EventEmitter { + command (address, value, callData, callback) { + this.api.perform((client, done) => { + this.api.execute(function (value) { + document.getElementById('deployAndRunLLTxSendTransaction').click + done() + if (callback) { + callback.call(this.api) + } + this.emit('complete') + }) + }) + return this + } +} + +module.exports = sendLowLevelTx diff --git a/test-browser/tests/specialFunctions.js b/test-browser/tests/specialFunctions.js new file mode 100644 index 0000000000..4e011388a5 --- /dev/null +++ b/test-browser/tests/specialFunctions.js @@ -0,0 +1,58 @@ +'use strict' +var init = require('../helpers/init') +var sauce = require('./sauce') + +module.exports = { + before: function (browser, done) { + init(browser, done) + }, + '@sources': function () { + return sources + }, + 'Use special functions receive/fullback': function (browser) { + browser.waitForElementVisible('#icon-panel', 10000) + .testContracts('receiveAndfFallback.sol', sources[0]['browser/Untitled.sol'], ['CheckSpecials']) + .clickLaunchIcon('udapp' + .selectContract('CheckSpecials') + .createContract('') + .clickInstance(0) + .perform((done) => { + browser.getAddressAtPosition(0, (address) => { + browser.sendLowLevelTx(address, '0', '0xaa') + .journalLastChild('dd') + .waitForElementVisible('label[id="deployAndRunLLTxError"]') + .assert.containsText('label[id="deployAndRunLLTxError"]', '') + .perform(done) + }) + }) + ) + }, + tearDown: sauce +} + +var sources = [ + { + 'browser/receiveAndfFallback.sol': { + content: ` + contract CheckSpecials { + receive() payable external{} + fallback() external {} + } + ` + }, + 'browser/receiveOnly.sol': { + content: ` + contract CheckSpecials { + receive() payable external{} + } + ` + }, + 'browser/fallbackOnly.sol': { + content: ` + contract CheckSpecials { + fallback() payable external{} + } + ` + } + } +]