Governance tests
This commit is contained in:
parent
79fd03f3aa
commit
6f377f3069
|
@ -2,10 +2,12 @@ const fs = require('fs');
|
|||
const utils = require("./utils/utils");
|
||||
const Constants = require("./utils/constants");
|
||||
const constants = Constants.constants;
|
||||
const { generateAddress } = require("./utils/utils");
|
||||
const dir = require('node-dir');
|
||||
const path = require('path');
|
||||
let faker = require('faker/locale/en');
|
||||
let moment = require('moment');
|
||||
const generatePassword = require('password-generator');
|
||||
const webdriver = require('selenium-webdriver'),
|
||||
chrome = require('selenium-webdriver/chrome');
|
||||
require("chromedriver");
|
||||
|
@ -20,6 +22,9 @@ const timeout = ms => new Promise(res => setTimeout(res, ms))
|
|||
|
||||
const votingURL = 'http://localhost:3002'
|
||||
|
||||
let validatorMetaData;
|
||||
let newMiningKey;
|
||||
|
||||
let args = process.argv.slice(2);
|
||||
let validator_num = args[0];
|
||||
|
||||
|
@ -54,62 +59,77 @@ async function main() {
|
|||
|
||||
votingPage.open();
|
||||
|
||||
driver.sleep(6000);
|
||||
driver.sleep(4000);
|
||||
|
||||
votingPage.clickNewBallot();
|
||||
|
||||
driver.sleep(4000);
|
||||
driver.sleep(3000);
|
||||
|
||||
votingPage.chooseKeysVotingType();
|
||||
|
||||
driver.sleep(2000);
|
||||
driver.sleep(1000);
|
||||
|
||||
votingPage.chooseAddKeyVotingType();
|
||||
votingPage.chooseMiningKeyType();
|
||||
|
||||
let validatorMetaData = generateValidatorMetadata();
|
||||
validatorMetaData = generateValidatorMetadata();
|
||||
|
||||
votingPage.fillFullName(validatorMetaData.full_name);
|
||||
votingPage.fillAddress(validatorMetaData.address);
|
||||
votingPage.fillState(validatorMetaData.us_state);
|
||||
votingPage.fillZipCode(validatorMetaData.zip_code);
|
||||
votingPage.fillLicenseID(validatorMetaData.license_id);
|
||||
votingPage.fillLicenseExpiration(validatorMetaData.license_expiration);
|
||||
votingPage.fillState(validatorMetaData.us_state);
|
||||
|
||||
let votingMetaData = generateBallotMetadata();
|
||||
|
||||
driver.sleep(2000);
|
||||
driver.sleep(1000);
|
||||
|
||||
/*votingPage.clickSetMetadataButton();
|
||||
votingPage.fillDescription(votingMetaData.description);
|
||||
//votingPage.fillEndTime(votingMetaData.endTime);
|
||||
votingPage.fillAffectedKey(votingMetaData.affectedKey);
|
||||
votingPage.fillNewMiningKey();
|
||||
|
||||
driver.sleep(2000);
|
||||
|
||||
metaMask.switchToAnotherPage();
|
||||
driver.sleep(3000);
|
||||
metaMask.refresh();
|
||||
driver.sleep(2000);
|
||||
let el = await metaMask.isElementPresent(buttonSubmit.buttonSubmit)
|
||||
if (el) {
|
||||
confirmTx(el)
|
||||
} else {
|
||||
console.log("Something went wrong. Let's try once more...")
|
||||
votingPage.addBallot();
|
||||
|
||||
metamaskInteraction();
|
||||
|
||||
driver.sleep(1000);
|
||||
|
||||
votingPage.clickAlertOKButton();
|
||||
|
||||
driver.sleep(60000);
|
||||
|
||||
votingPage.vote();
|
||||
|
||||
driver.sleep(60000);
|
||||
|
||||
votingPage.finalize();
|
||||
|
||||
async function metamaskInteraction() {
|
||||
driver.sleep(2000);
|
||||
|
||||
metaMask.switchToAnotherPage();
|
||||
driver.sleep(3000);
|
||||
metaMask.refresh();
|
||||
driver.sleep(2000);
|
||||
let el = await metaMask.isElementPresent(buttonSubmit.buttonSubmit)
|
||||
confirmTx(el)
|
||||
if (el) {
|
||||
confirmTx(el)
|
||||
} else {
|
||||
console.log("Something went wrong. Let's try once more...")
|
||||
driver.sleep(2000);
|
||||
let el = await metaMask.isElementPresent(buttonSubmit.buttonSubmit)
|
||||
confirmTx(el)
|
||||
}
|
||||
}
|
||||
|
||||
async function confirmTx(el) {
|
||||
metaMask.submitTransaction();
|
||||
votingPage.switchToAnotherPage();
|
||||
|
||||
driver.sleep(5000);
|
||||
|
||||
let handles = await driver.getAllWindowHandles();
|
||||
for (let i = 0; i < handles.length; i++) {
|
||||
driver.switchTo().window(handles[i]);
|
||||
driver.close();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
function generateValidatorMetadata() {
|
||||
|
@ -128,7 +148,14 @@ function generateValidatorMetadata() {
|
|||
|
||||
function generateBallotMetadata() {
|
||||
const ballotMetaData = {
|
||||
|
||||
description: `Add new validator ${validatorMetaData.full_name}
|
||||
address: ${validatorMetaData.address}
|
||||
us_state: ${validatorMetaData.us_state}
|
||||
zip_code: ${validatorMetaData.zip_code}
|
||||
license_id: ${validatorMetaData.license_id}
|
||||
license_expiration: ${validatorMetaData.license_expiration}`,
|
||||
//endTime: (new Date()).toISOString(),//moment(new Date(faker.date.future())).format('DD/MM/YYYY'),//moment().add('1', 'minute').format('DD/MM/YYYY'),//.format('DD/MM/YYYY, HH:mm'),
|
||||
affectedKey: "0x29EFc7C1d7c12b5641DF2011e17A7A8cE19cc949"
|
||||
};
|
||||
|
||||
return ballotMetaData;
|
||||
|
|
|
@ -5,17 +5,31 @@ const webdriver = require('selenium-webdriver'),
|
|||
by = require('selenium-webdriver/lib/by');
|
||||
|
||||
const newBallotButton = by.By.xpath("//*[@id=\"root\"]/div/header/div/a[2]");
|
||||
const keysBallotType = by.By.xpath("//*[@id=\"ballot-for-validators\"]");
|
||||
const addKeyType = by.By.xpath("//*[@id=\"add-key\"]");
|
||||
const miningKeyType = by.By.xpath("//*[@id=\"mining-key\"]");
|
||||
const keysBallotType = by.By.xpath("//*[@id=\"root\"]/div/section/form/div[1]/div[1]/div/label");
|
||||
const addKeyType = by.By.xpath("//*[@id=\"root\"]/div/section/form/div[2]/div[1]/div[1]/label");
|
||||
const miningKeyType = by.By.xpath("//*[@id=\"root\"]/div/section/form/div[2]/div[2]/div[1]/label");
|
||||
|
||||
//validator data
|
||||
const fullNameInput = by.By.xpath("//*[@id=\"full-name\"]");
|
||||
const addrInput = by.By.xpath("//*[@id=\"address\"]");
|
||||
const stateInput = by.By.xpath("//*[@id=\"us_state\"]");
|
||||
const stateInput = by.By.xpath("//*[@id=\"react-select-3--value\"]/div[1]");
|
||||
const stateCaliforniaInput = by.By.xpath("//*[@id=\"react-select-3--option-5\"]");
|
||||
const zipCodeInput = by.By.xpath("//*[@id=\"zip-code\"]");
|
||||
const licenseIdInput = by.By.xpath("//*[@id=\"license-id\"]");
|
||||
const licenseExpirationInput = by.By.xpath("//*[@id=\"license-expiration\"]");
|
||||
|
||||
//voting data
|
||||
const descriptionInput = by.By.xpath("//*[@id=\"root\"]/div/section/form/div[5]/div/textarea");
|
||||
const endTimeInput = by.By.xpath("//*[@id=\"datetime-local\"]");
|
||||
const affectedKeyInput = by.By.xpath("//*[@id=\"key\"]");
|
||||
const miningKeyInput = by.By.xpath("//*[@id=\"root\"]/div/section/form/div[4]/div/div[2]/div/div/div");
|
||||
const newMiningKeyXpath = by.By.xpath("//*[@id=\"react-select-2--option-0\"]");
|
||||
|
||||
const addBallotButton = by.By.xpath("//*[@id=\"root\"]/div/section/form/div[6]/button");
|
||||
const alertOKButton = by.By.xpath("/html/body/div[2]/div/div[10]/button[1]");
|
||||
const yesButton = by.By.xpath("//*[@id=\"root\"]/div/section/div[1]/div[2]/div[2]/button");
|
||||
const finalizeButton = by.By.xpath("//*[@id=\"root\"]/div/section/div[3]/div[5]/div[1]/button");
|
||||
|
||||
class Voting extends page.Page {
|
||||
constructor(driver,URL){
|
||||
super(driver);
|
||||
|
@ -51,7 +65,9 @@ class Voting extends page.Page {
|
|||
}
|
||||
|
||||
fillState(state) {
|
||||
super.fillWithWait(stateInput, state);
|
||||
super.clickWithWait(stateInput);
|
||||
this.driver.sleep(100);
|
||||
super.clickWithWait(stateCaliforniaInput);
|
||||
}
|
||||
|
||||
fillZipCode(zip_code) {
|
||||
|
@ -65,6 +81,40 @@ class Voting extends page.Page {
|
|||
fillLicenseExpiration(license_expiration) {
|
||||
super.fillWithWait(licenseExpirationInput, license_expiration);
|
||||
}
|
||||
|
||||
fillDescription(description) {
|
||||
super.fillWithWait(descriptionInput, description);
|
||||
}
|
||||
|
||||
fillEndTime(endTime) {
|
||||
super.fillWithWait(endTimeInput, endTime);
|
||||
}
|
||||
|
||||
fillAffectedKey(affectedKey) {
|
||||
super.fillWithWait(affectedKeyInput, affectedKey);
|
||||
}
|
||||
|
||||
fillNewMiningKey() {
|
||||
super.clickWithWait(miningKeyInput);
|
||||
this.driver.sleep(100);
|
||||
super.clickWithWait(newMiningKeyXpath);
|
||||
}
|
||||
|
||||
addBallot() {
|
||||
super.clickWithWait(addBallotButton);
|
||||
}
|
||||
|
||||
clickAlertOKButton() {
|
||||
super.clickWithWait(alertOKButton);
|
||||
}
|
||||
|
||||
vote() {
|
||||
super.clickWithWait(yesButton);
|
||||
}
|
||||
|
||||
finalize() {
|
||||
super.clickWithWait(finalizeButton);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.Voting = Voting;
|
|
@ -1,7 +1,6 @@
|
|||
const Constants = require("./utils/constants");
|
||||
const constants = Constants.constants;
|
||||
const fs = require('fs');
|
||||
const keythereum = require("keythereum");
|
||||
const generatePassword = require('password-generator');
|
||||
const utils = require("./utils/utils");
|
||||
const toml = require('toml');
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit cae073eaf884781a9bf244c2da23c4d6ac17e325
|
||||
Subproject commit 2e7c274735376a49417c7c21783494574d00f1be
|
|
@ -65,10 +65,24 @@ function saveToFile(filename, content) {
|
|||
});
|
||||
}
|
||||
|
||||
function generateAddress(password) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let params = { keyBytes: 32, ivBytes: 16 };
|
||||
|
||||
keythereum.create(params, function (dk) {
|
||||
let options = {};
|
||||
keythereum.dump(password, dk.privateKey, dk.salt, dk.iv, options, function (keyObject) {
|
||||
resolve(keyObject);
|
||||
});
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getSpec,
|
||||
getABI,
|
||||
clearFolder,
|
||||
removeFolderRecursive,
|
||||
saveToFile
|
||||
saveToFile,
|
||||
generateAddress
|
||||
}
|
Loading…
Reference in New Issue