merge with develop branch
This commit is contained in:
commit
ba833b5f54
|
@ -190,6 +190,15 @@ jobs:
|
|||
key: dependency-cache-{{ .Revision }}
|
||||
- restore_cache:
|
||||
key: build-cache-{{ .Revision }}
|
||||
- run: #STABLE
|
||||
name: Install Chromedriver latest version
|
||||
command: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install lsb-release libappindicator3-1
|
||||
curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
||||
sudo dpkg -i google-chrome.deb
|
||||
sudo sed -i 's|HERE/chrome"|HERE/chrome" --no-sandbox|g' /opt/google/chrome/google-chrome
|
||||
rm google-chrome.deb
|
||||
- run:
|
||||
name: test:e2e:chrome
|
||||
command: npm run test:e2e:chrome
|
||||
|
|
|
@ -11,18 +11,23 @@ import abiEncoder from 'web3-eth-abi'
|
|||
import Web3 from 'web3'
|
||||
import copyToClipboard from 'copy-to-clipboard'
|
||||
|
||||
class SendTransactionInput extends Component {
|
||||
class SendTransactionField extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
inputVal: props.defaultValue,
|
||||
val: props.defaultValue,
|
||||
}
|
||||
this.timerID = null
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
placeholder: PropTypes.string,
|
||||
defaultValue: PropTypes.string,
|
||||
defaultValue: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.number,
|
||||
PropTypes.bool,
|
||||
]),
|
||||
disabled: PropTypes.bool,
|
||||
value: PropTypes.string,
|
||||
onChange: PropTypes.func,
|
||||
}
|
||||
|
@ -31,19 +36,19 @@ class SendTransactionInput extends Component {
|
|||
return (
|
||||
<input
|
||||
type="text"
|
||||
className="input large-input"
|
||||
className="input large-input output"
|
||||
placeholder={this.props.placeholder}
|
||||
value={this.state.inputVal}
|
||||
value={this.state.val}
|
||||
disabled={this.props.disabled}
|
||||
onChange={e => {
|
||||
this.setState({
|
||||
inputVal: e.target.value,
|
||||
})
|
||||
this.props.onChange(e)
|
||||
}
|
||||
}
|
||||
this.setState({
|
||||
val: e.target.value,
|
||||
})
|
||||
this.props.onChange(e)
|
||||
}}
|
||||
style={{ marginTop: '5px' }}
|
||||
/>
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,18 +56,21 @@ class SendTransactionScreen extends PersistentForm {
|
|||
constructor (props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
web3: new Web3(global.ethereumProvider),
|
||||
options: [],
|
||||
abi: [],
|
||||
methodSelected: props.methodSelected,
|
||||
methodABI: props.methodABI,
|
||||
methodInputs: [],
|
||||
methodOutputs: [],
|
||||
methodInputsView: [],
|
||||
methodOutput: null,
|
||||
methodOutputsView: [],
|
||||
isConstantMethod: false,
|
||||
inputValues: props.inputValues || {},
|
||||
output: '',
|
||||
outputValues: props.outputValues || {},
|
||||
copyDisabled: true,
|
||||
}
|
||||
|
||||
PersistentForm.call(this)
|
||||
}
|
||||
|
||||
|
@ -101,15 +109,16 @@ class SendTransactionScreen extends PersistentForm {
|
|||
methodSelected: opt.value,
|
||||
isConstantMethod: opt.metadata.constant,
|
||||
methodABI: opt.metadata,
|
||||
output: '',
|
||||
outputValues: {},
|
||||
inputValues: {},
|
||||
}, () => {
|
||||
this.generateMethodFieldsView(opt.metadata)
|
||||
})
|
||||
this.generateMethodInputsView(opt.metadata)
|
||||
}}
|
||||
/>
|
||||
<div style={{ overflow: 'auto', maxHeight: this.state.isConstantMethod ? '120px' : '210px' }}>
|
||||
{this.state.methodInputsView}
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ padding: '0 30px', overflow: 'auto', 'maxHeight': '280px' }}>
|
||||
{this.state.methodInputsView}
|
||||
{this.state.isConstantMethod && this.methodOutput()}
|
||||
{this.buttonsSection()}
|
||||
</div>
|
||||
|
@ -119,14 +128,14 @@ class SendTransactionScreen extends PersistentForm {
|
|||
|
||||
componentDidMount () {
|
||||
if (this.props.methodSelected) {
|
||||
this.generateMethodInputsView(this.props.methodABI)
|
||||
this.generateMethodFieldsView(this.props.methodABI)
|
||||
}
|
||||
}
|
||||
|
||||
async getContractMethods () {
|
||||
const contractProps = await this.props.getContract(this.props.address)
|
||||
const abi = contractProps && contractProps.abi
|
||||
const options = abi && abi.reduce((filtered, obj) => {
|
||||
const options = abi && Array.isArray(abi) && abi.reduce((filtered, obj) => {
|
||||
if (obj.type === 'function') {
|
||||
filtered.push({ label: obj.name, value: obj.name, metadata: obj })
|
||||
}
|
||||
|
@ -139,13 +148,30 @@ class SendTransactionScreen extends PersistentForm {
|
|||
})
|
||||
}
|
||||
|
||||
generateMethodInput (params, ind) {
|
||||
generateMethodField (params, ind, isInput) {
|
||||
const { inputValues, outputValues, web3 } = this.state
|
||||
const paramName = isInput ? 'Input' : 'Output'
|
||||
const defaultInputValue = (inputValues && inputValues[ind]) || ''
|
||||
const defaultOutputValue = params.type === 'bool' ? outputValues && outputValues[ind] : (outputValues && outputValues[ind]) || ''
|
||||
let defaultValue = isInput ? defaultInputValue : defaultOutputValue
|
||||
if (Array.isArray(defaultValue)) {
|
||||
defaultValue = defaultValue.join(', ')
|
||||
} else if ((params.type.startsWith('uint') || params.type.startsWith('int')) && !isNaN(Number(defaultValue)) && Number(defaultValue) > 0) {
|
||||
defaultValue = web3.toBigNumber(defaultValue).toFixed()
|
||||
} else if (defaultValue) {
|
||||
defaultValue = defaultValue.toString()
|
||||
}
|
||||
const label = (
|
||||
<h3
|
||||
key={`method_label_${ind}`}
|
||||
style={{ marginTop: '10px' }}
|
||||
>
|
||||
{params.name || `Input ${ind + 1}`}
|
||||
{params.name || `${paramName} ${ind + 1}`}
|
||||
{!isInput ? <i
|
||||
className="clipboard cursor-pointer"
|
||||
style={{ marginLeft: '10px' }}
|
||||
onClick={(e) => { copyToClipboard(defaultValue) }}
|
||||
/> : null}
|
||||
</h3>
|
||||
)
|
||||
// bytes field is not mandatory to fill: 0x is by default
|
||||
|
@ -158,28 +184,33 @@ class SendTransactionScreen extends PersistentForm {
|
|||
})
|
||||
}
|
||||
}
|
||||
const input = (
|
||||
<SendTransactionInput
|
||||
const field = (
|
||||
<SendTransactionField
|
||||
key={Math.random()}
|
||||
ind={ind}
|
||||
disabled={!isInput}
|
||||
placeholder={params.type}
|
||||
defaultValue={(this.props.inputValues && this.props.inputValues[ind]) || ''}
|
||||
onChange={e => this.handleInputChange(e, ind)}
|
||||
defaultValue={defaultValue}
|
||||
onChange={e => isInput ? this.handleInputChange(e.target.value, params.type, ind) : null}
|
||||
/>
|
||||
)
|
||||
const inputObj = (
|
||||
const fieldObj = (
|
||||
<div key={`method_label_container_${ind}`}>
|
||||
{label}
|
||||
{input}
|
||||
{field}
|
||||
</div>
|
||||
)
|
||||
return inputObj
|
||||
return fieldObj
|
||||
}
|
||||
|
||||
handleInputChange (e, ind) {
|
||||
handleInputChange (val, type, ind) {
|
||||
const { inputValues } = this.state
|
||||
if (e.target.value) {
|
||||
inputValues[ind] = e.target.value
|
||||
if (val) {
|
||||
if (type === 'bool') {
|
||||
inputValues[ind] = (val === 'true')
|
||||
} else {
|
||||
inputValues[ind] = val
|
||||
}
|
||||
} else {
|
||||
delete inputValues[ind]
|
||||
}
|
||||
|
@ -188,53 +219,51 @@ class SendTransactionScreen extends PersistentForm {
|
|||
})
|
||||
}
|
||||
|
||||
generateMethodInputsView (metadata) {
|
||||
generateMethodFieldsView (metadata) {
|
||||
this.setState({
|
||||
methodInputs: [],
|
||||
methodInputsView: [],
|
||||
methodOutputs: [],
|
||||
methodOutputsView: [],
|
||||
})
|
||||
const methodInputsView = []
|
||||
const methodInputs = metadata && metadata.inputs
|
||||
const methodOutputsView = []
|
||||
const methodOutputs = metadata && metadata.outputs
|
||||
methodInputs.forEach((input, ind) => {
|
||||
methodInputsView.push(this.generateMethodInput(input, ind))
|
||||
methodInputsView.push(this.generateMethodField(input, ind, true))
|
||||
})
|
||||
methodOutputs.forEach((output, ind) => {
|
||||
methodOutputsView.push(this.generateMethodField(output, ind, false))
|
||||
})
|
||||
this.setState({
|
||||
methodInputs,
|
||||
methodInputsView,
|
||||
methodOutputs,
|
||||
methodOutputsView,
|
||||
})
|
||||
}
|
||||
|
||||
updateOutputsView () {
|
||||
const methodOutputsView = []
|
||||
this.state.methodOutputs.forEach((output, ind) => {
|
||||
methodOutputsView.push(this.generateMethodField(output, ind, false))
|
||||
})
|
||||
this.setState({
|
||||
methodOutputsView,
|
||||
})
|
||||
}
|
||||
|
||||
methodOutput () {
|
||||
const label = (
|
||||
<h2
|
||||
key="method_output_label"
|
||||
style={{
|
||||
marginTop: '10px',
|
||||
}}
|
||||
>
|
||||
Output
|
||||
</h2>
|
||||
)
|
||||
const output = (
|
||||
<textarea
|
||||
key="method_output_value"
|
||||
className="input large-input"
|
||||
disabled={true}
|
||||
value={this.state.output}
|
||||
style={{
|
||||
marginTop: '5px',
|
||||
width: '100%',
|
||||
height: '50px',
|
||||
}}
|
||||
/>
|
||||
)
|
||||
const outputObj = (
|
||||
return (
|
||||
<div>
|
||||
{label}
|
||||
{output}
|
||||
<h3
|
||||
className="flex-center"
|
||||
style={{ marginTop: '10px' }}
|
||||
>Output data</h3>
|
||||
{this.state.methodOutputsView}
|
||||
</div>
|
||||
)
|
||||
return outputObj
|
||||
}
|
||||
|
||||
buttonsSection () {
|
||||
|
@ -275,9 +304,8 @@ class SendTransactionScreen extends PersistentForm {
|
|||
|
||||
callData = () => {
|
||||
this.props.showLoadingIndication()
|
||||
const { abi, methodSelected, inputValues } = this.state
|
||||
const { abi, methodSelected, inputValues, methodOutputs, methodOutputsView, web3 } = this.state
|
||||
const { address } = this.props
|
||||
const web3 = new Web3(global.ethereumProvider)
|
||||
|
||||
const inputValuesArray = Object.keys(inputValues).map(key => inputValues[key])
|
||||
try {
|
||||
|
@ -287,11 +315,20 @@ class SendTransactionScreen extends PersistentForm {
|
|||
this.props.hideToast()
|
||||
return this.props.displayWarning(err)
|
||||
}
|
||||
if (output) {
|
||||
this.setState({
|
||||
output,
|
||||
const outputValues = {}
|
||||
if (methodOutputsView.length > 1) {
|
||||
output.forEach((val, ind) => {
|
||||
const type = methodOutputs && methodOutputs[ind] && methodOutputs[ind].type
|
||||
outputValues[ind] = this.setOutputValue(val, type)
|
||||
})
|
||||
} else {
|
||||
const type = methodOutputs && methodOutputs[0] && methodOutputs[0].type
|
||||
outputValues[0] = this.setOutputValue(output, type)
|
||||
}
|
||||
this.setState({
|
||||
outputValues,
|
||||
})
|
||||
this.updateOutputsView()
|
||||
})
|
||||
} catch (e) {
|
||||
this.props.hideToast()
|
||||
|
@ -299,6 +336,23 @@ class SendTransactionScreen extends PersistentForm {
|
|||
}
|
||||
}
|
||||
|
||||
setOutputValue = (val, type) => {
|
||||
console.log(val)
|
||||
if (!type) {
|
||||
return val || ''
|
||||
}
|
||||
if (!val) {
|
||||
if (type === 'bool') {
|
||||
return val
|
||||
}
|
||||
return ''
|
||||
}
|
||||
if ((type.startsWith('uint') || type.startsWith('int')) && !type.endsWith('[]')) {
|
||||
return val.toFixed().toString()
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
encodeFunctionCall = () => {
|
||||
const { inputValues, methodABI } = this.state
|
||||
const inputValuesArray = Object.keys(inputValues).map(key => inputValues[key])
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -60,15 +60,16 @@ module.exports = {
|
|||
|
||||
},
|
||||
executeMethod: {
|
||||
|
||||
title: By.className('flex-center send-header'),
|
||||
titleText: 'Execute Method',
|
||||
selectArrow: By.className('Select-arrow-zone'),
|
||||
item0: By.css('.Select-input > input:nth-child(1)'),
|
||||
item1: By.className('Select-option'),
|
||||
items: By.className('Select-option'),
|
||||
item11: By.css('#react-select-2--option-11'),
|
||||
buttonCall: By.css('.section > button:nth-child(1)'),
|
||||
fieldOutput: By.css('.input'),
|
||||
fieldParametr1: By.css('.input'),
|
||||
fieldOutput: By.className('input large-input output'),
|
||||
fieldParameter: By.className('input large-input output'),
|
||||
buttonNext: By.css('.section > div:nth-child(1) > button:nth-child(2)'),
|
||||
buttonArrow: By.className('fa fa-arrow-left fa-lg cursor-pointer'),
|
||||
buttonCopyABI: By.className('btn-violet'),
|
||||
|
@ -375,3 +376,4 @@ module.exports = {
|
|||
},
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ function buildFirefoxWebdriver () {
|
|||
|
||||
async function getExtensionIdChrome (driver) {
|
||||
await driver.get('chrome://extensions')
|
||||
const extensionId = await driver.executeScript('return document.querySelector("extensions-manager").shadowRoot.querySelector("extensions-view-manager extensions-item-list").shadowRoot.querySelector("extensions-item:nth-child(2)").getAttribute("id")')
|
||||
const extensionId = await driver.executeScript('return document.querySelector("extensions-manager").shadowRoot.querySelector("cr-view-manager extensions-item-list").shadowRoot.querySelector("extensions-item:nth-child(2)").getAttribute("id")')
|
||||
return extensionId
|
||||
}
|
||||
|
||||
|
|
|
@ -245,7 +245,9 @@ describe('Metamask popup page', async function () {
|
|||
})
|
||||
|
||||
describe('Import Contract account', async () => {
|
||||
const poaContract = '0xc6468767214c577013a904900ada0a0dd6653bc3'
|
||||
// const poaContract = '0xc6468767214c577013a904900ada0a0dd6653bc3'
|
||||
const contractSokol = '0x215b2ab35749e5a9f3efe890de602fb9844e842f'
|
||||
console.log('Contract ' + contractSokol + ' , Sokol')
|
||||
const wrongAddress = '0xB87b6077D59B01Ab9fa8cd5A1A21D02a4d60D35'
|
||||
const notContractAddress = '0x56B2e3C3cFf7f3921Dc2e0F8B8e20d1eEc29216b'
|
||||
describe('Import Contract', async () => {
|
||||
|
@ -303,8 +305,8 @@ describe('Metamask popup page', async function () {
|
|||
const field = await waitUntilShowUp(screens.importAccounts.contractABI)
|
||||
assert.equal(await field.getText(), '', "field 'ABI' isn't displayed")
|
||||
})
|
||||
it("Fill 'Address' with not contract address , POA core", async function () {
|
||||
await setProvider(NETWORKS.POA)
|
||||
it("Fill 'Address' with not contract address , SOKOL", async function () {
|
||||
await setProvider(NETWORKS.SOKOL)
|
||||
const field = await waitUntilShowUp(screens.importAccounts.contractAddress)
|
||||
await clearField(field, 100)
|
||||
await field.sendKeys(notContractAddress)
|
||||
|
@ -315,10 +317,10 @@ describe('Metamask popup page', async function () {
|
|||
assert.equal(await button.isEnabled(), false, 'button enabled')
|
||||
})
|
||||
|
||||
it("Fill 'Address' with valid contract , POA core", async function () {
|
||||
it("Fill 'Address' with valid contract , SOKOL", async function () {
|
||||
const field = await waitUntilShowUp(screens.importAccounts.contractAddress)
|
||||
await clearField(field, 100)
|
||||
await field.sendKeys(poaContract)
|
||||
await field.sendKeys(contractSokol)
|
||||
})
|
||||
|
||||
it("Button 'Import' is enabled if contract address is correct", async function () {
|
||||
|
@ -330,158 +332,399 @@ describe('Metamask popup page', async function () {
|
|||
it('ABI is fetched ', async function () {
|
||||
const field = await waitUntilShowUp(screens.importAccounts.contractABI)
|
||||
const abi = await field.getText()
|
||||
assert.equal(abi.length, 2800, "ABI isn't fetched")
|
||||
assert.equal(abi.length, 4457, "ABI isn't fetched")
|
||||
})
|
||||
|
||||
it("Click button 'Import', main screen opens", async function () {
|
||||
const button = await waitUntilShowUp(screens.importAccounts.buttonImport)
|
||||
await click(button)
|
||||
const identicon = await waitUntilShowUp(screens.main.identicon, 20)
|
||||
assert.notEqual(identicon, false, "main screen isn't opened")
|
||||
const ident = await waitUntilShowUp(screens.main.identicon, 20)
|
||||
assert.notEqual(ident, false, "main screen isn't opened")
|
||||
})
|
||||
|
||||
it("Click button 'Send', 'Execute Method' screen opens", async function () {
|
||||
const button = await waitUntilShowUp(screens.main.buttons.send)
|
||||
await click(button)
|
||||
const identicon = await waitUntilShowUp(screens.main.identicon, 40)
|
||||
assert.notEqual(identicon, false, "main screen isn't opened")
|
||||
})
|
||||
})
|
||||
describe('Execute Method', () => {
|
||||
const outputData = '0xd70befce3cf1cc88119c8f4eb583ccd4c39d06e2'
|
||||
describe('Execute Method screen', () => {
|
||||
const notContractAddress = '0x56B2e3C3cFf7f3921Dc2e0F8B8e20d1eEc29216b'
|
||||
it("Click button 'Send', 'Execute Method' screen opens", async function () {
|
||||
await driver.navigate().refresh()
|
||||
await delay(2000)
|
||||
const button = await waitUntilShowUp(screens.main.buttons.send)
|
||||
await click(button)
|
||||
})
|
||||
describe("Check UI and button's functionality", () => {
|
||||
it("Click button 'Send', 'Execute Method' screen opens", async function () {
|
||||
await driver.navigate().refresh()
|
||||
await delay(2000)
|
||||
const button = await waitUntilShowUp(screens.main.buttons.send)
|
||||
await click(button)
|
||||
})
|
||||
|
||||
it('title is displayed and correct', async function () {
|
||||
const title = await waitUntilShowUp(screens.executeMethod.title)
|
||||
assert.notEqual(title, false, 'title isn\'t displayed')
|
||||
assert.equal(await title.getText(), screens.executeMethod.titleText, 'incorrect text')
|
||||
})
|
||||
it('title is displayed and correct', async function () {
|
||||
const title = await waitUntilShowUp(screens.executeMethod.title)
|
||||
assert.notEqual(title, false, 'title isn\'t displayed')
|
||||
assert.equal(await title.getText(), screens.executeMethod.titleText, 'incorrect text')
|
||||
})
|
||||
|
||||
it("Select method 'abstractStorageAddr'", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
|
||||
await field.click()
|
||||
const item = await waitUntilShowUp(screens.executeMethod.item0)
|
||||
assert.notEqual(item, false, 'no drop down menu')
|
||||
await click(item)
|
||||
})
|
||||
it('Click arrow button leads to main screen', async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonArrow)
|
||||
await click(button)
|
||||
const identicon = await waitUntilShowUp(screens.main.identicon, 40)
|
||||
assert.notEqual(identicon, false, "main screen isn't opened")
|
||||
})
|
||||
|
||||
it("Button 'Call data' is displayed", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
|
||||
assert.notEqual(button, false, "button 'Call data' isn't displayed")
|
||||
await button.click()
|
||||
})
|
||||
|
||||
it('method returns correct value', async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||
assert.notEqual(field, false, "field 'Output' isn't displayed")
|
||||
const text = await waitUntilHasText(field)
|
||||
assert.equal(text, outputData, 'incorrect value was returned')
|
||||
})
|
||||
|
||||
it("2nd call doesn't throw the error", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
|
||||
assert.notEqual(button, false, "button 'Call data' isn't displayed")
|
||||
await button.click()
|
||||
const field = await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||
assert.notEqual(field, false, "field 'Output' isn't displayed")
|
||||
const text = await waitUntilHasText(field)
|
||||
assert.equal(text, outputData, 'incorrect value was returned')
|
||||
})
|
||||
it('Click arrow button leads to main screen', async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonArrow)
|
||||
await click(button)
|
||||
const identicon = await waitUntilShowUp(screens.main.identicon, 40)
|
||||
assert.notEqual(identicon, false, "main screen isn't opened")
|
||||
})
|
||||
it("Click button 'Send', 'Execute Method' screen opens", async function () {
|
||||
await driver.navigate().refresh()
|
||||
await delay(2000)
|
||||
const button = await waitUntilShowUp(screens.main.buttons.send)
|
||||
await click(button)
|
||||
})
|
||||
it("Select method 'changeAbstractStorage'", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
|
||||
await field.click()
|
||||
const items = await waitUntilShowUp(screens.executeMethod.item1)
|
||||
assert.notEqual(items, false, 'no drop down menu')
|
||||
const item = (await driver.findElements(screens.executeMethod.item1))[1]
|
||||
// await click(item)
|
||||
await item.click()
|
||||
})
|
||||
|
||||
it("Button 'Copy ABI encoded' is displayed", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCopyABI)
|
||||
assert.notEqual(button, false, "button 'Copy ABI encoded' isn't displayed")
|
||||
it("Click button 'Send', 'Execute Method' screen opens", async function () {
|
||||
await driver.navigate().refresh()
|
||||
await delay(2000)
|
||||
const button = await waitUntilShowUp(screens.main.buttons.send)
|
||||
await click(button)
|
||||
})
|
||||
|
||||
})
|
||||
describe('Check output for data type : ADDRESS', () => {
|
||||
const address = '0x56B2e3C3cFf7f3921Dc2e0F8B8e20d1eEc29216b'
|
||||
|
||||
it("Button 'Copy ABI encoded' is disabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCopyABI)
|
||||
assert.equal(await button.isEnabled(), false, "button 'Copy ABI encoded' enabled")
|
||||
it("Select method 'returnAddress'", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
|
||||
await field.click()
|
||||
await waitUntilShowUp(screens.executeMethod.items)
|
||||
const list = await driver.findElements(screens.executeMethod.items)
|
||||
await list[3].click()
|
||||
assert.equal(list.length, 22, "drop down menu isn't displayed")
|
||||
})
|
||||
|
||||
it("Button 'Call data' is displayed and disabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
|
||||
assert.notEqual(button, false, "button 'Call data' isn't displayed")
|
||||
assert.equal(await button.isEnabled(), false, "Button 'Call data' is enabled")
|
||||
})
|
||||
|
||||
it("Fill out input field 'Address'", async function () {
|
||||
await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
|
||||
assert.notEqual(fields[0], false, "field parameter#1 isn't displayed")
|
||||
await fields[0].sendKeys(address)
|
||||
})
|
||||
|
||||
it("Button 'Call data' is displayed and enabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
|
||||
assert.notEqual(button, false, "button 'Call data' isn't displayed")
|
||||
assert.equal(await button.isEnabled(), true, "Button 'Call data' is disabled")
|
||||
await button.click()
|
||||
})
|
||||
|
||||
it('method returns correct value', async function () {
|
||||
await delay(3000)
|
||||
await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
|
||||
assert.notEqual(fields[1], false, "field 'Output' isn't displayed")
|
||||
const text = await waitUntilHasValue(fields[1])
|
||||
assert.equal(text.toLowerCase(), address.toLowerCase(), 'incorrect value was returned')
|
||||
})
|
||||
|
||||
it("2nd call doesn't throw the error", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
|
||||
assert.notEqual(button, false, "button 'Call data' isn't displayed")
|
||||
await button.click()
|
||||
const field = await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||
assert.notEqual(field, false, "field 'Output' isn't displayed")
|
||||
const text = await waitUntilHasValue(field)
|
||||
assert.equal(text.toLowerCase(), address.toLowerCase(), 'incorrect value was returned')
|
||||
})
|
||||
})
|
||||
|
||||
it("Button 'Next' is disabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonNext)
|
||||
assert.equal(await button.isEnabled(), false, "button 'Next' enabled")
|
||||
})
|
||||
describe('Check output for data type : STRING', () => {
|
||||
const stringValue = 'POA network'
|
||||
|
||||
it("Fill out parameter '_newAbstractStorageAddr with wrong data'", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.fieldParametr1)
|
||||
assert.notEqual(field, false, "field address isn't displayed")
|
||||
await field.sendKeys(wrongAddress)
|
||||
})
|
||||
it("Select method 'returnString'", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
|
||||
await field.click()
|
||||
await waitUntilShowUp(screens.executeMethod.items)
|
||||
const list = await driver.findElements(screens.executeMethod.items)
|
||||
await list[14].click()
|
||||
assert.equal(list.length, 22, "drop down menu isn't displayed")
|
||||
})
|
||||
|
||||
it.skip("Button 'Copy ABI encoded' is disabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCopyABI)
|
||||
assert.equal(await button.isEnabled(), false, "button 'Copy ABI encoded' enabled")
|
||||
})
|
||||
it('Fill out input parameter field ', async function () {
|
||||
await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
|
||||
assert.notEqual(fields[0], false, "field parameter#1 isn't displayed")
|
||||
await fields[0].sendKeys(stringValue)
|
||||
})
|
||||
|
||||
it.skip("Button 'Next' is disabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonNext)
|
||||
assert.equal(await button.isEnabled(), false, "button 'Next' enabled")
|
||||
})
|
||||
it("Click button 'Call data' ", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
|
||||
assert.notEqual(button, false, "button 'Call data' isn't displayed")
|
||||
assert.equal(await button.isEnabled(), true, "Button 'Call data' is disabled")
|
||||
await button.click()
|
||||
})
|
||||
|
||||
it('Error message if wrong parameter', async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCopyABI)
|
||||
await button.click()
|
||||
const error = await waitUntilShowUp(elements.error)
|
||||
assert.notEqual(error, false, 'no error message')
|
||||
it('method returns correct value', async function () {
|
||||
await delay(3000)
|
||||
await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
|
||||
assert.notEqual(fields[1], false, "field 'Output' isn't displayed")
|
||||
const text = await waitUntilHasValue(fields[1])
|
||||
assert.equal(text, stringValue, 'incorrect value was returned')
|
||||
})
|
||||
})
|
||||
describe('Check output for data type : BOOLEAN', () => {
|
||||
it("Select method 'returnBoolean'", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
|
||||
await field.click()
|
||||
await waitUntilShowUp(screens.executeMethod.items)
|
||||
const list = await driver.findElements(screens.executeMethod.items)
|
||||
await list[5].click()
|
||||
assert.equal(list.length, 22, "drop down menu isn't displayed")
|
||||
})
|
||||
|
||||
it('Close error message', async function () {
|
||||
const button = await waitUntilShowUp(elements.errorClose)
|
||||
await button.click()
|
||||
const title = await waitUntilShowUp(screens.executeMethod.title)
|
||||
assert.notEqual(title, false, "error message isn't closed")
|
||||
})
|
||||
it('Fill out input parameter field, value is TRUE', async function () {
|
||||
await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
|
||||
assert.notEqual(fields[0], false, "field parameter#1 isn't displayed")
|
||||
await fields[0].sendKeys('true')
|
||||
})
|
||||
|
||||
it("Fill out parameter '_newAbstractStorageAddr'", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.fieldParametr1)
|
||||
await clearField(field, 100)
|
||||
await field.sendKeys(notContractAddress)
|
||||
assert.notEqual(field, false, "field address isn't displayed")
|
||||
})
|
||||
it("Click button 'Call data' ", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
|
||||
assert.notEqual(button, false, "button 'Call data' isn't displayed")
|
||||
assert.equal(await button.isEnabled(), true, "Button 'Call data' is disabled")
|
||||
await button.click()
|
||||
})
|
||||
|
||||
it("Button 'Next' is enabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonNext)
|
||||
assert.equal(await button.isEnabled(), true, "button 'Next' disabled")
|
||||
})
|
||||
it("Button 'Copy ABI encoded' is enabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCopyABI)
|
||||
assert.equal(await button.isEnabled(), true, "button 'Copy ABI encoded' disabled")
|
||||
await button.click()
|
||||
})
|
||||
it('method returns correct value: TRUE', async function () {
|
||||
await delay(3000)
|
||||
await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
|
||||
assert.notEqual(fields[1], false, "field 'Output' isn't displayed")
|
||||
const text = await waitUntilHasValue(fields[1])
|
||||
assert.equal(text, 'true', 'incorrect value was returned')
|
||||
})
|
||||
it('Fill out input parameter field, value is FALSE ', async function () {
|
||||
await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
|
||||
assert.notEqual(fields[0], false, "field parameter#1 isn't displayed")
|
||||
await clearField(fields[0])
|
||||
await fields[0].sendKeys('false')
|
||||
})
|
||||
|
||||
it("Click button 'Next'", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonNext)
|
||||
assert.notEqual(button, false, "button 'Next' isn't displayed")
|
||||
await button.click()
|
||||
it("Click button 'Call data' ", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
|
||||
assert.notEqual(button, false, "button 'Call data' isn't displayed")
|
||||
assert.equal(await button.isEnabled(), true, "Button 'Call data' is disabled")
|
||||
await button.click()
|
||||
})
|
||||
|
||||
it('method returns correct value, FALSE', async function () {
|
||||
await delay(3000)
|
||||
await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
|
||||
assert.notEqual(fields[1], false, "field 'Output' isn't displayed")
|
||||
const text = await waitUntilHasValue(fields[1])
|
||||
assert.equal(text, 'false', 'incorrect value was returned')
|
||||
})
|
||||
|
||||
})
|
||||
describe('Check output for data type : BYTES', () => {
|
||||
const bytesValue = '0x010203'
|
||||
it("Select method 'returnBytes1'", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
|
||||
await field.click()
|
||||
await waitUntilShowUp(screens.executeMethod.items)
|
||||
const list = await driver.findElements(screens.executeMethod.items)
|
||||
await list[7].click()
|
||||
assert.equal(list.length, 22, "drop down menu isn't displayed")
|
||||
})
|
||||
|
||||
it('Fill out input parameter field ', async function () {
|
||||
await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
|
||||
assert.notEqual(fields[0], false, "field parameter#1 isn't displayed")
|
||||
await fields[0].sendKeys(bytesValue)
|
||||
})
|
||||
|
||||
it("Click button 'Call data' ", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
|
||||
assert.notEqual(button, false, "button 'Call data' isn't displayed")
|
||||
assert.equal(await button.isEnabled(), true, "Button 'Call data' is disabled")
|
||||
await button.click()
|
||||
})
|
||||
|
||||
it('method returns correct value', async function () {
|
||||
await delay(3000)
|
||||
await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
|
||||
assert.notEqual(fields[1], false, "field 'Output' isn't displayed")
|
||||
const text = await waitUntilHasValue(fields[1])
|
||||
assert.equal(text, bytesValue, 'incorrect value was returned')
|
||||
})
|
||||
})
|
||||
describe('Check output for data type : UINT256', () => {
|
||||
const uint256Value = '1122334455667788991122334455667788'
|
||||
it("Select method 'returnUint256'", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
|
||||
await field.click()
|
||||
await waitUntilShowUp(screens.executeMethod.items)
|
||||
const list = await driver.findElements(screens.executeMethod.items)
|
||||
await list[17].click()
|
||||
assert.equal(list.length, 22, "drop down menu isn't displayed")
|
||||
})
|
||||
|
||||
it('Fill out input parameter field ', async function () {
|
||||
await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
|
||||
assert.notEqual(fields[0], false, "field parameter#1 isn't displayed")
|
||||
await fields[0].sendKeys(uint256Value)
|
||||
})
|
||||
|
||||
it("Click button 'Call data' ", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
|
||||
assert.notEqual(button, false, "button 'Call data' isn't displayed")
|
||||
assert.equal(await button.isEnabled(), true, "Button 'Call data' is disabled")
|
||||
await button.click()
|
||||
})
|
||||
|
||||
it('method returns correct value', async function () {
|
||||
await delay(3000)
|
||||
await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
|
||||
assert.notEqual(fields[1], false, "field 'Output' isn't displayed")
|
||||
const text = await waitUntilHasValue(fields[1])
|
||||
assert.equal(text, uint256Value, 'incorrect value was returned')
|
||||
})
|
||||
|
||||
})
|
||||
describe('Check output for data type : INT256', () => {
|
||||
const int256Value = '-1122334455667788991122334455667788'
|
||||
it("Select method 'returnInt256'", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
|
||||
await field.click()
|
||||
await waitUntilShowUp(screens.executeMethod.items)
|
||||
const list = await driver.findElements(screens.executeMethod.items)
|
||||
await list[10].click()
|
||||
assert.equal(list.length, 22, "drop down menu isn't displayed")
|
||||
})
|
||||
|
||||
it('Fill out input parameter field ', async function () {
|
||||
await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
|
||||
assert.notEqual(fields[0], false, "field parameter#1 isn't displayed")
|
||||
await fields[0].sendKeys(int256Value)
|
||||
})
|
||||
|
||||
it("Click button 'Call data' ", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCall)
|
||||
assert.notEqual(button, false, "button 'Call data' isn't displayed")
|
||||
assert.equal(await button.isEnabled(), true, "Button 'Call data' is disabled")
|
||||
await button.click()
|
||||
})
|
||||
|
||||
it('method returns correct value', async function () {
|
||||
await delay(3000)
|
||||
await waitUntilShowUp(screens.executeMethod.fieldOutput)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldOutput)
|
||||
assert.notEqual(fields[1], false, "field 'Output' isn't displayed")
|
||||
const text = await waitUntilHasValue(fields[1])
|
||||
assert.equal(text, int256Value, 'incorrect value was returned')
|
||||
})
|
||||
})
|
||||
describe('Check executed method', () => {
|
||||
|
||||
it("Select method 'transfer'", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.selectArrow)
|
||||
await field.click()
|
||||
await waitUntilShowUp(screens.executeMethod.items)
|
||||
const list = await driver.findElements(screens.executeMethod.items)
|
||||
await list[21].click()
|
||||
assert.equal(list.length, 22, "drop down menu isn't displayed")
|
||||
})
|
||||
|
||||
it("Button 'Copy ABI encoded' is displayed", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCopyABI)
|
||||
assert.notEqual(button, false, "button 'Copy ABI encoded' isn't displayed")
|
||||
})
|
||||
|
||||
it("Button 'Copy ABI encoded' is disabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCopyABI)
|
||||
assert.equal(await button.isEnabled(), false, "button 'Copy ABI encoded' enabled")
|
||||
})
|
||||
|
||||
it("Button 'Next' is disabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonNext)
|
||||
assert.equal(await button.isEnabled(), false, "button 'Next' enabled")
|
||||
})
|
||||
|
||||
it("Fill out parameter '_value' with valid data", async function () {
|
||||
await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
|
||||
assert.notEqual(fields[1], false, "field address isn't displayed")
|
||||
await fields[1].sendKeys('1')
|
||||
})
|
||||
|
||||
it("Button 'Copy ABI encoded' is disabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCopyABI)
|
||||
assert.equal(await button.isEnabled(), false, "button 'Copy ABI encoded' enabled")
|
||||
})
|
||||
|
||||
it("Button 'Next' is disabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonNext)
|
||||
assert.equal(await button.isEnabled(), false, "button 'Next' enabled")
|
||||
})
|
||||
it("Fill out parameter '_to' with wrong data", async function () {
|
||||
await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
||||
const fields = await driver.findElements(screens.executeMethod.fieldParameter)
|
||||
assert.notEqual(fields[0], false, "field address isn't displayed")
|
||||
await fields[0].sendKeys(wrongAddress)
|
||||
})
|
||||
|
||||
it("Error message if click 'Copy ABI encoded' with wrong address", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCopyABI)
|
||||
await button.click()
|
||||
const error = await waitUntilShowUp(elements.error)
|
||||
assert.notEqual(error, false, 'no error message')
|
||||
})
|
||||
|
||||
it('Close error message', async function () {
|
||||
const button = await waitUntilShowUp(elements.errorClose)
|
||||
await button.click()
|
||||
const title = await waitUntilShowUp(screens.executeMethod.title)
|
||||
assert.notEqual(title, false, "error message isn't closed")
|
||||
})
|
||||
|
||||
it.skip("Error message if click 'Next' with wrong address", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonNext)
|
||||
await button.click()
|
||||
const error = await waitUntilShowUp(elements.error)
|
||||
assert.notEqual(error, false, 'no error message')
|
||||
})
|
||||
|
||||
it.skip('Close error message', async function () {
|
||||
const button = await waitUntilShowUp(elements.errorClose)
|
||||
await button.click()
|
||||
const title = await waitUntilShowUp(screens.executeMethod.title)
|
||||
assert.notEqual(title, false, "error message isn't closed")
|
||||
})
|
||||
|
||||
it("Fill out parameter '_to' with valid data", async function () {
|
||||
const field = await waitUntilShowUp(screens.executeMethod.fieldParameter)
|
||||
await clearField(field, 100)
|
||||
await field.sendKeys(notContractAddress)
|
||||
assert.notEqual(field, false, "field address isn't displayed")
|
||||
})
|
||||
|
||||
it("Button 'Next' is enabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonNext)
|
||||
assert.equal(await button.isEnabled(), true, "button 'Next' disabled")
|
||||
})
|
||||
|
||||
it("Button 'Copy ABI encoded' is enabled", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonCopyABI)
|
||||
assert.equal(await button.isEnabled(), true, "button 'Copy ABI encoded' disabled")
|
||||
await button.click()
|
||||
})
|
||||
|
||||
it("Click button 'Next'", async function () {
|
||||
const button = await waitUntilShowUp(screens.executeMethod.buttonNext)
|
||||
assert.notEqual(button, false, "button 'Next' isn't displayed")
|
||||
await button.click()
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
@ -2090,17 +2333,18 @@ describe('Metamask popup page', async function () {
|
|||
return false
|
||||
}
|
||||
|
||||
async function waitUntilHasText (element, Twait) {
|
||||
async function waitUntilHasValue (element, Twait) {
|
||||
if (Twait === undefined) Twait = 200
|
||||
let text
|
||||
do {
|
||||
await delay(100)
|
||||
text = await element.getText()
|
||||
text = await element.getAttribute('value')
|
||||
if (text !== '') return text
|
||||
} while (Twait-- > 0)
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
async function isElementDisplayed (by) {
|
||||
try {
|
||||
return await driver.findElement(by).isDisplayed()
|
||||
|
@ -2133,16 +2377,20 @@ describe('Metamask popup page', async function () {
|
|||
async function isDisabledAddInexistentToken (tokenAddress) {
|
||||
await delay(500)
|
||||
try {
|
||||
const tab = await waitUntilShowUp(screens.main.tokens.menu)
|
||||
await click(tab)
|
||||
const button = await waitUntilShowUp(screens.main.tokens.buttonAdd, 300)
|
||||
await click(button)
|
||||
let count = 20
|
||||
do {
|
||||
await delay(500)
|
||||
const tab = await waitUntilShowUp(screens.addToken.tab.custom, 10)
|
||||
try {
|
||||
await tab.click()
|
||||
} catch (err) {
|
||||
}
|
||||
}
|
||||
while (await waitUntilShowUp(screens.addToken.custom.fields.contractAddress) === false)
|
||||
while ((await waitUntilShowUp(screens.addToken.custom.fields.contractAddress) === false) && (count-- > 0))
|
||||
} catch (err) {
|
||||
}
|
||||
const fieldAddress = await waitUntilShowUp(screens.addToken.custom.fields.contractAddress)
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
const assert = require('assert')
|
||||
const { countSignificantDecimals, getCurrentKeyring, ifLooseAcc, ifContractAcc } = require('../../../../old-ui/app/util')
|
||||
const {
|
||||
countSignificantDecimals,
|
||||
getCurrentKeyring,
|
||||
ifLooseAcc,
|
||||
ifContractAcc,
|
||||
} = require('../../../../old-ui/app/util')
|
||||
|
||||
describe('countSignificantDecimals(val, len) function', () => {
|
||||
it('returns correct significant decimals', () => {
|
||||
|
|
Loading…
Reference in New Issue