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')
|
||||||
const {homeRPC, foreignRPC} = require('../e2e-commons/constants.json')
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
const IDMetaMask = "nkbihfbeogaeaoehlefnkodbefgpgknn";
|
const { By } = require('selenium-webdriver/lib/by')
|
||||||
const URL = "chrome-extension://" + IDMetaMask + "//popup.html";
|
const { Page } = require('./Page.js')
|
||||||
const buttonSubmit = By.className("confirm btn-green");
|
const { homeRPC, foreignRPC } = require('../e2e-commons/constants.json')
|
||||||
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) {
|
async initFieldsBalance() {
|
||||||
super(driver);
|
if (!(await this.waitUntilWeb3Loaded())) return null
|
||||||
this.url;
|
try {
|
||||||
this.fieldHomePOABalance;
|
const array = await super.findWithWait(fieldsBalance)
|
||||||
this.fieldForeignPOABalance;
|
/* eslint-disable prefer-destructuring */
|
||||||
}
|
this.fieldHomePOABalance = array[0]
|
||||||
|
this.fieldForeignPOABalance = array[1]
|
||||||
|
/* eslint-enable prefer-destructuring */
|
||||||
|
return array
|
||||||
|
} catch (err) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async initFieldsBalance() {
|
async getHomePOABalance() {
|
||||||
if (!(await this.waitUntilWeb3Loaded())) return null;
|
await this.initFieldsBalance()
|
||||||
try {
|
return parseFloat(await this.fieldHomePOABalance.getText())
|
||||||
let array;
|
}
|
||||||
array = await super.findWithWait(fieldsBalance);
|
|
||||||
this.fieldHomePOABalance = array[0];
|
|
||||||
this.fieldForeignPOABalance = array[1];
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async getHomePOABalance() {
|
async getForeignPOABalance() {
|
||||||
await this.initFieldsBalance();
|
await this.initFieldsBalance()
|
||||||
return parseFloat(await this.fieldHomePOABalance.getText());
|
return parseFloat(await this.fieldForeignPOABalance.getText())
|
||||||
}
|
}
|
||||||
|
|
||||||
async getForeignPOABalance() {
|
async fillFieldAmount(amount) {
|
||||||
await this.initFieldsBalance();
|
try {
|
||||||
return parseFloat(await this.fieldForeignPOABalance.getText());
|
await this.clickWithWait(fieldAmount)
|
||||||
}
|
await this.fillWithWait(fieldAmount, amount)
|
||||||
|
return true
|
||||||
|
} catch (err) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fillFieldAmount(amount) {
|
async clickButtonTransfer() {
|
||||||
try {
|
return this.clickWithWait(buttonTransfer)
|
||||||
await this.clickWithWait(fieldAmount);
|
}
|
||||||
await this.fillWithWait(fieldAmount, amount);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async clickButtonTransfer() {
|
async clickButtonOk() {
|
||||||
return await this.clickWithWait(buttonTransfer);
|
return super.clickWithWait(buttonOk)
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickButtonOk() {
|
async clickButtonTransferConfirm() {
|
||||||
return await super.clickWithWait(buttonOk);
|
return super.clickWithWait(buttonTransferConfirm)
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickButtonTransferConfirm() {
|
async isPresentButtonOk() {
|
||||||
return await super.clickWithWait(buttonTransferConfirm);
|
return super.isElementDisplayed(buttonOk, 180)
|
||||||
}
|
}
|
||||||
|
|
||||||
async isPresentButtonOk() {
|
async waitUntilWeb3Loaded() {
|
||||||
return await super.isElementDisplayed(buttonOk, 180);
|
return this.waitUntilLocated(classWeb3Loaded, 180)
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilWeb3Loaded() {
|
async isPendingTransaction() {
|
||||||
return await this.waitUntilLocated(classWeb3Loaded, 180);
|
return super.isElementLocated(classPendingTransaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
async isPendingTransaction() {
|
async waitUntilTransactionDone() {
|
||||||
return await super.isElementLocated(classPendingTransaction);
|
return this.waitUntilDisappear(classPendingTransaction, 360)
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilTransactionDone() {
|
async waitUntilShowUpButtonOk() {
|
||||||
return await this.waitUntilDisappear(classPendingTransaction, 360);
|
return super.waitUntilDisplayed(buttonOk, 360)
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilShowUpButtonOk() {
|
async waitUntilShowUpButtonTransferConfirm() {
|
||||||
return await super.waitUntilDisplayed(buttonOk, 360);
|
return super.waitUntilDisplayed(buttonTransferConfirm, 360)
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilShowUpButtonTransferConfirm() {
|
async waitUntilShowUpLoadingContainer() {
|
||||||
return await super.waitUntilDisplayed(buttonTransferConfirm, 360);
|
return super.waitUntilDisplayed(loadingContainer, 180)
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilShowUpButtonOk() {
|
async isDisplayedLoadingContainer() {
|
||||||
return await super.waitUntilDisplayed(buttonOk, 360);
|
return super.isElementDisplayed(loadingContainer)
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitUntilShowUpLoadingContainer() {
|
async confirmDisclaimer() {
|
||||||
return await super.waitUntilDisplayed(loadingContainer, 180);
|
return (
|
||||||
}
|
(await super.waitUntilDisplayed(disclaimer, 180)) &&
|
||||||
|
// await this.clickCheckboxDisclaimer() &&
|
||||||
|
(await this.clickButtonDisclaimerConfirm())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
async isDisplayedLoadingContainer() {
|
async clickButtonDisclaimerConfirm() {
|
||||||
return await super.isElementDisplayed(loadingContainer);
|
return super.clickWithWait(buttonDisclaimerConfirm)
|
||||||
}
|
}
|
||||||
|
|
||||||
async confirmDisclaimer() {
|
async clickCheckboxDisclaimer() {
|
||||||
return await super.waitUntilDisplayed(disclaimer, 180) &&
|
return super.clickWithWait(checkboxDisclaimer)
|
||||||
//await this.clickCheckboxDisclaimer() &&
|
}
|
||||||
await this.clickButtonDisclaimerConfirm();
|
|
||||||
}
|
|
||||||
|
|
||||||
async clickButtonDisclaimerConfirm() {
|
|
||||||
return await super.clickWithWait(buttonDisclaimerConfirm);
|
|
||||||
}
|
|
||||||
|
|
||||||
async clickCheckboxDisclaimer() {
|
|
||||||
return await super.clickWithWait(checkboxDisclaimer);
|
|
||||||
}
|
|
||||||
|
|
||||||
async open(url) {
|
|
||||||
let counter = 60;
|
|
||||||
do {
|
|
||||||
await this.driver.sleep(1000);
|
|
||||||
await super.open(url);
|
|
||||||
} while (counter-- >= 0 && !await this.isElementDisplayed(disclaimer))
|
|
||||||
return (counter >= 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
async open(url) {
|
||||||
|
let counter = 60
|
||||||
|
do {
|
||||||
|
await this.driver.sleep(1000)
|
||||||
|
await super.open(url)
|
||||||
|
} while (counter-- >= 0 && !(await this.isElementDisplayed(disclaimer)))
|
||||||
|
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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
625
ui-e2e/test.js
625
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 {
|
|
||||||
driver = await Utils.startBrowserWithMetamask();
|
|
||||||
mainPage = new MainPage(driver);
|
|
||||||
homeAccount = new User(driver, await Utils.getHomeAccount());
|
|
||||||
foreignAccount = new User(driver, await Utils.getForeignAccount());
|
|
||||||
metaMask = new MetaMask(driver);
|
|
||||||
await metaMask.activate();
|
|
||||||
await homeAccount.setMetaMaskAccount();
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test.after(async function () {
|
|
||||||
try {
|
try {
|
||||||
await driver.quit();
|
driver = await Utils.startBrowserWithMetamask()
|
||||||
|
mainPage = new MainPage(driver)
|
||||||
|
homeAccount = new User(driver, await Utils.getHomeAccount())
|
||||||
|
foreignAccount = new User(driver, await Utils.getForeignAccount())
|
||||||
|
metaMask = new MetaMask(driver)
|
||||||
|
await metaMask.activate()
|
||||||
|
await homeAccount.setMetaMaskAccount()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
test.it('User is able to open main page of bridge-ui ',
|
test.after(async () => {
|
||||||
async function () {
|
try {
|
||||||
startURL = await Utils.getStartURL();
|
await driver.quit()
|
||||||
let result = await mainPage.open(startURL);
|
} catch (e) {
|
||||||
console.log("Test URL: " + startURL);
|
console.log(e)
|
||||||
return await assert.equal(result, true, "Test FAILED. Build failed.");
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
test.it('Home page: disclaimer is displayed ',
|
test.it('User is able to open main page of bridge-ui ', async () => {
|
||||||
async function () {
|
startURL = await Utils.getStartURL()
|
||||||
let result = await mainPage.confirmDisclaimer();
|
const result = await mainPage.open(startURL)
|
||||||
return await assert.equal(result, true, "Test FAILED. Disclaimer is not displayed");
|
console.log('Test URL: ' + startURL)
|
||||||
});
|
return await assert.strictEqual(result, true, 'Test FAILED. Build failed.')
|
||||||
|
})
|
||||||
|
|
||||||
test.it('Main page: foreign POA balance is displayed ',
|
test.it('Home page: disclaimer is displayed ', async () => {
|
||||||
async function () {
|
const result = await mainPage.confirmDisclaimer()
|
||||||
foreignBalanceBefore = await mainPage.getForeignPOABalance();
|
return await assert.strictEqual(result, true, 'Test FAILED. Disclaimer is not displayed')
|
||||||
console.log("foreignBalanceBefore = "+foreignBalanceBefore);
|
})
|
||||||
let result = foreignBalanceBefore === 0;
|
|
||||||
return await assert.equal(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: foreign POA balance is displayed ', async () => {
|
||||||
async function () {
|
foreignBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
homeBalanceBefore = await mainPage.getHomePOABalance();
|
console.log('foreignBalanceBefore = ' + foreignBalanceBefore)
|
||||||
console.log("homeBalanceBefore = "+homeBalanceBefore);
|
const result = foreignBalanceBefore === 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.Foreign POA balance is zero or not displayed '
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('User is able to send tokens from Home account to Foreign account ',
|
test.it('Main page: home POA balance is displayed ', async () => {
|
||||||
async function () {
|
homeBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
let result = await homeAccount.transferTokens(maxAmountPerTransactionLimit);
|
console.log('homeBalanceBefore = ' + homeBalanceBefore)
|
||||||
return await assert.equal(result, true, "Test FAILED. User is able send tokens from Home account to Foreign account");
|
const result = homeBalanceBefore !== 0
|
||||||
});
|
return await assert.strictEqual(
|
||||||
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED.Home POA balance is zero or not displayed '
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('Home POA balance has correctly changed after transaction',
|
test.it('User is able to send tokens from Home account to Foreign account ', async () => {
|
||||||
async function () {
|
const result = await homeAccount.transferTokens(maxAmountPerTransactionLimit)
|
||||||
let newHomeBalance = await mainPage.getHomePOABalance();
|
return await assert.strictEqual(
|
||||||
let shouldBe = homeBalanceBefore - maxAmountPerTransactionLimit;
|
result,
|
||||||
console.log("newHomeBalance = " + newHomeBalance);
|
true,
|
||||||
console.log("shouldBe = " + shouldBe);
|
'Test FAILED. User is able send tokens from Home account to Foreign account'
|
||||||
let result = (Math.abs(shouldBe - newHomeBalance)) < (maxAmountPerTransactionLimit / 100);
|
)
|
||||||
homeBalanceBefore = newHomeBalance;
|
})
|
||||||
return await assert.equal(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('Home POA balance has correctly changed after transaction', async () => {
|
||||||
async function () {
|
const newHomeBalance = await mainPage.getHomePOABalance()
|
||||||
let newForeignBalance = await mainPage.getForeignPOABalance();
|
const shouldBe = homeBalanceBefore - maxAmountPerTransactionLimit
|
||||||
|
console.log('newHomeBalance = ' + newHomeBalance)
|
||||||
|
console.log('shouldBe = ' + shouldBe)
|
||||||
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
|
homeBalanceBefore = newHomeBalance
|
||||||
|
return await assert.strictEqual(
|
||||||
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
let shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit;
|
test.it('Foreign account has received correct amount of tokens after transaction ', async () => {
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
const newForeignBalance = await mainPage.getForeignPOABalance()
|
||||||
console.log("shouldBe = " + shouldBe);
|
|
||||||
|
|
||||||
let result = (Math.abs(shouldBe - newForeignBalance)) < (maxAmountPerTransactionLimit / 100);
|
const shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit
|
||||||
return await assert.equal(result, true, "Test FAILED. Foreign POA balance is not correct after transaction");
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
});
|
console.log('shouldBe = ' + shouldBe)
|
||||||
|
|
||||||
test.it('User is able to send tokens from Foreign account to Home account ',
|
const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100
|
||||||
async function () {
|
return await assert.strictEqual(
|
||||||
await foreignAccount.setMetaMaskNetwork();
|
result,
|
||||||
foreignBalanceBefore = await mainPage.getHomePOABalance();
|
true,
|
||||||
let result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit);
|
'Test FAILED. Foreign POA balance is not correct after transaction'
|
||||||
return await assert.equal(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('User is able to send tokens from Foreign account to Home account ', async () => {
|
||||||
async function () {
|
await foreignAccount.setMetaMaskNetwork()
|
||||||
let newForeignBalance = await mainPage.getHomePOABalance();
|
foreignBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
let shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit;
|
const result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit)
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
return await assert.strictEqual(
|
||||||
console.log("shouldBe = " + shouldBe);
|
result,
|
||||||
let result = (Math.abs(shouldBe - newForeignBalance)) < (maxAmountPerTransactionLimit / 100);
|
true,
|
||||||
return await assert.equal(result, true, "Test FAILED.Foreign POA balance is not correct after transaction");
|
'Test FAILED. User is able send tokens from Home account to Foreign account'
|
||||||
});
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('Home account has received correct amount of tokens after transaction ',
|
test.it('Foreign POA balance has correctly changed after transaction', async () => {
|
||||||
async function () {
|
const newForeignBalance = await mainPage.getHomePOABalance()
|
||||||
let newHomeBalance = await mainPage.getForeignPOABalance();
|
const shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit
|
||||||
let shouldBe = homeBalanceBefore + maxAmountPerTransactionLimit;
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
console.log("newHomeBalance = " + newHomeBalance);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
console.log("shouldBe = " + shouldBe);
|
const result = Math.abs(shouldBe - newForeignBalance) < 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.Foreign POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - User is able to open main page of bridge-ui ',
|
test.it('Home account has received correct amount of tokens after transaction ', async () => {
|
||||||
async function () {
|
const newHomeBalance = await mainPage.getForeignPOABalance()
|
||||||
startURL = await Utils.getErc20StartURL();
|
const shouldBe = homeBalanceBefore + maxAmountPerTransactionLimit
|
||||||
let result = await mainPage.open(startURL);
|
console.log('newHomeBalance = ' + newHomeBalance)
|
||||||
console.log("Test URL: " + startURL);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
return await assert.equal(result, true, "Test FAILED. Build failed.");
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
});
|
return await assert.strictEqual(
|
||||||
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - Home page: disclaimer is displayed ',
|
test.it('ERC20-ERC20 - User is able to open main page of bridge-ui ', async () => {
|
||||||
async function () {
|
startURL = await Utils.getErc20StartURL()
|
||||||
let result = await mainPage.confirmDisclaimer();
|
const result = await mainPage.open(startURL)
|
||||||
return await assert.equal(result, true, "Test FAILED. Disclaimer is not displayed");
|
console.log('Test URL: ' + startURL)
|
||||||
});
|
return await assert.strictEqual(result, true, 'Test FAILED. Build failed.')
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - Main page: foreign erc20 balance is displayed ',
|
test.it('ERC20-ERC20 - Home page: disclaimer is displayed ', async () => {
|
||||||
async function () {
|
const result = await mainPage.confirmDisclaimer()
|
||||||
foreignBalanceBefore = await mainPage.getForeignPOABalance();
|
return await assert.strictEqual(result, true, 'Test FAILED. Disclaimer is not displayed')
|
||||||
console.log("foreignBalanceBefore = "+foreignBalanceBefore);
|
})
|
||||||
let result = foreignBalanceBefore === 0;
|
|
||||||
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: foreign erc20 balance is displayed ', async () => {
|
||||||
async function () {
|
foreignBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
homeBalanceBefore = await mainPage.getHomePOABalance();
|
console.log('foreignBalanceBefore = ' + foreignBalanceBefore)
|
||||||
console.log("homeBalanceBefore = "+homeBalanceBefore);
|
const result = foreignBalanceBefore === 0
|
||||||
let result = homeBalanceBefore !== 0;
|
return await assert.strictEqual(result, true, 'Test FAILED. Foreign erc20 balance is not zero')
|
||||||
return await assert.equal(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('ERC20-ERC20 - Main page: home erc20 balance is displayed ', async () => {
|
||||||
async function () {
|
homeBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
homeBalanceBefore = await mainPage.getForeignPOABalance();
|
console.log('homeBalanceBefore = ' + homeBalanceBefore)
|
||||||
foreignBalanceBefore = await mainPage.getHomePOABalance();
|
const result = homeBalanceBefore !== 0
|
||||||
let result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit);
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED. User is able send tokens from Foreign account to Home account");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED. Home erc20 balance is zero or not displayed '
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - Foreign POA balance has correctly changed after transaction',
|
test.it(
|
||||||
async function () {
|
'ERC20-ERC20 - User is able to send tokens from Foreign account to Home account ',
|
||||||
let newForeignBalance = await mainPage.getHomePOABalance();
|
async () => {
|
||||||
let shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit;
|
homeBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
foreignBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
console.log("shouldBe = " + shouldBe);
|
const result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit)
|
||||||
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. User is able send tokens from Foreign account to Home account'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test.it('ERC20-ERC20 - Home account has received correct amount of tokens after transaction ',
|
test.it('ERC20-ERC20 - Foreign POA balance has correctly changed after transaction', async () => {
|
||||||
async function () {
|
const newForeignBalance = await mainPage.getHomePOABalance()
|
||||||
let newHomeBalance = await mainPage.getForeignPOABalance();
|
const shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit
|
||||||
let shouldBe = homeBalanceBefore + maxAmountPerTransactionLimit;
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
console.log("newHomeBalance = " + newHomeBalance);
|
console.log('shouldBe = ' + shouldBe)
|
||||||
console.log("shouldBe = " + shouldBe);
|
const result = Math.abs(shouldBe - newForeignBalance) < 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.it('ERC20-ERC20 - User is able to send tokens from Home account to Foreign account ',
|
'Test FAILED.Foreign POA balance is not correct after transaction'
|
||||||
async function () {
|
)
|
||||||
await homeAccount.setMetaMaskNetwork();
|
})
|
||||||
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 - Home POA balance has correctly changed after transaction',
|
test.it(
|
||||||
async function () {
|
'ERC20-ERC20 - Home account has received correct amount of tokens after transaction ',
|
||||||
let newHomeBalance = await mainPage.getHomePOABalance();
|
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)
|
||||||
homeBalanceBefore = newHomeBalance;
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
return await assert.equal(result, true, "Test FAILED.Home POA balance is not correct after transaction");
|
return await assert.strictEqual(
|
||||||
});
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
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 - Foreign account has received correct amount of tokens after transaction ',
|
test.it('ERC20-ERC20 - Home POA balance has correctly changed after transaction', async () => {
|
||||||
async function () {
|
const newHomeBalance = await mainPage.getHomePOABalance()
|
||||||
let newForeignBalance = await mainPage.getForeignPOABalance();
|
const shouldBe = homeBalanceBefore - maxAmountPerTransactionLimit
|
||||||
|
console.log('newHomeBalance = ' + newHomeBalance)
|
||||||
|
console.log('shouldBe = ' + shouldBe)
|
||||||
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
|
homeBalanceBefore = newHomeBalance
|
||||||
|
return await assert.strictEqual(
|
||||||
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
let shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit;
|
test.it(
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
'ERC20-ERC20 - Foreign account has received correct amount of tokens after transaction ',
|
||||||
console.log("shouldBe = " + shouldBe);
|
async () => {
|
||||||
|
const newForeignBalance = await mainPage.getForeignPOABalance()
|
||||||
|
|
||||||
let result = (Math.abs(shouldBe - newForeignBalance)) < (maxAmountPerTransactionLimit / 100);
|
const shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit
|
||||||
return await assert.equal(result, true, "Test FAILED. Foreign POA balance is not correct after transaction");
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
});
|
console.log('shouldBe = ' + shouldBe)
|
||||||
|
|
||||||
test.it('ERC20-Native - User is able to open main page of bridge-ui ',
|
const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100
|
||||||
async function () {
|
return await assert.strictEqual(
|
||||||
startURL = await Utils.getErc20NativeStartURL();
|
result,
|
||||||
let result = await mainPage.open(startURL);
|
true,
|
||||||
console.log("Test URL: " + startURL);
|
'Test FAILED. Foreign POA balance is not correct after transaction'
|
||||||
return await assert.equal(result, true, "Test FAILED. Build failed.");
|
)
|
||||||
});
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test.it('ERC20-Native - Home page: disclaimer is displayed ',
|
test.it('ERC20-Native - User is able to open main page of bridge-ui ', async () => {
|
||||||
async function () {
|
startURL = await Utils.getErc20NativeStartURL()
|
||||||
let result = await mainPage.confirmDisclaimer();
|
const result = await mainPage.open(startURL)
|
||||||
return await assert.equal(result, true, "Test FAILED. Disclaimer is not displayed");
|
console.log('Test URL: ' + startURL)
|
||||||
});
|
return await assert.strictEqual(result, true, 'Test FAILED. Build failed.')
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-Native - Main page: foreign erc20 balance is displayed ',
|
test.it('ERC20-Native - Home page: disclaimer is displayed ', async () => {
|
||||||
async function () {
|
const result = await mainPage.confirmDisclaimer()
|
||||||
await foreignAccount.setMetaMaskNetwork();
|
return await assert.strictEqual(result, true, 'Test FAILED. Disclaimer is not displayed')
|
||||||
foreignBalanceBefore = await mainPage.getForeignPOABalance();
|
})
|
||||||
console.log("foreignBalanceBefore = "+foreignBalanceBefore);
|
|
||||||
let result = foreignBalanceBefore !== 0;
|
|
||||||
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: foreign erc20 balance is displayed ', async () => {
|
||||||
async function () {
|
await foreignAccount.setMetaMaskNetwork()
|
||||||
homeBalanceBefore = await mainPage.getHomePOABalance();
|
foreignBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
console.log("homeBalanceBefore = "+homeBalanceBefore);
|
console.log('foreignBalanceBefore = ' + foreignBalanceBefore)
|
||||||
let result = homeBalanceBefore !== 0;
|
const result = foreignBalanceBefore !== 0
|
||||||
return await assert.equal(result, true, "Test FAILED. Home erc20 balance is zero or not displayed ");
|
return await assert.strictEqual(result, true, 'Test FAILED. Foreign erc20 balance is zero')
|
||||||
});
|
})
|
||||||
|
|
||||||
test.it('ERC20-Native - User is able to send tokens from Foreign account to Home account ',
|
test.it('ERC20-Native - Main page: home erc20 balance is displayed ', async () => {
|
||||||
async function () {
|
homeBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
homeBalanceBefore = await mainPage.getForeignPOABalance();
|
console.log('homeBalanceBefore = ' + homeBalanceBefore)
|
||||||
foreignBalanceBefore = await mainPage.getHomePOABalance();
|
const result = homeBalanceBefore !== 0
|
||||||
let result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit);
|
return await assert.strictEqual(
|
||||||
return await assert.equal(result, true, "Test FAILED. User is able send tokens from Foreign account to Home account");
|
result,
|
||||||
});
|
true,
|
||||||
|
'Test FAILED. Home erc20 balance is zero or not displayed '
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
test.it('ERC20-Native - Foreign POA balance has correctly changed after transaction',
|
test.it(
|
||||||
async function () {
|
'ERC20-Native - User is able to send tokens from Foreign account to Home account ',
|
||||||
let newForeignBalance = await mainPage.getHomePOABalance();
|
async () => {
|
||||||
let shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit;
|
homeBalanceBefore = await mainPage.getForeignPOABalance()
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
foreignBalanceBefore = await mainPage.getHomePOABalance()
|
||||||
console.log("shouldBe = " + shouldBe);
|
const result = await foreignAccount.transferTokens(maxAmountPerTransactionLimit)
|
||||||
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. User is able send tokens from Foreign account to Home account'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test.it('ERC20-Native - Home account has received correct amount of tokens after transaction ',
|
test.it(
|
||||||
async function () {
|
'ERC20-Native - Foreign POA balance has correctly changed after transaction',
|
||||||
let newHomeBalance = await mainPage.getForeignPOABalance();
|
async () => {
|
||||||
let shouldBe = homeBalanceBefore + maxAmountPerTransactionLimit;
|
const newForeignBalance = await mainPage.getHomePOABalance()
|
||||||
console.log("newHomeBalance = " + newHomeBalance);
|
const shouldBe = foreignBalanceBefore - maxAmountPerTransactionLimit
|
||||||
console.log("shouldBe = " + shouldBe);
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
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 - newForeignBalance) < 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.Foreign 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 - Home POA balance has correctly changed after transaction',
|
test.it(
|
||||||
async function () {
|
'ERC20-Native - Home account has received correct amount of tokens after transaction ',
|
||||||
let newHomeBalance = await mainPage.getHomePOABalance();
|
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)
|
||||||
homeBalanceBefore = newHomeBalance;
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
return await assert.equal(result, true, "Test FAILED.Home POA balance is not correct after transaction");
|
return await assert.strictEqual(
|
||||||
});
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
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 - Foreign account has received correct amount of tokens after transaction ',
|
test.it('ERC20-Native - Home POA balance has correctly changed after transaction', async () => {
|
||||||
async function () {
|
const newHomeBalance = await mainPage.getHomePOABalance()
|
||||||
let newForeignBalance = await mainPage.getForeignPOABalance();
|
const shouldBe = homeBalanceBefore - maxAmountPerTransactionLimit
|
||||||
|
console.log('newHomeBalance = ' + newHomeBalance)
|
||||||
|
console.log('shouldBe = ' + shouldBe)
|
||||||
|
const result = Math.abs(shouldBe - newHomeBalance) < maxAmountPerTransactionLimit / 100
|
||||||
|
homeBalanceBefore = newHomeBalance
|
||||||
|
return await assert.strictEqual(
|
||||||
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED.Home POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
let shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit;
|
test.it(
|
||||||
console.log("newForeignBalance = " + newForeignBalance);
|
'ERC20-Native - Foreign account has received correct amount of tokens after transaction ',
|
||||||
console.log("shouldBe = " + shouldBe);
|
async () => {
|
||||||
|
const newForeignBalance = await mainPage.getForeignPOABalance()
|
||||||
|
|
||||||
let result = (Math.abs(shouldBe - newForeignBalance)) < (maxAmountPerTransactionLimit / 100);
|
const shouldBe = foreignBalanceBefore + maxAmountPerTransactionLimit
|
||||||
return await assert.equal(result, true, "Test FAILED. Foreign POA balance is not correct after transaction");
|
console.log('newForeignBalance = ' + newForeignBalance)
|
||||||
});
|
console.log('shouldBe = ' + shouldBe)
|
||||||
});
|
|
||||||
|
const result = Math.abs(shouldBe - newForeignBalance) < maxAmountPerTransactionLimit / 100
|
||||||
|
return await assert.strictEqual(
|
||||||
|
result,
|
||||||
|
true,
|
||||||
|
'Test FAILED. Foreign POA balance is not correct after transaction'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user