E2E files linting (#117)
* Introduced linting for oracle-e2e. * Fixed linting errors. * Introduced linting for ui-e2e * Fixed linting errors. * Typo.
This commit is contained in:
parent
b254df7c25
commit
4c5df11fd3
14
oracle-e2e/.eslintrc
Normal file
14
oracle-e2e/.eslintrc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"plugin:node/recommended",
|
||||||
|
"airbnb-base",
|
||||||
|
"../.eslintrc"
|
||||||
|
],
|
||||||
|
"plugins": ["node"],
|
||||||
|
"rules": {
|
||||||
|
"node/no-unpublished-require": "off"
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"mocha": true
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,8 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "mocha"
|
"start": "mocha",
|
||||||
|
"lint": "eslint . --ignore-path ../.eslintignore"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
@ -20,14 +20,8 @@ homeWeb3.eth.accounts.wallet.add(user.privateKey)
|
|||||||
foreignWeb3.eth.accounts.wallet.add(user.privateKey)
|
foreignWeb3.eth.accounts.wallet.add(user.privateKey)
|
||||||
|
|
||||||
const tokenAbi = require(path.join(abisDir, 'ERC677BridgeToken.json')).abi
|
const tokenAbi = require(path.join(abisDir, 'ERC677BridgeToken.json')).abi
|
||||||
const erc20Token = new foreignWeb3.eth.Contract(
|
const erc20Token = new foreignWeb3.eth.Contract(tokenAbi, ercToErcBridge.foreignToken)
|
||||||
tokenAbi,
|
const erc677Token = new homeWeb3.eth.Contract(tokenAbi, ercToErcBridge.homeToken)
|
||||||
ercToErcBridge.foreignToken
|
|
||||||
)
|
|
||||||
const erc677Token = new homeWeb3.eth.Contract(
|
|
||||||
tokenAbi,
|
|
||||||
ercToErcBridge.homeToken
|
|
||||||
)
|
|
||||||
|
|
||||||
describe('erc to erc', () => {
|
describe('erc to erc', () => {
|
||||||
it('should convert tokens in foreign to tokens in home', async () => {
|
it('should convert tokens in foreign to tokens in home', async () => {
|
||||||
|
@ -20,10 +20,7 @@ homeWeb3.eth.accounts.wallet.add(user.privateKey)
|
|||||||
foreignWeb3.eth.accounts.wallet.add(user.privateKey)
|
foreignWeb3.eth.accounts.wallet.add(user.privateKey)
|
||||||
|
|
||||||
const tokenAbi = require(path.join(abisDir, 'ERC677BridgeToken.json')).abi
|
const tokenAbi = require(path.join(abisDir, 'ERC677BridgeToken.json')).abi
|
||||||
const erc20Token = new foreignWeb3.eth.Contract(
|
const erc20Token = new foreignWeb3.eth.Contract(tokenAbi, ercToNativeBridge.foreignToken)
|
||||||
tokenAbi,
|
|
||||||
ercToNativeBridge.foreignToken
|
|
||||||
)
|
|
||||||
|
|
||||||
describe('erc to native', () => {
|
describe('erc to native', () => {
|
||||||
it('should convert tokens in foreign to coins in home', async () => {
|
it('should convert tokens in foreign to coins in home', async () => {
|
||||||
|
@ -2,7 +2,14 @@ const path = require('path')
|
|||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
const promiseRetry = require('promise-retry')
|
const promiseRetry = require('promise-retry')
|
||||||
const { user, validator, nativeToErcBridge, secondUser, homeRPC, foreignRPC } = require('../../e2e-commons/constants.json')
|
const {
|
||||||
|
user,
|
||||||
|
validator,
|
||||||
|
nativeToErcBridge,
|
||||||
|
secondUser,
|
||||||
|
homeRPC,
|
||||||
|
foreignRPC
|
||||||
|
} = require('../../e2e-commons/constants.json')
|
||||||
const { abiPath } = require('../config.json')
|
const { abiPath } = require('../config.json')
|
||||||
const { generateNewBlock } = require('../../e2e-commons/utils')
|
const { generateNewBlock } = require('../../e2e-commons/utils')
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"initialize": "yarn clean && git submodule update --init && yarn install --unsafe-perm --frozen-lockfile && yarn install:deploy && yarn compile:contracts",
|
"initialize": "yarn clean && git submodule update --init && yarn install --unsafe-perm --frozen-lockfile && yarn install:deploy && yarn compile:contracts",
|
||||||
"build": "yarn workspace ui run build",
|
"build": "yarn workspace ui run build",
|
||||||
"lint": "yarn wsrun --exclude oracle-e2e --exclude ui-e2e --exclude poa-parity-bridge-contracts lint",
|
"lint": "yarn wsrun --exclude poa-parity-bridge-contracts lint",
|
||||||
"test": "yarn wsrun --exclude monitor --exclude oracle-e2e --exclude ui-e2e test",
|
"test": "yarn wsrun --exclude monitor --exclude oracle-e2e --exclude ui-e2e test",
|
||||||
"ansible-lint": "./deployment/lint.sh",
|
"ansible-lint": "./deployment/lint.sh",
|
||||||
"oracle-e2e": "./oracle-e2e/run-tests.sh",
|
"oracle-e2e": "./oracle-e2e/run-tests.sh",
|
||||||
|
14
ui-e2e/.eslintrc
Normal file
14
ui-e2e/.eslintrc
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"plugin:node/recommended",
|
||||||
|
"airbnb-base",
|
||||||
|
"../.eslintrc"
|
||||||
|
],
|
||||||
|
"plugins": ["node"],
|
||||||
|
"rules": {
|
||||||
|
"node/no-unpublished-require": "off"
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"mocha": true
|
||||||
|
}
|
||||||
|
}
|
@ -1,152 +1,168 @@
|
|||||||
const key = require('selenium-webdriver').Key;
|
/* eslint-disable no-return-await */
|
||||||
const Page = require('./Page.js').Page;
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
const By = require('selenium-webdriver/lib/by').By;
|
const { Key } = require('selenium-webdriver')
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
const { By } = require('selenium-webdriver/lib/by')
|
||||||
|
const { Page } = require('./Page.js')
|
||||||
const { homeRPC, foreignRPC } = require('../e2e-commons/constants.json')
|
const { homeRPC, foreignRPC } = require('../e2e-commons/constants.json')
|
||||||
const IDMetaMask = "nkbihfbeogaeaoehlefnkodbefgpgknn";
|
|
||||||
const URL = "chrome-extension://" + IDMetaMask + "//popup.html";
|
|
||||||
const buttonSubmit = By.className("confirm btn-green");
|
|
||||||
const buttonAccept = By.xpath('//*[@id="app-content"]/div/div[4]/div/button');
|
|
||||||
const agreement = By.xpath("//*[@id=\"app-content\"]/div/div[4]/div/div/div/p[1]/strong");
|
|
||||||
const fieldNewPass = By.xpath("//*[@id=\"password-box\"]");
|
|
||||||
const fieldConfirmPass = By.xpath("//*[@id=\"password-box-confirm\"]");
|
|
||||||
const buttonCreate = By.xpath("//*[@id=\"app-content\"]/div/div[4]/div/button");
|
|
||||||
const buttonIveCopied = By.xpath("//*[@id=\"app-content\"]/div/div[4]/div/button[1]");
|
|
||||||
const popupNetwork = By.className("network-name");
|
|
||||||
const popupAccount = By.xpath("//*[@id=\"app-content\"]/div/div[1]/div/div[2]/span/div");
|
|
||||||
const fieldPrivateKey = By.xpath("//*[@id=\"private-key-box\"]");
|
|
||||||
const pass = "qwerty12345";
|
|
||||||
const buttonImport = By.xpath("//*[@id=\"app-content\"]/div/div[4]/div/div[3]/button");
|
|
||||||
const fieldNewRPCURL = By.id("new_rpc");
|
|
||||||
const buttonSave = By.xpath("//*[@id=\"app-content\"]/div/div[4]/div/div[3]/div/div[2]/button");
|
|
||||||
const arrowBackRPCURL = By.xpath("//*[@id=\"app-content\"]/div/div[4]/div/div[1]/i");
|
|
||||||
const iconChangeAccount = By.className("cursor-pointer color-orange accounts-selector");
|
|
||||||
|
|
||||||
var accountOrderNumber = 1;
|
const IDMetaMask = 'nkbihfbeogaeaoehlefnkodbefgpgknn'
|
||||||
var networks = [0, 3, 43, 4, 8545];
|
const URL = 'chrome-extension://' + IDMetaMask + '//popup.html'
|
||||||
|
const buttonSubmit = By.className('confirm btn-green')
|
||||||
|
const buttonAccept = By.xpath('//*[@id="app-content"]/div/div[4]/div/button')
|
||||||
|
const agreement = By.xpath('//*[@id="app-content"]/div/div[4]/div/div/div/p[1]/strong')
|
||||||
|
const fieldNewPass = By.xpath('//*[@id="password-box"]')
|
||||||
|
const fieldConfirmPass = By.xpath('//*[@id="password-box-confirm"]')
|
||||||
|
const buttonCreate = By.xpath('//*[@id="app-content"]/div/div[4]/div/button')
|
||||||
|
const buttonIveCopied = By.xpath('//*[@id="app-content"]/div/div[4]/div/button[1]')
|
||||||
|
const popupNetwork = By.className('network-name')
|
||||||
|
const popupAccount = By.xpath('//*[@id="app-content"]/div/div[1]/div/div[2]/span/div')
|
||||||
|
const fieldPrivateKey = By.xpath('//*[@id="private-key-box"]')
|
||||||
|
const pass = 'qwerty12345'
|
||||||
|
const buttonImport = By.xpath('//*[@id="app-content"]/div/div[4]/div/div[3]/button')
|
||||||
|
const fieldNewRPCURL = By.id('new_rpc')
|
||||||
|
const buttonSave = By.xpath('//*[@id="app-content"]/div/div[4]/div/div[3]/div/div[2]/button')
|
||||||
|
const arrowBackRPCURL = By.xpath('//*[@id="app-content"]/div/div[4]/div/div[1]/i')
|
||||||
|
const iconChangeAccount = By.className('cursor-pointer color-orange accounts-selector')
|
||||||
|
|
||||||
|
let accountOrderNumber = 1
|
||||||
|
const networks = [0, 3, 43, 4, 8545]
|
||||||
|
|
||||||
class MetaMask extends Page {
|
class MetaMask extends Page {
|
||||||
|
|
||||||
constructor(driver) {
|
constructor(driver) {
|
||||||
super(driver);
|
super(driver)
|
||||||
this.driver = driver;
|
this.driver = driver
|
||||||
this.URL = URL;
|
this.URL = URL
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickButtonSubmitTransaction() {
|
async clickButtonSubmitTransaction() {
|
||||||
return await this.clickWithWait(buttonSubmit);
|
return this.clickWithWait(buttonSubmit)
|
||||||
}
|
}
|
||||||
|
|
||||||
async activate() {
|
async activate() {
|
||||||
return await this.switchToNextPage() &&
|
return (
|
||||||
(await this.open(this.URL) === this.URL) &&
|
(await this.switchToNextPage()) &&
|
||||||
await this.clickWithWait(buttonAccept) &&
|
(await this.open(this.URL)) === this.URL &&
|
||||||
await this.clickWithWait(agreement) &&
|
(await this.clickWithWait(buttonAccept)) &&
|
||||||
await this.clickKey(key.TAB, 15) &&
|
(await this.clickWithWait(agreement)) &&
|
||||||
await this.clickWithWait(buttonAccept) &&
|
(await this.clickKey(Key.TAB, 15)) &&
|
||||||
await this.waitUntilLocated(fieldNewPass) &&
|
(await this.clickWithWait(buttonAccept)) &&
|
||||||
await this.clickWithWait(fieldNewPass) &&
|
(await this.waitUntilLocated(fieldNewPass)) &&
|
||||||
await this.fillWithWait(fieldNewPass, pass) &&
|
(await this.clickWithWait(fieldNewPass)) &&
|
||||||
await this.fillWithWait(fieldConfirmPass, pass) &&
|
(await this.fillWithWait(fieldNewPass, pass)) &&
|
||||||
await this.clickWithWait(buttonCreate) &&
|
(await this.fillWithWait(fieldConfirmPass, pass)) &&
|
||||||
await this.waitUntilDisplayed(buttonIveCopied) &&
|
(await this.clickWithWait(buttonCreate)) &&
|
||||||
await this.clickWithWait(buttonIveCopied) &&
|
(await this.waitUntilDisplayed(buttonIveCopied)) &&
|
||||||
await this.switchToNextPage();
|
(await this.clickWithWait(buttonIveCopied)) &&
|
||||||
|
(await this.switchToNextPage())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async importAccount(user) {
|
async importAccount(user) {
|
||||||
user.accountOrderInMetamask = accountOrderNumber - 1;
|
user.accountOrderInMetamask = accountOrderNumber - 1
|
||||||
return await this.switchToNextPage() &&
|
return (
|
||||||
await this.setNetwork(user.networkID) &&
|
(await this.switchToNextPage()) &&
|
||||||
await this.clickImportAccount() &&
|
(await this.setNetwork(user.networkID)) &&
|
||||||
await this.fillWithWait(fieldPrivateKey, user.privateKey) &&
|
(await this.clickImportAccount()) &&
|
||||||
await this.waitUntilDisplayed(buttonImport) &&
|
(await this.fillWithWait(fieldPrivateKey, user.privateKey)) &&
|
||||||
await this.clickWithWait(buttonImport) &&
|
(await this.waitUntilDisplayed(buttonImport)) &&
|
||||||
await this.switchToNextPage();
|
(await this.clickWithWait(buttonImport)) &&
|
||||||
|
(await this.switchToNextPage())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectAccount(user) {
|
async selectAccount(user) {
|
||||||
try {
|
try {
|
||||||
await this.switchToNextPage();
|
await this.switchToNextPage()
|
||||||
await this.setNetwork(user.networkID);
|
await this.setNetwork(user.networkID)
|
||||||
await super.clickWithWait(popupAccount);
|
await super.clickWithWait(popupAccount)
|
||||||
await this.driver.executeScript("document.getElementsByClassName('dropdown-menu-item')[" +
|
await this.driver.executeScript(
|
||||||
user.accountOrderInMetamask + "].click();");
|
"document.getElementsByClassName('dropdown-menu-item')[" +
|
||||||
await this.switchToNextPage();
|
user.accountOrderInMetamask +
|
||||||
return true;
|
'].click();'
|
||||||
}
|
)
|
||||||
catch (err) {
|
await this.switchToNextPage()
|
||||||
return false;
|
return true
|
||||||
|
} catch (err) {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickImportAccount() {
|
async clickImportAccount() {
|
||||||
try {
|
try {
|
||||||
await super.clickWithWait(popupAccount);
|
await super.clickWithWait(popupAccount)
|
||||||
await this.driver.executeScript("document.getElementsByClassName('dropdown-menu-item')["
|
await this.driver.executeScript(
|
||||||
+ (accountOrderNumber + 1) + "].click();");
|
"document.getElementsByClassName('dropdown-menu-item')[" +
|
||||||
accountOrderNumber++;
|
(accountOrderNumber + 1) +
|
||||||
return true;
|
'].click();'
|
||||||
}
|
)
|
||||||
catch (err) {
|
accountOrderNumber++
|
||||||
return false;
|
return true
|
||||||
|
} catch (err) {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async signTransaction(refreshCount) {
|
async signTransaction(refreshCount) {
|
||||||
await this.switchToNextPage();
|
await this.switchToNextPage()
|
||||||
let counter = 5;
|
let counter = 5
|
||||||
if (refreshCount !== undefined) counter = refreshCount;
|
if (refreshCount !== undefined) counter = refreshCount
|
||||||
do {
|
do {
|
||||||
await this.refresh();
|
await this.refresh()
|
||||||
await super.waitUntilLocated(iconChangeAccount);
|
await super.waitUntilLocated(iconChangeAccount)
|
||||||
if (await this.isElementDisplayed(buttonSubmit)) {
|
if (await this.isElementDisplayed(buttonSubmit)) {
|
||||||
return await this.clickButtonSubmitTransaction() &&
|
return (await this.clickButtonSubmitTransaction()) && (await this.switchToNextPage())
|
||||||
await this.switchToNextPage();
|
|
||||||
}
|
}
|
||||||
await this.driver.sleep(3000);
|
await this.driver.sleep(3000)
|
||||||
} while (counter-- >= 0);
|
} while (counter-- >= 0)
|
||||||
|
|
||||||
await this.switchToNextPage();
|
await this.switchToNextPage()
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
async setNetwork(provider) {
|
async setNetwork(provider) {
|
||||||
try {
|
try {
|
||||||
await super.clickWithWait(popupNetwork);
|
await super.clickWithWait(popupNetwork)
|
||||||
let orderNumber = networks.indexOf(provider);
|
const orderNumber = networks.indexOf(provider)
|
||||||
let script = "document.getElementsByClassName('dropdown-menu-item')[" + orderNumber + "].click();"
|
const script =
|
||||||
if (orderNumber < 0) await this.addNetwork(provider);
|
"document.getElementsByClassName('dropdown-menu-item')[" + orderNumber + '].click();'
|
||||||
else await this.driver.executeScript(script);
|
if (orderNumber < 0) await this.addNetwork(provider)
|
||||||
return true;
|
else await this.driver.executeScript(script)
|
||||||
}
|
return true
|
||||||
catch (err) {
|
} catch (err) {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async addNetwork(provider) {
|
async addNetwork(provider) {
|
||||||
let url;
|
let url
|
||||||
switch (provider) {
|
switch (provider) {
|
||||||
case homeRPC.ID: {
|
case homeRPC.ID: {
|
||||||
url = "http://localhost:8541";
|
url = 'http://localhost:8541'
|
||||||
networks.push(177);
|
networks.push(177)
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
case foreignRPC.ID: {
|
case foreignRPC.ID: {
|
||||||
url = "http://localhost:8542";
|
url = 'http://localhost:8542'
|
||||||
networks.push(142);
|
networks.push(142)
|
||||||
break;
|
break
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
throw new Error(`Unexcpected provider ${provider}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const index = networks.length > 8 ? 8 : networks.length;
|
const index = networks.length > 8 ? 8 : networks.length
|
||||||
await this.driver.executeScript("document.getElementsByClassName('dropdown-menu-item')[" +
|
await this.driver.executeScript(
|
||||||
(index - 1) + "].click();");
|
"document.getElementsByClassName('dropdown-menu-item')[" + (index - 1) + '].click();'
|
||||||
return await super.fillWithWait(fieldNewRPCURL, url) &&
|
)
|
||||||
await super.clickWithWait(buttonSave) &&
|
return (
|
||||||
await super.clickWithWait(arrowBackRPCURL);
|
(await super.fillWithWait(fieldNewRPCURL, url)) &&
|
||||||
|
(await super.clickWithWait(buttonSave)) &&
|
||||||
|
(await super.clickWithWait(arrowBackRPCURL))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
MetaMask: MetaMask
|
MetaMask
|
||||||
};
|
}
|
||||||
|
171
ui-e2e/Page.js
171
ui-e2e/Page.js
@ -1,166 +1,151 @@
|
|||||||
const webdriver = require('selenium-webdriver');
|
/* eslint-disable no-return-await */
|
||||||
const Twait = 20000;
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
const webdriver = require('selenium-webdriver')
|
||||||
|
|
||||||
|
const Twait = 20000
|
||||||
|
|
||||||
class Page {
|
class Page {
|
||||||
|
|
||||||
constructor(driver) {
|
constructor(driver) {
|
||||||
this.driver = driver;
|
this.driver = driver
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilDisplayed(element, Twaiting) {
|
async waitUntilDisplayed(element, Twaiting) {
|
||||||
let counter = Twaiting;
|
let counter = Twaiting
|
||||||
if (counter === undefined) counter = 180;
|
if (counter === undefined) counter = 180
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
await this.driver.sleep(300);
|
await this.driver.sleep(300)
|
||||||
if (await this.isElementDisplayed(element)) return true;
|
if (await this.isElementDisplayed(element)) return true
|
||||||
} while (counter-- > 0);
|
} while (counter-- > 0)
|
||||||
return false;
|
return false
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
return false
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilDisappear(element, Twaiting) {
|
async waitUntilDisappear(element, Twaiting) {
|
||||||
let counter = Twaiting;
|
let counter = Twaiting
|
||||||
if (counter === undefined) counter = 180;
|
if (counter === undefined) counter = 180
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
await this.driver.sleep(300);
|
await this.driver.sleep(300)
|
||||||
if (!await this.isElementDisplayed(element)) return true;
|
if (!(await this.isElementDisplayed(element))) return true
|
||||||
} while (counter-- > 0);
|
} while (counter-- > 0)
|
||||||
return false;
|
return false
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
return false
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilLocated(element, Twaiting) {
|
async waitUntilLocated(element, Twaiting) {
|
||||||
let counter = Twaiting;
|
let counter = Twaiting
|
||||||
if (counter === undefined) counter = 180;
|
if (counter === undefined) counter = 180
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
await this.driver.sleep(300);
|
await this.driver.sleep(300)
|
||||||
if (await this.isElementLocated(element)) return true;
|
if (await this.isElementLocated(element)) return true
|
||||||
} while (counter-- > 0);
|
} while (counter-- > 0)
|
||||||
return false;
|
return false
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
return false
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async isElementDisplayed(element) {
|
async isElementDisplayed(element) {
|
||||||
try {
|
try {
|
||||||
return await this.driver.findElement(element).isDisplayed();
|
return await this.driver.findElement(element).isDisplayed()
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
return false
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async isElementLocated(element) {
|
async isElementLocated(element) {
|
||||||
return (await this.driver.findElements(element)).length > 0;
|
return (await this.driver.findElements(element)).length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickWithWait(element) {
|
async clickWithWait(element) {
|
||||||
try {
|
try {
|
||||||
let field;
|
let field
|
||||||
if (element.constructor.name !== "WebElement") {
|
if (element.constructor.name !== 'WebElement') {
|
||||||
field = await this.driver.wait(webdriver.until.elementLocated(element), Twait);
|
field = await this.driver.wait(webdriver.until.elementLocated(element), Twait)
|
||||||
}
|
} else field = element
|
||||||
else field = element;
|
await field.click()
|
||||||
await field.click();
|
return true
|
||||||
return true;
|
} catch (err) {
|
||||||
}
|
return false
|
||||||
catch (err) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fillWithWait(element, text) {
|
async fillWithWait(element, text) {
|
||||||
try {
|
try {
|
||||||
let field;
|
let field
|
||||||
if (element.constructor.name !== "WebElement") {
|
if (element.constructor.name !== 'WebElement') {
|
||||||
field = await this.driver.wait(webdriver.until.elementLocated(element), Twait);
|
field = await this.driver.wait(webdriver.until.elementLocated(element), Twait)
|
||||||
}
|
} else field = element
|
||||||
else field = element;
|
await field.sendKeys(text)
|
||||||
await field.sendKeys(text);
|
return true
|
||||||
return true;
|
} catch (err) {
|
||||||
}
|
return false
|
||||||
catch (err) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async findWithWait(element) {
|
async findWithWait(element) {
|
||||||
try {
|
try {
|
||||||
await this.driver.wait(webdriver.until.elementLocated(element), Twait);
|
await this.driver.wait(webdriver.until.elementLocated(element), Twait)
|
||||||
return await this.driver.findElements(element);
|
return await this.driver.findElements(element)
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
return null
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async switchToNextPage() {
|
async switchToNextPage() {
|
||||||
let allHandles = [];
|
let allHandles = []
|
||||||
let curHandle;
|
let curHandle
|
||||||
try {
|
try {
|
||||||
allHandles = await this.driver.getAllWindowHandles();
|
allHandles = await this.driver.getAllWindowHandles()
|
||||||
curHandle = await this.driver.getWindowHandle();
|
curHandle = await this.driver.getWindowHandle()
|
||||||
if (allHandles.length > 2) {
|
if (allHandles.length > 2) {
|
||||||
let arr = [];
|
allHandles = [allHandles[0], allHandles[1]]
|
||||||
arr[0] = allHandles[0];
|
|
||||||
arr[1] = allHandles[1];
|
|
||||||
allHandles = arr;
|
|
||||||
}
|
}
|
||||||
let handle;
|
let handle
|
||||||
for (let i = 0; i < allHandles.length; i++) {
|
for (let i = 0; i < allHandles.length; i++) {
|
||||||
if (curHandle !== allHandles[i]) {
|
if (curHandle !== allHandles[i]) {
|
||||||
handle = allHandles[i];
|
handle = allHandles[i]
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.driver.switchTo().window(handle);
|
await this.driver.switchTo().window(handle)
|
||||||
await this.driver.sleep(500);
|
await this.driver.sleep(500)
|
||||||
return true;
|
return true
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
return false
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async refresh() {
|
async refresh() {
|
||||||
await this.driver.navigate().refresh();
|
await this.driver.navigate().refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUrl() {
|
async getUrl() {
|
||||||
return await this.driver.getCurrentUrl();
|
return await this.driver.getCurrentUrl()
|
||||||
}
|
}
|
||||||
|
|
||||||
async open(url) {
|
async open(url) {
|
||||||
await this.driver.get(url);
|
await this.driver.get(url)
|
||||||
return this.getUrl();
|
return this.getUrl()
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickKey(key, times) {
|
async clickKey(key, times) {
|
||||||
try {
|
try {
|
||||||
const action = this.driver.actions();
|
const action = this.driver.actions()
|
||||||
for (let i = 0; i < times; i++)
|
for (let i = 0; i < times; i++) await action.sendKeys(key).perform()
|
||||||
await action.sendKeys(key).perform();
|
return true
|
||||||
return true;
|
} catch (err) {
|
||||||
}
|
return false
|
||||||
catch (err) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Page: Page
|
Page
|
||||||
};
|
}
|
||||||
|
|
||||||
|
@ -1,51 +1,53 @@
|
|||||||
const fs = require('fs-extra');
|
/* eslint-disable no-return-await */
|
||||||
const MetaMask = require('./MetaMask.js').MetaMask;
|
const { MetaMask } = require('./MetaMask.js')
|
||||||
const MainPage = require('./mainPage.js').MainPage;
|
const { MainPage } = require('./mainPage.js')
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
constructor(driver, obj) {
|
constructor(driver, obj) {
|
||||||
try {
|
try {
|
||||||
this.driver = driver;
|
this.driver = driver
|
||||||
this.account = obj.account;
|
this.account = obj.account
|
||||||
this.privateKey = obj.privateKey;
|
this.privateKey = obj.privateKey
|
||||||
this.networkID = obj.networkID;
|
this.networkID = obj.networkID
|
||||||
this.accountOrderInMetamask = "undefined";//for MetaMaskPage usage only
|
this.accountOrderInMetamask = 'undefined' // for MetaMaskPage usage only
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
console.log('instance User was not created')
|
||||||
console.log("instance User was not created");
|
console.log(err)
|
||||||
console.log(err);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async transferTokens(amount) {
|
async transferTokens(amount) {
|
||||||
let mainPage = new MainPage(this.driver);
|
const mainPage = new MainPage(this.driver)
|
||||||
let metaMask = new MetaMask(this.driver);
|
const metaMask = new MetaMask(this.driver)
|
||||||
return await mainPage.fillFieldAmount(amount) &&
|
return (
|
||||||
await mainPage.clickButtonTransfer() &&
|
(await mainPage.fillFieldAmount(amount)) &&
|
||||||
await mainPage.waitUntilShowUpButtonTransferConfirm() &&
|
(await mainPage.clickButtonTransfer()) &&
|
||||||
await mainPage.clickButtonTransferConfirm() &&
|
(await mainPage.waitUntilShowUpButtonTransferConfirm()) &&
|
||||||
await metaMask.signTransaction() &&
|
(await mainPage.clickButtonTransferConfirm()) &&
|
||||||
await mainPage.waitUntilTransactionDone() &&
|
(await metaMask.signTransaction()) &&
|
||||||
await mainPage.waitUntilShowUpButtonOk() &&
|
(await mainPage.waitUntilTransactionDone()) &&
|
||||||
await mainPage.clickButtonOk()
|
(await mainPage.waitUntilShowUpButtonOk()) &&
|
||||||
|
(await mainPage.clickButtonOk())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async setMetaMaskNetwork() {
|
async setMetaMaskNetwork() {
|
||||||
let metaMask = new MetaMask(this.driver);
|
const metaMask = new MetaMask(this.driver)
|
||||||
return await metaMask.switchToNextPage() &&
|
return (
|
||||||
await metaMask.setNetwork(this.networkID) &&
|
(await metaMask.switchToNextPage()) &&
|
||||||
await metaMask.switchToNextPage();
|
(await metaMask.setNetwork(this.networkID)) &&
|
||||||
|
(await metaMask.switchToNextPage())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async setMetaMaskAccount() {
|
async setMetaMaskAccount() {
|
||||||
let metaMask = new MetaMask(this.driver);
|
const metaMask = new MetaMask(this.driver)
|
||||||
if (this.accountOrderInMetamask === "undefined") {
|
if (this.accountOrderInMetamask === 'undefined') {
|
||||||
return await metaMask.importAccount(this);
|
return await metaMask.importAccount(this)
|
||||||
} else
|
} else return await metaMask.selectAccount(this)
|
||||||
return await metaMask.selectAccount(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
User: User
|
User
|
||||||
};
|
}
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
const webdriver = require('selenium-webdriver');
|
/* eslint-disable import/no-extraneous-dependencies */
|
||||||
const chrome = require('selenium-webdriver/chrome');
|
/* eslint-disable no-return-await */
|
||||||
const {user, nativeToErcBridge, ercToErcBridge, ercToNativeBridge, homeRPC, foreignRPC} = require('../e2e-commons/constants.json')
|
const webdriver = require('selenium-webdriver')
|
||||||
|
const chrome = require('selenium-webdriver/chrome')
|
||||||
|
const {
|
||||||
|
user,
|
||||||
|
nativeToErcBridge,
|
||||||
|
ercToErcBridge,
|
||||||
|
ercToNativeBridge,
|
||||||
|
homeRPC,
|
||||||
|
foreignRPC
|
||||||
|
} = require('../e2e-commons/constants.json')
|
||||||
|
|
||||||
class Utils {
|
class Utils {
|
||||||
|
|
||||||
static async getHomeAccount() {
|
static async getHomeAccount() {
|
||||||
return {
|
return {
|
||||||
account: user.address,
|
account: user.address,
|
||||||
@ -21,25 +29,25 @@ class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async getStartURL() {
|
static async getStartURL() {
|
||||||
return nativeToErcBridge.ui;
|
return nativeToErcBridge.ui
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getErc20StartURL() {
|
static async getErc20StartURL() {
|
||||||
return ercToErcBridge.ui;
|
return ercToErcBridge.ui
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getErc20NativeStartURL() {
|
static async getErc20NativeStartURL() {
|
||||||
return ercToNativeBridge.ui;
|
return ercToNativeBridge.ui
|
||||||
}
|
}
|
||||||
|
|
||||||
static async startBrowserWithMetamask() {
|
static async startBrowserWithMetamask() {
|
||||||
let source = './MetaMask.crx';
|
const source = './MetaMask.crx'
|
||||||
let options = new chrome.Options();
|
const options = new chrome.Options()
|
||||||
await options.addExtensions(source);
|
await options.addExtensions(source)
|
||||||
await options.addArguments('disable-popup-blocking');
|
await options.addArguments('disable-popup-blocking')
|
||||||
let driver = await new webdriver.Builder().withCapabilities(options.toCapabilities()).build();
|
const driver = await new webdriver.Builder().withCapabilities(options.toCapabilities()).build()
|
||||||
await driver.sleep(5000);
|
await driver.sleep(5000)
|
||||||
return driver;
|
return driver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,133 +1,125 @@
|
|||||||
const Page = require('./Page.js').Page;
|
/* eslint-disable no-return-await */
|
||||||
const By = require('selenium-webdriver/lib/by').By;
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
const fieldAmount = By.id("amount");
|
const { By } = require('selenium-webdriver/lib/by')
|
||||||
const buttonTransfer = By.className("bridge-form-button ");
|
const { Page } = require('./Page.js')
|
||||||
const buttonOk = By.className("swal-button swal-button--confirm");
|
|
||||||
const fieldsBalance = By.className("network-balance");
|
const fieldAmount = By.id('amount')
|
||||||
const classWeb3Loaded = By.className("web3-loaded");
|
const buttonTransfer = By.className('bridge-form-button ')
|
||||||
const classPendingTransaction = By.className("pending-transaction");
|
const buttonOk = By.className('swal-button swal-button--confirm')
|
||||||
const loadingContainer = By.className("loading-container");
|
const fieldsBalance = By.className('network-balance')
|
||||||
const buttonTransferConfirm = By.className("transfer-confirm");
|
const classWeb3Loaded = By.className('web3-loaded')
|
||||||
const buttonDisclaimerConfirm = By.className("disclaimer-confirm");
|
const classPendingTransaction = By.className('pending-transaction')
|
||||||
const checkboxDisclaimer = By.className("disclaimer-checkbox");
|
const loadingContainer = By.className('loading-container')
|
||||||
const disclaimer = By.className("disclaimer-title");
|
const buttonTransferConfirm = By.className('transfer-confirm')
|
||||||
|
const buttonDisclaimerConfirm = By.className('disclaimer-confirm')
|
||||||
|
const checkboxDisclaimer = By.className('disclaimer-checkbox')
|
||||||
|
const disclaimer = By.className('disclaimer-title')
|
||||||
|
|
||||||
class MainPage extends Page {
|
class MainPage extends Page {
|
||||||
constructor(driver) {
|
|
||||||
super(driver);
|
|
||||||
this.url;
|
|
||||||
this.fieldHomePOABalance;
|
|
||||||
this.fieldForeignPOABalance;
|
|
||||||
}
|
|
||||||
|
|
||||||
async initFieldsBalance() {
|
async initFieldsBalance() {
|
||||||
if (!(await this.waitUntilWeb3Loaded())) return null;
|
if (!(await this.waitUntilWeb3Loaded())) return null
|
||||||
try {
|
try {
|
||||||
let array;
|
const array = await super.findWithWait(fieldsBalance)
|
||||||
array = await super.findWithWait(fieldsBalance);
|
/* eslint-disable prefer-destructuring */
|
||||||
this.fieldHomePOABalance = array[0];
|
this.fieldHomePOABalance = array[0]
|
||||||
this.fieldForeignPOABalance = array[1];
|
this.fieldForeignPOABalance = array[1]
|
||||||
return array;
|
/* eslint-enable prefer-destructuring */
|
||||||
}
|
return array
|
||||||
catch (err) {
|
} catch (err) {
|
||||||
return null;
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getHomePOABalance() {
|
async getHomePOABalance() {
|
||||||
await this.initFieldsBalance();
|
await this.initFieldsBalance()
|
||||||
return parseFloat(await this.fieldHomePOABalance.getText());
|
return parseFloat(await this.fieldHomePOABalance.getText())
|
||||||
}
|
}
|
||||||
|
|
||||||
async getForeignPOABalance() {
|
async getForeignPOABalance() {
|
||||||
await this.initFieldsBalance();
|
await this.initFieldsBalance()
|
||||||
return parseFloat(await this.fieldForeignPOABalance.getText());
|
return parseFloat(await this.fieldForeignPOABalance.getText())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fillFieldAmount(amount) {
|
async fillFieldAmount(amount) {
|
||||||
try {
|
try {
|
||||||
await this.clickWithWait(fieldAmount);
|
await this.clickWithWait(fieldAmount)
|
||||||
await this.fillWithWait(fieldAmount, amount);
|
await this.fillWithWait(fieldAmount, amount)
|
||||||
return true;
|
return true
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
return false
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickButtonTransfer() {
|
async clickButtonTransfer() {
|
||||||
return await this.clickWithWait(buttonTransfer);
|
return this.clickWithWait(buttonTransfer)
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickButtonOk() {
|
async clickButtonOk() {
|
||||||
return await super.clickWithWait(buttonOk);
|
return super.clickWithWait(buttonOk)
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickButtonTransferConfirm() {
|
async clickButtonTransferConfirm() {
|
||||||
return await super.clickWithWait(buttonTransferConfirm);
|
return super.clickWithWait(buttonTransferConfirm)
|
||||||
}
|
}
|
||||||
|
|
||||||
async isPresentButtonOk() {
|
async isPresentButtonOk() {
|
||||||
return await super.isElementDisplayed(buttonOk, 180);
|
return super.isElementDisplayed(buttonOk, 180)
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilWeb3Loaded() {
|
async waitUntilWeb3Loaded() {
|
||||||
return await this.waitUntilLocated(classWeb3Loaded, 180);
|
return this.waitUntilLocated(classWeb3Loaded, 180)
|
||||||
}
|
}
|
||||||
|
|
||||||
async isPendingTransaction() {
|
async isPendingTransaction() {
|
||||||
return await super.isElementLocated(classPendingTransaction);
|
return super.isElementLocated(classPendingTransaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilTransactionDone() {
|
async waitUntilTransactionDone() {
|
||||||
return await this.waitUntilDisappear(classPendingTransaction, 360);
|
return this.waitUntilDisappear(classPendingTransaction, 360)
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilShowUpButtonOk() {
|
async waitUntilShowUpButtonOk() {
|
||||||
return await super.waitUntilDisplayed(buttonOk, 360);
|
return super.waitUntilDisplayed(buttonOk, 360)
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilShowUpButtonTransferConfirm() {
|
async waitUntilShowUpButtonTransferConfirm() {
|
||||||
return await super.waitUntilDisplayed(buttonTransferConfirm, 360);
|
return super.waitUntilDisplayed(buttonTransferConfirm, 360)
|
||||||
}
|
|
||||||
|
|
||||||
async waitUntilShowUpButtonOk() {
|
|
||||||
return await super.waitUntilDisplayed(buttonOk, 360);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilShowUpLoadingContainer() {
|
async waitUntilShowUpLoadingContainer() {
|
||||||
return await super.waitUntilDisplayed(loadingContainer, 180);
|
return super.waitUntilDisplayed(loadingContainer, 180)
|
||||||
}
|
}
|
||||||
|
|
||||||
async isDisplayedLoadingContainer() {
|
async isDisplayedLoadingContainer() {
|
||||||
return await super.isElementDisplayed(loadingContainer);
|
return super.isElementDisplayed(loadingContainer)
|
||||||
}
|
}
|
||||||
|
|
||||||
async confirmDisclaimer() {
|
async confirmDisclaimer() {
|
||||||
return await super.waitUntilDisplayed(disclaimer, 180) &&
|
return (
|
||||||
|
(await super.waitUntilDisplayed(disclaimer, 180)) &&
|
||||||
// await this.clickCheckboxDisclaimer() &&
|
// await this.clickCheckboxDisclaimer() &&
|
||||||
await this.clickButtonDisclaimerConfirm();
|
(await this.clickButtonDisclaimerConfirm())
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickButtonDisclaimerConfirm() {
|
async clickButtonDisclaimerConfirm() {
|
||||||
return await super.clickWithWait(buttonDisclaimerConfirm);
|
return super.clickWithWait(buttonDisclaimerConfirm)
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickCheckboxDisclaimer() {
|
async clickCheckboxDisclaimer() {
|
||||||
return await super.clickWithWait(checkboxDisclaimer);
|
return super.clickWithWait(checkboxDisclaimer)
|
||||||
}
|
}
|
||||||
|
|
||||||
async open(url) {
|
async open(url) {
|
||||||
let counter = 60;
|
let counter = 60
|
||||||
do {
|
do {
|
||||||
await this.driver.sleep(1000);
|
await this.driver.sleep(1000)
|
||||||
await super.open(url);
|
await super.open(url)
|
||||||
} while (counter-- >= 0 && !await this.isElementDisplayed(disclaimer))
|
} while (counter-- >= 0 && !(await this.isElementDisplayed(disclaimer)))
|
||||||
return (counter >= 0);
|
return counter >= 0
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
MainPage: MainPage
|
MainPage
|
||||||
};
|
}
|
||||||
|
@ -6,5 +6,10 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"selenium-webdriver": "3.6.0"
|
"selenium-webdriver": "3.6.0"
|
||||||
},
|
},
|
||||||
"scripts": {}
|
"scripts": {
|
||||||
|
"lint": "eslint . --ignore-path ../.eslintignore"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8.9"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
613
ui-e2e/test.js
613
ui-e2e/test.js
@ -1,310 +1,397 @@
|
|||||||
let test = require('selenium-webdriver/testing');
|
/* eslint-disable import/no-extraneous-dependencies */
|
||||||
let assert = require('assert');
|
/* eslint-disable no-return-await */
|
||||||
const Utils = require('./Utils.js').Utils;
|
const test = require('selenium-webdriver/testing')
|
||||||
const MetaMask = require('./MetaMask.js').MetaMask;
|
const assert = require('assert')
|
||||||
const MainPage = require('./mainPage.js').MainPage;
|
const { Utils } = require('./Utils.js')
|
||||||
const User = require("./User.js").User;
|
const { MetaMask } = require('./MetaMask.js')
|
||||||
|
const { MainPage } = require('./mainPage.js')
|
||||||
|
const { User } = require('./User.js')
|
||||||
|
|
||||||
test.describe('e2e-test for bridge.poa, version 1.5.0', async function() {
|
test.describe('e2e-test for bridge.poa, version 1.5.0', async function() {
|
||||||
this.timeout(5 * 60000);
|
this.timeout(5 * 60000)
|
||||||
this.slow(1 * 60000);
|
this.slow(1 * 60000)
|
||||||
this.retries(2);
|
this.retries(2)
|
||||||
|
|
||||||
const maxAmountPerTransactionLimit = 1;
|
const maxAmountPerTransactionLimit = 1
|
||||||
let startURL;
|
let startURL
|
||||||
let driver;
|
let driver
|
||||||
let mainPage;
|
let mainPage
|
||||||
let homeAccount;
|
let homeAccount
|
||||||
let foreignAccount;
|
let foreignAccount
|
||||||
let metaMask;
|
let metaMask
|
||||||
let foreignBalanceBefore;
|
let foreignBalanceBefore
|
||||||
let homeBalanceBefore;
|
let homeBalanceBefore
|
||||||
|
|
||||||
test.before(async function () {
|
test.before(async () => {
|
||||||
try {
|
try {
|
||||||
driver = await Utils.startBrowserWithMetamask();
|
driver = await Utils.startBrowserWithMetamask()
|
||||||
mainPage = new MainPage(driver);
|
mainPage = new MainPage(driver)
|
||||||
homeAccount = new User(driver, await Utils.getHomeAccount());
|
homeAccount = new User(driver, await Utils.getHomeAccount())
|
||||||
foreignAccount = new User(driver, await Utils.getForeignAccount());
|
foreignAccount = new User(driver, await Utils.getForeignAccount())
|
||||||
metaMask = new MetaMask(driver);
|
metaMask = new MetaMask(driver)
|
||||||
await metaMask.activate();
|
await metaMask.activate()
|
||||||
await homeAccount.setMetaMaskAccount();
|
await homeAccount.setMetaMaskAccount()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
test.after(async function () {
|
test.after(async () => {
|
||||||
try {
|
try {
|
||||||
await driver.quit();
|
await driver.quit()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
test.it('User is able to open main page of bridge-ui ',
|
test.it('User is able to open main page of bridge-ui ', async () => {
|
||||||
async function () {
|
startURL = await Utils.getStartURL()
|
||||||
startURL = await Utils.getStartURL();
|
const result = await mainPage.open(startURL)
|
||||||
let result = await mainPage.open(startURL);
|
console.log('Test URL: ' + startURL)
|
||||||
console.log("Test URL: " + startURL);
|
return await assert.strictEqual(result, true, 'Test FAILED. Build failed.')
|
||||||
return await assert.equal(result, true, "Test FAILED. Build failed.");
|
})
|
||||||
});
|
|
||||||
|
|
||||||
test.it('Home page: disclaimer is displayed ',
|
test.it('Home page: disclaimer is displayed ', async () => {
|
||||||
async function () {
|
const result = await mainPage.confirmDisclaimer()
|
||||||
let result = await mainPage.confirmDisclaimer();
|
return await assert.strictEqual(result, true, 'Test FAILED. Disclaimer is not displayed')
|
||||||
return await assert.equal(result, true, "Test FAILED. Disclaimer is not displayed");
|
})
|
||||||
});
|
|
||||||
|
|
||||||
test.it('Main page: foreign POA balance is displayed ',
|
test.it('Main page: foreign POA balance is displayed ', async () => {
|
||||||
async function () {
|
foreignBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
foreignBalanceBefore = await mainPage.getForeignPOABalance();
|
console.log('foreignBalanceBefore = ' + foreignBalanceBefore)
|
||||||
console.log("foreignBalanceBefore = "+foreignBalanceBefore);
|
const result = foreignBalanceBefore === 0
|
||||||
let result = foreignBalanceBefore === 0;
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED.Foreign POA balance is zero or not displayed ");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED.Foreign POA balance is zero or not displayed '
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('Main page: home POA balance is displayed ',
|
test.it('Main page: home POA balance is displayed ', async () => {
|
||||||
async function () {
|
homeBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
homeBalanceBefore = await mainPage.getHomePOABalance();
|
console.log('homeBalanceBefore = ' + homeBalanceBefore)
|
||||||
console.log("homeBalanceBefore = "+homeBalanceBefore);
|
const result = homeBalanceBefore !== 0
|
||||||
let result = homeBalanceBefore !== 0;
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED.Home POA balance is zero or not displayed ");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED.Home POA balance is zero or not displayed '
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('User is able to send tokens from Home account to Foreign account ',
|
test.it('User is able to send tokens from Home account to Foreign account ', async () => {
|
||||||
async function () {
|
const result = await homeAccount.transferTokens(maxAmountPerTransactionLimit)
|
||||||
let result = await homeAccount.transferTokens(maxAmountPerTransactionLimit);
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED. User is able send tokens from Home account to Foreign account");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED. User is able send tokens from Home account to Foreign account'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('Home POA balance has correctly changed after transaction',
|
test.it('Home POA balance has correctly changed after transaction', async () => {
|
||||||
async function () {
|
const newHomeBalance = await mainPage.getHomePOABalance()
|
||||||
let newHomeBalance = await mainPage.getHomePOABalance();
|
const shouldBe = homeBalanceBefore - maxAmountPerTransactionLimit
|
||||||
let shouldBe = homeBalanceBefore - maxAmountPerTransactionLimit;
|
console.log('newHomeBalance = ' + newHomeBalance)
|
||||||
console.log("newHomeBalance = " + newHomeBalance);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
console.log("shouldBe = " + shouldBe);
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
let result = (Math.abs(shouldBe - newHomeBalance)) < (maxAmountPerTransactionLimit / 100);
|
homeBalanceBefore = newHomeBalance
|
||||||
homeBalanceBefore = newHomeBalance;
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED.Home POA balance is not correct after transaction");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('Foreign account has received correct amount of tokens after transaction ',
|
test.it('Foreign account has received correct amount of tokens after transaction ', async () => {
|
||||||
async function () {
|
const newForeignBalance = await mainPage.getForeignPOABalance()
|
||||||
let newForeignBalance = await mainPage.getForeignPOABalance();
|
|
||||||
|
|
||||||
let shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit;
|
const shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
console.log("shouldBe = " + shouldBe);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
|
|
||||||
let result = (Math.abs(shouldBe - newForeignBalance)) < (maxAmountPerTransactionLimit / 100);
|
const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100
|
||||||
return await assert.equal(result, true, "Test FAILED. Foreign POA balance is not correct after transaction");
|
return await assert.strictEqual(
|
||||||
});
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED. Foreign POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('User is able to send tokens from Foreign account to Home account ',
|
test.it('User is able to send tokens from Foreign account to Home account ', async () => {
|
||||||
async function () {
|
await foreignAccount.setMetaMaskNetwork()
|
||||||
await foreignAccount.setMetaMaskNetwork();
|
foreignBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
foreignBalanceBefore = await mainPage.getHomePOABalance();
|
const result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit)
|
||||||
let result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit);
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED. User is able send tokens from Home account to Foreign account");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED. User is able send tokens from Home account to Foreign account'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('Foreign POA balance has correctly changed after transaction',
|
test.it('Foreign POA balance has correctly changed after transaction', async () => {
|
||||||
async function () {
|
const newForeignBalance = await mainPage.getHomePOABalance()
|
||||||
let newForeignBalance = await mainPage.getHomePOABalance();
|
const shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit
|
||||||
let shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit;
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
console.log("shouldBe = " + shouldBe);
|
const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100
|
||||||
let result = (Math.abs(shouldBe - newForeignBalance)) < (maxAmountPerTransactionLimit / 100);
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED.Foreign POA balance is not correct after transaction");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED.Foreign POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('Home account has received correct amount of tokens after transaction ',
|
test.it('Home account has received correct amount of tokens after transaction ', async () => {
|
||||||
async function () {
|
const newHomeBalance = await mainPage.getForeignPOABalance()
|
||||||
let newHomeBalance = await mainPage.getForeignPOABalance();
|
const shouldBe = homeBalanceBefore + maxAmountPerTransactionLimit
|
||||||
let shouldBe = homeBalanceBefore + maxAmountPerTransactionLimit;
|
console.log('newHomeBalance = ' + newHomeBalance)
|
||||||
console.log("newHomeBalance = " + newHomeBalance);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
console.log("shouldBe = " + shouldBe);
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
let result = (Math.abs(shouldBe - newHomeBalance)) < (maxAmountPerTransactionLimit / 100);
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED.Home POA balance is not correct after transaction");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - User is able to open main page of bridge-ui ',
|
test.it('ERC20-ERC20 - User is able to open main page of bridge-ui ', async () => {
|
||||||
async function () {
|
startURL = await Utils.getErc20StartURL()
|
||||||
startURL = await Utils.getErc20StartURL();
|
const result = await mainPage.open(startURL)
|
||||||
let result = await mainPage.open(startURL);
|
console.log('Test URL: ' + startURL)
|
||||||
console.log("Test URL: " + startURL);
|
return await assert.strictEqual(result, true, 'Test FAILED. Build failed.')
|
||||||
return await assert.equal(result, true, "Test FAILED. Build failed.");
|
})
|
||||||
});
|
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - Home page: disclaimer is displayed ',
|
test.it('ERC20-ERC20 - Home page: disclaimer is displayed ', async () => {
|
||||||
async function () {
|
const result = await mainPage.confirmDisclaimer()
|
||||||
let result = await mainPage.confirmDisclaimer();
|
return await assert.strictEqual(result, true, 'Test FAILED. Disclaimer is not displayed')
|
||||||
return await assert.equal(result, true, "Test FAILED. Disclaimer is not displayed");
|
})
|
||||||
});
|
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - Main page: foreign erc20 balance is displayed ',
|
test.it('ERC20-ERC20 - Main page: foreign erc20 balance is displayed ', async () => {
|
||||||
async function () {
|
foreignBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
foreignBalanceBefore = await mainPage.getForeignPOABalance();
|
console.log('foreignBalanceBefore = ' + foreignBalanceBefore)
|
||||||
console.log("foreignBalanceBefore = "+foreignBalanceBefore);
|
const result = foreignBalanceBefore === 0
|
||||||
let result = foreignBalanceBefore === 0;
|
return await assert.strictEqual(result, true, 'Test FAILED. Foreign erc20 balance is not zero')
|
||||||
return await assert.equal(result, true, "Test FAILED. Foreign erc20 balance is not zero");
|
})
|
||||||
});
|
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - Main page: home erc20 balance is displayed ',
|
test.it('ERC20-ERC20 - Main page: home erc20 balance is displayed ', async () => {
|
||||||
async function () {
|
homeBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
homeBalanceBefore = await mainPage.getHomePOABalance();
|
console.log('homeBalanceBefore = ' + homeBalanceBefore)
|
||||||
console.log("homeBalanceBefore = "+homeBalanceBefore);
|
const result = homeBalanceBefore !== 0
|
||||||
let result = homeBalanceBefore !== 0;
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED. Home erc20 balance is zero or not displayed ");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED. Home erc20 balance is zero or not displayed '
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - User is able to send tokens from Foreign account to Home account ',
|
test.it(
|
||||||
async function () {
|
'ERC20-ERC20 - User is able to send tokens from Foreign account to Home account ',
|
||||||
homeBalanceBefore = await mainPage.getForeignPOABalance();
|
async () => {
|
||||||
foreignBalanceBefore = await mainPage.getHomePOABalance();
|
homeBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
let result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit);
|
foreignBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
return await assert.equal(result, true, "Test FAILED. User is able send tokens from Foreign account to Home account");
|
const result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit)
|
||||||
});
|
return await assert.strictEqual(
|
||||||
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED. User is able send tokens from Foreign account to Home account'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - Foreign POA balance has correctly changed after transaction',
|
test.it('ERC20-ERC20 - Foreign POA balance has correctly changed after transaction', async () => {
|
||||||
async function () {
|
const newForeignBalance = await mainPage.getHomePOABalance()
|
||||||
let newForeignBalance = await mainPage.getHomePOABalance();
|
const shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit
|
||||||
let shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit;
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
console.log("shouldBe = " + shouldBe);
|
const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100
|
||||||
let result = (Math.abs(shouldBe - newForeignBalance)) < (maxAmountPerTransactionLimit / 100);
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED.Foreign POA balance is not correct after transaction");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED.Foreign POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - Home account has received correct amount of tokens after transaction ',
|
test.it(
|
||||||
async function () {
|
'ERC20-ERC20 - Home account has received correct amount of tokens after transaction ',
|
||||||
let newHomeBalance = await mainPage.getForeignPOABalance();
|
async () => {
|
||||||
let shouldBe = homeBalanceBefore + maxAmountPerTransactionLimit;
|
const newHomeBalance = await mainPage.getForeignPOABalance()
|
||||||
console.log("newHomeBalance = " + newHomeBalance);
|
const shouldBe = homeBalanceBefore + maxAmountPerTransactionLimit
|
||||||
console.log("shouldBe = " + shouldBe);
|
console.log('newHomeBalance = ' + newHomeBalance)
|
||||||
let result = (Math.abs(shouldBe - newHomeBalance)) < (maxAmountPerTransactionLimit / 100);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
return await assert.equal(result, true, "Test FAILED.Home POA balance is not correct after transaction");
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
});
|
return await assert.strictEqual(
|
||||||
test.it('ERC20-ERC20 - User is able to send tokens from Home account to Foreign account ',
|
result,
|
||||||
async function () {
|
true,
|
||||||
await homeAccount.setMetaMaskNetwork();
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
homeBalanceBefore = await mainPage.getHomePOABalance();
|
)
|
||||||
foreignBalanceBefore = await mainPage.getForeignPOABalance();
|
}
|
||||||
let result = await homeAccount.transferTokens(maxAmountPerTransactionLimit);
|
)
|
||||||
return await assert.equal(result, true, "Test FAILED. User is able send tokens from Home account to Foreign account");
|
test.it(
|
||||||
});
|
'ERC20-ERC20 - User is able to send tokens from Home account to Foreign account ',
|
||||||
|
async () => {
|
||||||
|
await homeAccount.setMetaMaskNetwork()
|
||||||
|
homeBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
|
foreignBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
|
const result = await homeAccount.transferTokens(maxAmountPerTransactionLimit)
|
||||||
|
return await assert.strictEqual(
|
||||||
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED. User is able send tokens from Home account to Foreign account'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - Home POA balance has correctly changed after transaction',
|
test.it('ERC20-ERC20 - Home POA balance has correctly changed after transaction', async () => {
|
||||||
async function () {
|
const newHomeBalance = await mainPage.getHomePOABalance()
|
||||||
let newHomeBalance = await mainPage.getHomePOABalance();
|
const shouldBe = homeBalanceBefore - maxAmountPerTransactionLimit
|
||||||
let shouldBe = homeBalanceBefore - maxAmountPerTransactionLimit;
|
console.log('newHomeBalance = ' + newHomeBalance)
|
||||||
console.log("newHomeBalance = " + newHomeBalance);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
console.log("shouldBe = " + shouldBe);
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
let result = (Math.abs(shouldBe - newHomeBalance)) < (maxAmountPerTransactionLimit / 100);
|
homeBalanceBefore = newHomeBalance
|
||||||
homeBalanceBefore = newHomeBalance;
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED.Home POA balance is not correct after transaction");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - Foreign account has received correct amount of tokens after transaction ',
|
test.it(
|
||||||
async function () {
|
'ERC20-ERC20 - Foreign account has received correct amount of tokens after transaction ',
|
||||||
let newForeignBalance = await mainPage.getForeignPOABalance();
|
async () => {
|
||||||
|
const newForeignBalance = await mainPage.getForeignPOABalance()
|
||||||
|
|
||||||
let shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit;
|
const shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
console.log("shouldBe = " + shouldBe);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
|
|
||||||
let result = (Math.abs(shouldBe - newForeignBalance)) < (maxAmountPerTransactionLimit / 100);
|
const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100
|
||||||
return await assert.equal(result, true, "Test FAILED. Foreign POA balance is not correct after transaction");
|
return await assert.strictEqual(
|
||||||
});
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED. Foreign POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test.it('ERC20-Native - User is able to open main page of bridge-ui ',
|
test.it('ERC20-Native - User is able to open main page of bridge-ui ', async () => {
|
||||||
async function () {
|
startURL = await Utils.getErc20NativeStartURL()
|
||||||
startURL = await Utils.getErc20NativeStartURL();
|
const result = await mainPage.open(startURL)
|
||||||
let result = await mainPage.open(startURL);
|
console.log('Test URL: ' + startURL)
|
||||||
console.log("Test URL: " + startURL);
|
return await assert.strictEqual(result, true, 'Test FAILED. Build failed.')
|
||||||
return await assert.equal(result, true, "Test FAILED. Build failed.");
|
})
|
||||||
});
|
|
||||||
|
|
||||||
test.it('ERC20-Native - Home page: disclaimer is displayed ',
|
test.it('ERC20-Native - Home page: disclaimer is displayed ', async () => {
|
||||||
async function () {
|
const result = await mainPage.confirmDisclaimer()
|
||||||
let result = await mainPage.confirmDisclaimer();
|
return await assert.strictEqual(result, true, 'Test FAILED. Disclaimer is not displayed')
|
||||||
return await assert.equal(result, true, "Test FAILED. Disclaimer is not displayed");
|
})
|
||||||
});
|
|
||||||
|
|
||||||
test.it('ERC20-Native - Main page: foreign erc20 balance is displayed ',
|
test.it('ERC20-Native - Main page: foreign erc20 balance is displayed ', async () => {
|
||||||
async function () {
|
await foreignAccount.setMetaMaskNetwork()
|
||||||
await foreignAccount.setMetaMaskNetwork();
|
foreignBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
foreignBalanceBefore = await mainPage.getForeignPOABalance();
|
console.log('foreignBalanceBefore = ' + foreignBalanceBefore)
|
||||||
console.log("foreignBalanceBefore = "+foreignBalanceBefore);
|
const result = foreignBalanceBefore !== 0
|
||||||
let result = foreignBalanceBefore !== 0;
|
return await assert.strictEqual(result, true, 'Test FAILED. Foreign erc20 balance is zero')
|
||||||
return await assert.equal(result, true, "Test FAILED. Foreign erc20 balance is zero");
|
})
|
||||||
});
|
|
||||||
|
|
||||||
test.it('ERC20-Native - Main page: home erc20 balance is displayed ',
|
test.it('ERC20-Native - Main page: home erc20 balance is displayed ', async () => {
|
||||||
async function () {
|
homeBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
homeBalanceBefore = await mainPage.getHomePOABalance();
|
console.log('homeBalanceBefore = ' + homeBalanceBefore)
|
||||||
console.log("homeBalanceBefore = "+homeBalanceBefore);
|
const result = homeBalanceBefore !== 0
|
||||||
let result = homeBalanceBefore !== 0;
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED. Home erc20 balance is zero or not displayed ");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED. Home erc20 balance is zero or not displayed '
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-Native - User is able to send tokens from Foreign account to Home account ',
|
test.it(
|
||||||
async function () {
|
'ERC20-Native - User is able to send tokens from Foreign account to Home account ',
|
||||||
homeBalanceBefore = await mainPage.getForeignPOABalance();
|
async () => {
|
||||||
foreignBalanceBefore = await mainPage.getHomePOABalance();
|
homeBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
let result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit);
|
foreignBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
return await assert.equal(result, true, "Test FAILED. User is able send tokens from Foreign account to Home account");
|
const result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit)
|
||||||
});
|
return await assert.strictEqual(
|
||||||
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED. User is able send tokens from Foreign account to Home account'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test.it('ERC20-Native - Foreign POA balance has correctly changed after transaction',
|
test.it(
|
||||||
async function () {
|
'ERC20-Native - Foreign POA balance has correctly changed after transaction',
|
||||||
let newForeignBalance = await mainPage.getHomePOABalance();
|
async () => {
|
||||||
let shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit;
|
const newForeignBalance = await mainPage.getHomePOABalance()
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
const shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit
|
||||||
console.log("shouldBe = " + shouldBe);
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
let result = (Math.abs(shouldBe - newForeignBalance)) < (maxAmountPerTransactionLimit / 100);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
return await assert.equal(result, true, "Test FAILED.Foreign POA balance is not correct after transaction");
|
const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100
|
||||||
});
|
return await assert.strictEqual(
|
||||||
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED.Foreign POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test.it('ERC20-Native - Home account has received correct amount of tokens after transaction ',
|
test.it(
|
||||||
async function () {
|
'ERC20-Native - Home account has received correct amount of tokens after transaction ',
|
||||||
let newHomeBalance = await mainPage.getForeignPOABalance();
|
async () => {
|
||||||
let shouldBe = homeBalanceBefore + maxAmountPerTransactionLimit;
|
const newHomeBalance = await mainPage.getForeignPOABalance()
|
||||||
console.log("newHomeBalance = " + newHomeBalance);
|
const shouldBe = homeBalanceBefore + maxAmountPerTransactionLimit
|
||||||
console.log("shouldBe = " + shouldBe);
|
console.log('newHomeBalance = ' + newHomeBalance)
|
||||||
let result = (Math.abs(shouldBe - newHomeBalance)) < (maxAmountPerTransactionLimit / 100);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
return await assert.equal(result, true, "Test FAILED.Home POA balance is not correct after transaction");
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
});
|
return await assert.strictEqual(
|
||||||
test.it('ERC20-Native - User is able to send tokens from Home account to Foreign account ',
|
result,
|
||||||
async function () {
|
true,
|
||||||
await homeAccount.setMetaMaskNetwork();
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
homeBalanceBefore = await mainPage.getHomePOABalance();
|
)
|
||||||
foreignBalanceBefore = await mainPage.getForeignPOABalance();
|
}
|
||||||
let result = await homeAccount.transferTokens(maxAmountPerTransactionLimit);
|
)
|
||||||
return await assert.equal(result, true, "Test FAILED. User is able send tokens from Home account to Foreign account");
|
test.it(
|
||||||
});
|
'ERC20-Native - User is able to send tokens from Home account to Foreign account ',
|
||||||
|
async () => {
|
||||||
|
await homeAccount.setMetaMaskNetwork()
|
||||||
|
homeBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
|
foreignBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
|
const result = await homeAccount.transferTokens(maxAmountPerTransactionLimit)
|
||||||
|
return await assert.strictEqual(
|
||||||
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED. User is able send tokens from Home account to Foreign account'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test.it('ERC20-Native - Home POA balance has correctly changed after transaction',
|
test.it('ERC20-Native - Home POA balance has correctly changed after transaction', async () => {
|
||||||
async function () {
|
const newHomeBalance = await mainPage.getHomePOABalance()
|
||||||
let newHomeBalance = await mainPage.getHomePOABalance();
|
const shouldBe = homeBalanceBefore - maxAmountPerTransactionLimit
|
||||||
let shouldBe = homeBalanceBefore - maxAmountPerTransactionLimit;
|
console.log('newHomeBalance = ' + newHomeBalance)
|
||||||
console.log("newHomeBalance = " + newHomeBalance);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
console.log("shouldBe = " + shouldBe);
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
let result = (Math.abs(shouldBe - newHomeBalance)) < (maxAmountPerTransactionLimit / 100);
|
homeBalanceBefore = newHomeBalance
|
||||||
homeBalanceBefore = newHomeBalance;
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED.Home POA balance is not correct after transaction");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-Native - Foreign account has received correct amount of tokens after transaction ',
|
test.it(
|
||||||
async function () {
|
'ERC20-Native - Foreign account has received correct amount of tokens after transaction ',
|
||||||
let newForeignBalance = await mainPage.getForeignPOABalance();
|
async () => {
|
||||||
|
const newForeignBalance = await mainPage.getForeignPOABalance()
|
||||||
|
|
||||||
let shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit;
|
const shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
console.log("shouldBe = " + shouldBe);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
|
|
||||||
let result = (Math.abs(shouldBe - newForeignBalance)) < (maxAmountPerTransactionLimit / 100);
|
const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100
|
||||||
return await assert.equal(result, true, "Test FAILED. Foreign POA balance is not correct after transaction");
|
return await assert.strictEqual(
|
||||||
});
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED. Foreign POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user