tests whitelist Dutch

This commit is contained in:
dennis00010011b 2018-05-29 23:32:41 -07:00
parent 851db03530
commit 675530c0d2
10 changed files with 455 additions and 85 deletions

View File

@ -12,7 +12,7 @@ class Crowdsale {
this.reservedTokens = [];
this.gasPrice;
this.minCap;
this.whitelisting;
this.tiers = [];
this.tokenAddress;
this.contractAddress;

View File

@ -18,8 +18,8 @@ class DutchAuction extends Crowdsale {
this.totalSupply = obj.totalSupply;
this.walletAddress = obj.walletAddress;
this.gasPrice = obj.gasprice;
this.whitelisting = obj.whitelisting;
this.tiers = obj.tiers;
this.minCap = obj.mincap;
}
print() {
@ -30,8 +30,10 @@ class DutchAuction extends Crowdsale {
logger.info("totalSupply :" + this.totalSupply);
logger.info("walletAddress :" + this.walletAddress);
logger.info("gasPrice :" + this.gasPrice);
logger.info("whitelisting :" + this.whitelisting);
logger.info("mincap :" + this.minCap);
for (let i = 0; i < this.tiers.length; i++) {
logger.info("isWhitelisted #:" + i + this.tiers[i].isWhitelisted);
logger.info("startDate #" + i + ": " + this.tiers[i].startDate);
logger.info("startTime #" + i + ": " + this.tiers[i].startTime);
logger.info("endDate #" + i + ": " + this.tiers[i].endDate);

View File

@ -372,7 +372,7 @@ class User {
async createDutchAuctionCrowdsale(crowdsale) {
logger.info(" createDuthAuctionCrowdsale ");
logger.info(" createDutchAuctionCrowdsale ");
const startURL = Utils.getStartURL();
const welcomePage = new WizardWelcome(this.driver, startURL);
const wizardStep1 = new WizardStep1(this.driver);
@ -382,12 +382,13 @@ class User {
const crowdsalePage = new CrowdsalePage(this.driver);
const investPage = new InvestPage(this.driver);
const reservedTokens = new ReservedTokensPage(this.driver);
await TierPage.setCountTiers(0);
let result = await welcomePage.open() &&
await welcomePage.clickButtonNewCrowdsale() &&
await wizardStep1.waitUntilDisplayedCheckboxDutchAuction() &&
await wizardStep1.clickCheckboxDutchAuction();
if (!result) return false;
let counter = 200;
do {
await this.driver.sleep(300);
@ -403,7 +404,7 @@ class User {
await wizardStep2.fillPage(crowdsale) &&
await wizardStep2.clickButtonContinue() &&
await wizardStep3.fillPage(crowdsale);
if (!result) return false;
counter = 200;
do {
await this.driver.sleep(300);
@ -423,7 +424,7 @@ class User {
await wizardStep4.waitUntilDisplayedButtonContinue() &&
await wizardStep4.clickButtonContinue() &&
await wizardStep4.waitUntilLoaderGone();
if (!result) return false;
counter = 200;
do {
await this.driver.sleep(300);

View File

@ -6,7 +6,7 @@
"startGanache": "npm install -g ganache-cli && ganache-cli &",
"e2e-deployRegistry": "node ./contracts/DeployRegistry.js",
"e2eMinted": "mocha -b ./test/e2eMinted.js",
"e2eDutch": "mocha ./test/e2eDutch.js",
"e2eDutch": "mocha -b ./test/e2eDutch.js",
"ra": "node ./test/testRA.js",
"e2eMintedRopsten": "mocha ./test/e2eMintedRopsten.js",
"e2eDutchRopsten": "mocha ./test/e2eDutchRopsten.js"

View File

@ -194,10 +194,17 @@ class TierPage extends Page {
try {
let containers = await super.findWithWait(contentContainer);
let array = await this.getChildFromElementByClassName("radio-inline", containers[this.number + 1]);
this.checkboxModifyOn = array[0];
this.checkboxModifyOff = array[1];
this.checkboxWhitelistingYes = array[2];
this.checkboxWhitelistingNo = array[3];
if (array.length > 2) {
this.checkboxModifyOn = array[0];
this.checkboxModifyOff = array[1];
this.checkboxWhitelistingYes = array[2];
this.checkboxWhitelistingNo = array[3];
}
else { //if DUTCH
this.checkboxWhitelistingYes = array[0];
this.checkboxWhitelistingNo = array[1];
}
return true;
}
catch (err) {
@ -232,7 +239,7 @@ class TierPage extends Page {
async clickButtonAdd() {
logger.info(this.name + "clickButtonAdd ");
if (this.tier.minRate !== undefined) return true;
//if (this.tier.minRate !== undefined) return true;
let array = await this.findWithWait(buttonAdd);
if (array === null) return false;
else return await super.clickWithWait(array[this.number]);
@ -247,7 +254,7 @@ class TierPage extends Page {
async setModify() {
logger.info(this.name + "setModify ");
if (!this.tier.allowModify) return true;
if ((this.tier.allowModify === undefined) || (!this.tier.allowModify)) return true;
return (await this.initCheckboxes() !== null)
&& await super.clickWithWait(this.checkboxModifyOn);
}

View File

@ -0,0 +1,32 @@
{
"name": "scenarioE2eDutchWhitelistShort",
"ticker": "test",
"decimals": 18,
"totalSupply":1000,
"walletAddress":"0xdDdC96314b7f16cB243Cb07e1dE081CA367095E7",
"gasprice":1,
"mincap": 100,
"tiers":[
{
"isWhitelisted":true,
"startDate": "120000",
"startTime": "120000",
"endDate":"300000",
"endTime":"300000",
"minRate":100,
"maxRate":1000,
"supply": 500,
"whitelist":[
{
"address": "0xDb0E42Ee8fDaAd8A7f295f447F71A1480c98a373",
"min": 50,
"max": 150
},
{
"address": "0xF16AB2EA0a7F7B28C267cbA3Ed211Ea5c6e27411",
"min": 0,
"max": 300
}
]
}]
}

View File

@ -0,0 +1,22 @@
{
"name": "scenarioE2eDutchMincapLongjson",
"ticker": "test",
"decimals": 18,
"totalSupply":1000,
"walletAddress":"0xdDdC96314b7f16cB243Cb07e1dE081CA367095E7",
"gasprice":1,
"whitelisting":false,
"mincap": 100,
"tiers":[
{
"isWhitelisted":false,
"startDate": "120000",
"startTime": "120000",
"endDate":"23/02/2050",
"endTime":"12:34",
"minRate":100,
"maxRate":1000,
"supply": 500,
"whitelist":[]
}]
}

View File

@ -34,15 +34,15 @@ const endDateForTestEarlier = "01/07/2049";
const endTimeForTestLater = "11:23";
const endDateForTestLater = "01/07/2050";
test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function () {
this.timeout(2400000);//40 min
this.slow(1800000);
const user8545_dDdCFile = './users/user8545_dDdC.json';//Owner
const user8545_Db0EFile = './users/user8545_Db0E.json';//Investor1 - whitelisted before deployment
const scenarioForE2Etests = './scenarios/simpleDutchAuction.json';
const user8545_F16AFile = './users/user8545_F16A.json';//Investor2 - whitelisted before deployment
const scenarioE2eMinCap = './scenarios/scenarioE2eDutchMincapLong.json';
const scenarioE2eWhitelist = './scenarios/scenarioDutchWhitelistShort.json';
let driver;
let Owner;
@ -61,30 +61,45 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
let investPage;
let startURL;
let crowdsaleForUItests;
let crowdsaleForE2Etests;
let e2eMinCap;
let e2eWhitelist;
let mngPage;
let balance;
let balanceEthOwnerBefore;
let balanceEthOwnerAfter;
/////////////////////////////////////////////////////////////////////////
test.before(async function () {
logger.info("Version 2.3.0 - Wizard2.0 ");
crowdsaleForE2Etests = await Utils.getDutchCrowdsaleInstance(scenarioForE2Etests);
logger.info("Version 2.4.0 - Wizard2.0 - DutchAuction");
e2eMinCap = await Utils.getDutchCrowdsaleInstance(scenarioE2eMinCap);
e2eWhitelist = await Utils.getDutchCrowdsaleInstance(scenarioE2eWhitelist);
//e2eMinCap.print();
//throw("Stop");
startURL = await Utils.getStartURL();
driver = await Utils.startBrowserWithMetamask();
Owner = new User(driver, user8545_dDdCFile);
Investor1 = new User(driver, user8545_Db0EFile);
Investor1.tokenBalance = 0;
Investor2 = new User(driver, user8545_F16AFile);
Investor2.minCap = e2eWhitelist.tiers[0].whitelist[0].min;
Investor2.maxCap = e2eWhitelist.tiers[0].whitelist[0].max;
await Utils.receiveEth(Owner, 10);
await Utils.receiveEth(Investor1, 10);
await Utils.receiveEth(Investor2, 10);
logger.info("Roles:");
logger.info("Owner = " + Owner.account);
logger.info("Owner's balance = :" + await Utils.getBalance(Owner) / 1e18);
logger.info("Investor1 = " + Investor1.account);
logger.info("Investor1 balance = :" + await Utils.getBalance(Investor1) / 1e18);
logger.info("Investor2 = " + Investor2.account);
logger.info("Investor2 balance = :" + await Utils.getBalance(Investor2) / 1e18);
metaMask = new MetaMask(driver);
await metaMask.activate();//return activated Metamask and empty page
@ -111,29 +126,257 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
//await fs.remove(tempOutputPath);
//await driver.quit();
});
////////UI TESTS
test.it.skip('Check persisTTTTTTTTTT', async function () {
let investor = Investor1;
let newBalance = await investor.getTokenBalance(e2eMinCap) / 1e18;
let balance = e2eMinCap.minCap + smallAmount + 10;
logger.info("Investor should receive = " + balance);
logger.info("Investor has received balance = " + newBalance);
logger.info("Difference = " + (newBalance - balance));
return await assert.equal(balance, newBalance, "Test FAILED.'Investor has received " + newBalance + " tokens instead " + balance)
});
//////////////////////// Test SUITE #1 /////////////////////////////
test.it('Owner can create crowdsale(scenario DutchAuction1.json),1 tier, no whitelist',
test.it('Owner can create crowdsale, 2 Whitelisted',
async function () {
let owner = Owner;
assert.equal(await owner.setMetaMaskAccount(), true, "Can not set Metamask account");
let result = await owner.createDutchAuctionCrowdsale(crowdsaleForE2Etests);
let result = await owner.createDutchAuctionCrowdsale(e2eWhitelist);
return await assert.equal(result, true, 'Test FAILED. Crowdsale has not created ');
});
test.it("Invest page: Owner's balance has correct value (totalSupply-supply) ",
async function () {
balanceEthOwnerBefore = await Utils.getBalance(Owner);
let owner = Owner;
await owner.openInvestPage(crowdsaleForE2Etests);
let balance = await owner.getBalanceFromInvestPage(crowdsaleForE2Etests);
let shouldBe = crowdsaleForE2Etests.totalSupply - crowdsaleForE2Etests.tiers[0].supply;
await owner.openInvestPage(e2eMinCap);
let balance = await owner.getBalanceFromInvestPage(e2eWhitelist);
let shouldBe = e2eWhitelist.totalSupply - e2eWhitelist.tiers[0].supply;
let result = (balance.toString() === shouldBe.toString());
return await assert.equal(result, true, "Test FAILED. Owner's balance has incorrect value (totalSupply-supply)");
});
test.it('Whitelisted investor not able to buy before start of crowdsale ',
async function () {
let investor = Investor1;
assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
assert.equal(await investor.openInvestPage(e2eWhitelist), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let contribution = e2eWhitelist.tiers[0].whitelist[0].min;
let result = await investor.contribute(contribution);
return await assert.equal(result, false, "Test FAILED. Whitelisted investor can buy before the crowdsale started");
});
test.it('Invest page: Countdown timer is displayed',
async function () {
let investor = Owner;
await investor.openInvestPage(crowdsaleForE2Etests);
assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
assert.equal(await investor.openInvestPage(e2eWhitelist), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let result = await investPage.getTimerStatus();
return await assert.notEqual(result, false, 'Test FAILED. Countdown timer are not displayed ');
});
test.it('Tier starts as scheduled',
async function () {
let investor = Owner;
assert.equal(await investor.openInvestPage(e2eWhitelist), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let counter = 120;
do {
logger.info("wait " + Date.now());
await driver.sleep(1000);
}
while (counter-- > 0 && !await investPage.isCrowdsaleStarted());
return await assert.equal(counter > 0, true, 'Test FAILED. Tier has not start in time ');
});
test.it('Whitelisted investor is NOT able to buy less than min in first transaction',
async function () {
let investor = Investor1;
assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
assert.equal(await investor.openInvestPage(e2eWhitelist), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let contribution = e2eWhitelist.tiers[0].whitelist[0].min * 0.5;
let result = await investor.contribute(contribution);
return await assert.equal(result, false, "Test FAILED.Investor can buy less than minCap in first transaction");
});
test.it('Whitelisted investor can buy amount equal mincap',
async function () {
let investor = Investor1;
assert.equal(await investor.openInvestPage(e2eWhitelist), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let contribution = e2eWhitelist.tiers[0].whitelist[0].min;
investor.tokenBalance += contribution;
let result = await investor.contribute(contribution);
return await assert.equal(result, true, 'Test FAILED. Investor can not buy amount = min');
});
test.it('Invest page: Investors balance is properly changed after purchase ',
async function () {
let investor = Investor1;
await investor.openInvestPage(e2eWhitelist);
let newBalance = await investor.getBalanceFromInvestPage(e2eWhitelist);
console.log("newBalance="+newBalance);
console.log("investor.tokenBalance="+investor.tokenBalance);
let result = (Math.abs(parseFloat(newBalance) - parseFloat(investor.tokenBalance)) < 25);
return await assert.equal(result, true, "Test FAILED. Investor can buy but balance did not changed");
});
test.it('Whitelisted investor is able to buy less than mincap after first transaction',
async function () {
balanceEthOwnerBefore = await Utils.getBalance(Owner);
let investor = Investor1;
assert.equal(await investor.openInvestPage(e2eWhitelist), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let contribution = e2eWhitelist.tiers[0].whitelist[0].min * 0.1;
investor.tokenBalance += contribution;
let result = await investor.contribute(contribution);
return await assert.equal(result, true, "Test FAILED. Investor can NOT buy less than min after first transaction");
});
test.it('Whitelisted investor is able to buy maxCap',
async function () {
let investor = Investor1;
assert.equal(await investor.openInvestPage(e2eWhitelist), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let contribution = e2eWhitelist.tiers[0].supply;
let result = await investor.contribute(contribution);
return await assert.equal(result, true, "Test FAILED.Investor can buy more than assigned max");
});
test.it("Whitelisted investor's balance restricted by maxCap",
async function () {
let investor = Investor1;
assert.equal(await investor.openInvestPage(e2eWhitelist), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let newBalance = await investor.getBalanceFromInvestPage(e2eWhitelist);
investor.tokenBalance = e2eWhitelist.tiers[0].whitelist[0].max;
let result = (Math.abs(parseFloat(newBalance) - parseFloat(investor.tokenBalance)) < 300);
return await assert.equal(result, true, "Test FAILED.Investor can buy more than assigned max");
});
test.it('Whitelisted investor#2 is able to buy if mincap is zero',
async function () {
let investor = Investor2;
assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
assert.equal(await investor.openInvestPage(e2eWhitelist), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let contribution = 0.000001;
investor.tokenBalance += contribution;
let result = await investor.contribute(contribution);
return await assert.equal(result, true, "Test FAILED. Investor can NOT buy less than min after first transaction");
});
test.it('Whitelisted investor#2 balance is properly changed',
async function () {
let investor = Investor2;
assert.equal(await investor.openInvestPage(e2eWhitelist), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let newBalance = await investor.getBalanceFromInvestPage(e2eWhitelist);
let result = (parseFloat(newBalance) !== 0);
return await assert.equal(result, true, "Test FAILED. Investor can NOT buy less than min after first transaction");
});
test.it('Tier#1 has finished as scheduled',
async function () {
let investor = Investor1;
await investor.openInvestPage(e2eWhitelist);
let counter = 40;
do {
driver.sleep(5000);
}
while ((!await investPage.isCrowdsaleTimeOver()) && (counter-- > 0));
let result = (counter > 0);
return await assert.equal(result, true, "Test FAILED. Crowdsale has not finished in time");
});
test.it('Whitelisted investor is not able to buy if crowdsale finished',
async function () {
let investor = Investor2;
assert.equal(await investor.openInvestPage(e2eWhitelist), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let contribution = e2eWhitelist.tiers[0].supply;
return await assert.equal(await investor.contribute(contribution), false, 'Whitelisted investor is able to buy if crowdsale finalized');
});
test.it('Not owner is not able to finalize',
async function () {
let investor = Investor1;
assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
let result = await investor.finalize(e2eWhitelist);
return await assert.equal(result, false, "Test FAILED.'Not Owner can finalize ");
});
test.it('Owner is able to finalize (if all tokens are sold but crowdsale time is not expired)',
async function () {
let owner = Owner;
assert.equal(await owner.setMetaMaskAccount(), true, "Can not set Metamask account");
let result = await owner.finalize(e2eWhitelist);
return await assert.equal(result, true, "Test FAILED.'Owner can NOT finalize ");
});
test.it.skip('Investor has received correct quantity of tokens after finalization',
async function () {
let investor = Investor1;
let newBalance = await investor.getTokenBalance(e2eWhitelist) / 1e18;
let balance = e2eWhitelist.minCap + smallAmount + 10;
logger.info("Investor should receive = " + balance);
logger.info("Investor has received balance = " + newBalance);
logger.info("Difference = " + (newBalance - balance));
return await assert.equal(balance, newBalance, "Test FAILED.'Investor has received " + newBalance + " tokens instead " + balance)
});
test.it.skip('Owner has received correct quantity of tokens after finalization',
async function () {
let investor = Investor1;
let newBalance = await investor.getTokenBalance(e2eWhitelist) / 1e18;
let balance = e2eWhitelist.minCap + smallAmount + 10;
logger.info("Investor should receive = " + balance);
logger.info("Investor has received balance = " + newBalance);
logger.info("Difference = " + (newBalance - balance));
return await assert.equal(balance, newBalance, "Test FAILED.'Investor has received " + newBalance + " tokens instead " + balance)
});
//////////////////////// Test SUITE #2 /////////////////////////////
test.it('Owner can create crowdsale(scenario scenarioE2eDutchMincapLong.json), minCap,no whitelist',
async function () {
Investor1.tokenBalance = 0;
let owner = Owner;
assert.equal(await owner.setMetaMaskAccount(), true, "Can not set Metamask account");
let result = await owner.createDutchAuctionCrowdsale(e2eMinCap);
return await assert.equal(result, true, 'Test FAILED. Crowdsale has not created ');
});
test.it("Invest page: Owner's balance has correct value (totalSupply-supply) ",
async function () {
balanceEthOwnerBefore = await Utils.getBalance(Owner);
let owner = Owner;
await owner.openInvestPage(e2eMinCap);
let balance = await owner.getBalanceFromInvestPage(e2eMinCap);
let shouldBe = e2eMinCap.totalSupply - e2eMinCap.tiers[0].supply;
let result = (balance.toString() === shouldBe.toString());
return await assert.equal(result, true, "Test FAILED. Owner's balance has incorrect value (totalSupply-supply)");
});
test.it('Investor not able to buy before start of crowdsale ',
async function () {
let investor = Investor1;
assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
assert.equal(await investor.openInvestPage(e2eMinCap), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let contribution = e2eMinCap.minCap;
let result = await investor.contribute(contribution);
return await assert.equal(result, false, "Test FAILED. Whitelisted investor can buy before the crowdsale started");
});
test.it('Invest page: Countdown timer is displayed',
async function () {
let investor = Investor1;
await investor.openInvestPage(e2eMinCap);
await investPage.waitUntilLoaderGone();
let result = await investPage.getTimerStatus();
return await assert.notEqual(result, false, 'Test FAILED. Countdown timer are not displayed ');
@ -141,8 +384,8 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
test.it('Tier start as scheduled',
async function () {
let investor = Owner;
await investor.openInvestPage(crowdsaleForE2Etests);
let investor = Investor1;
await investor.openInvestPage(e2eMinCap);
await investPage.waitUntilLoaderGone();
let counter = 120;
do {
@ -153,42 +396,106 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(counter > 0, true, 'Test FAILED. Tier has not start in time ');
});
test.it('Disabled to modify the end time for DutchCrowdsale',
async function () {
let owner = Owner;
await owner.openManagePage(crowdsaleForE2Etests);
let adjust = 80000000;
let newTime = Utils.getTimeWithAdjust(adjust, "utc");
let newDate = Utils.getDateWithAdjust(adjust, "utc");
let tierNumber = 1;
let result = await owner.changeEndTime(tierNumber, newDate, newTime);
return await assert.equal(result, false, 'Test FAILED.DutchCrowdsale is modifiable ');
});
test.it('Investor can buy allowed amount',
test.it('Investor is not able to buy less than minCap in first transaction',
async function () {
let investor = Investor1;
assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
let contribution = crowdsaleForE2Etests.tiers[0].supply / 2;
balance = contribution;
let result = await investor.openInvestPage(crowdsaleForE2Etests)
//assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
assert.equal(await investor.openInvestPage(e2eMinCap), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let contribution = e2eMinCap.minCap * 0.5;
let result = await investor.contribute(contribution);
return await assert.equal(result, false, "Test FAILED.Investor can buy less than minCap in first transaction");
});
test.it('Investor is able to buy amount equal mincap',
async function () {
let investor = Investor1;
//assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
let contribution = e2eMinCap.minCap;
investor.tokenBalance += contribution;
let result = await investor.openInvestPage(e2eMinCap)
&& await investor.contribute(contribution);
return await assert.equal(result, true, 'Test FAILED. Investor can not buy ');
});
test.it('Invest page: Investors balance is changed accordingly after purchase ',
test.it('Invest page: Investors balance is properly changed after purchase ',
async function () {
let investor = Investor1;
await investor.openInvestPage(crowdsaleForE2Etests);
let newBalance = await investor.getBalanceFromInvestPage(crowdsaleForE2Etests);
let result = (newBalance >= balance);
await investor.openInvestPage(e2eMinCap);
let newBalance = await investor.getBalanceFromInvestPage(e2eMinCap);
let result = (Math.abs(parseFloat(newBalance) - parseFloat(investor.tokenBalance)) < 10);
return await assert.equal(result, true, "Test FAILED. Investor can buy but balance did not changed");
});
test.it('Crowdsale is finished in time',
test.it('Whitelisted investor is able to buy less than mincap after first transaction',
async function () {
let investor = Investor1;
await investor.openInvestPage(crowdsaleForE2Etests);
assert.equal(await investor.openInvestPage(e2eMinCap), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let contribution = e2eMinCap.minCap * 0.5;
investor.tokenBalance += contribution;
let result = await investor.contribute(contribution);
return await assert.equal(result, true, "Test FAILED. Investor can NOT buy less than min after first transaction");
});
test.it('Whitelisted investor is able to buy maxCap',
async function () {
let investor = Investor1;
assert.equal(await investor.openInvestPage(e2eMinCap), true, 'Investor can not open Invest page');
assert.equal(await investPage.waitUntilLoaderGone(), true, 'Loader displayed too long time');
let contribution = e2eMinCap.tiers[0].supply;
investor.tokenBalance = contribution;
await investor.contribute(contribution);
let balance = await investor.getBalanceFromInvestPage(e2eMinCap);
let result = (Math.abs(parseFloat(balance) - parseFloat(investor.tokenBalance)) < 0.1);
return await assert.equal(result, true, "Test FAILED.Investor can not buy maxCap");
});
test.it("Owner's Eth balance properly changed ",
async function () {
balanceEthOwnerAfter = await Utils.getBalance(Owner);
let contribution = e2eMinCap.tiers[0].supply;
let delta = 0.1;
let result = await Utils.compareBalance(balanceEthOwnerBefore, balanceEthOwnerAfter, contribution, e2eMinCap.tiers[0].minRate, delta);
return await assert.equal(result, true, "Owner's balance incorrect");
});
test.it('Owner is able to finalize (if all tokens have been sold)',
async function () {
let owner = Owner;
assert.equal(await owner.setMetaMaskAccount(), true, "Can not set Metamask account");
let result = await owner.finalize(e2eMinCap);
return await assert.equal(result, true, "Test FAILED.'Owner can NOT finalize ");
});
test.it.skip('Investor has received correct quantity of tokens after finalization',
async function () {
let investor = Investor1;
let newBalance = await investor.getTokenBalance(e2eMinCap) / 1e18;
let balance = e2eMinCap.minCap + smallAmount + 10;
logger.info("Investor should receive = " + balance);
logger.info("Investor has received balance = " + newBalance);
logger.info("Difference = " + (newBalance - balance));
return await assert.equal(balance, newBalance, "Test FAILED.'Investor has received " + newBalance + " tokens instead " + balance)
});
test.it.skip('Owner has received correct quantity of tokens after finalization',
async function () {
let investor = Investor1;
let newBalance = await investor.getTokenBalance(e2eMinCap) / 1e18;
let balance = e2eMinCap.minCap + smallAmount + 10;
logger.info("Investor should receive = " + balance);
logger.info("Investor has received balance = " + newBalance);
logger.info("Difference = " + (newBalance - balance));
return await assert.equal(balance, newBalance, "Test FAILED.'Investor has received " + newBalance + " tokens instead " + balance)
});
test.it.skip('Crowdsale is finished in time',
async function () {
let investor = Investor1;
await investor.openInvestPage(e2eMinCap);
let counter = 40;
do {
driver.sleep(5000);
@ -199,48 +506,46 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(result, true, "Test FAILED. Crowdsale has not finished in time");
});
test.it('Is disabled to buy after crowdsale time expired',
test.it.skip('Is disabled to buy after crowdsale time expired',
async function () {
let investor = Investor1;
let contribution = crowdsaleForE2Etests.tiers[0].supply;
let contribution = e2eMinCap.minCap * 1.1;
let result = await investor.contribute(contribution);
return await assert.equal(result, false, "Test FAILED. Investor can buy if crowdsale is finalized");
});
test.it('Not owner can not finalize)',
test.it.skip('Not owner can not finalize)',
async function () {
let investor = Investor1;
let result = await investor.finalize(crowdsaleForE2Etests);
let result = await investor.finalize(e2eMinCap);
return await assert.equal(result, false, "Test FAILED.'Not Owner can finalize ");
});
test.it('Owner is able to finalize (if crowdsale time expired but not all tokens were sold)',
test.it.skip('Owner is able to finalize (if crowdsale time expired but not all tokens were sold)',
async function () {
let owner = Owner;
assert.equal(await owner.setMetaMaskAccount(), true, "Can not set Metamask account");
let result = await owner.finalize(crowdsaleForE2Etests);
let result = await owner.finalize(e2eMinCap);
return await assert.equal(result, true, "Test FAILED.'Owner can NOT finalize ");
});
test.it.skip('Investor has received correct quantity of tokens after finalization', async function () {
let investor = Investor1;
let newBalance = await investor.getTokenBalance(crowdsaleForE2Etests) / 1e18;
let balance = crowdsaleForE2Etests.minCap + smallAmount + 10;
logger.info("Investor should receive = " + balance);
logger.info("Investor has received balance = " + newBalance);
logger.info("Difference = " + (newBalance - balance));
return await assert.equal(balance, newBalance, "Test FAILED.'Investor has received " + newBalance + " tokens instead " + balance)
});
test.it.skip('Check persisTTTTTTTTTT', async function () {
let investor = Investor1;
let newBalance = await investor.getTokenBalance(crowdsaleForE2Etests) / 1e18;
let balance = crowdsaleForE2Etests.minCap + smallAmount + 10;
logger.info("Investor should receive = " + balance);
logger.info("Investor has received balance = " + newBalance);
logger.info("Difference = " + (newBalance - balance));
return await assert.equal(balance, newBalance, "Test FAILED.'Investor has received " + newBalance + " tokens instead " + balance)
});
test.it.skip('Investor has received correct quantity of tokens after finalization',
async function () {
let investor = Investor1;
let newBalance = await investor.getTokenBalance(e2eWhitelist) / 1e18;
let balance = e2eWhitelist.minCap + smallAmount + 10;
logger.info("Investor should receive = " + balance);
logger.info("Investor has received balance = " + newBalance);
logger.info("Difference = " + (newBalance - balance));
return await assert.equal(balance, newBalance, "Test FAILED.'Investor has received " + newBalance + " tokens instead " + balance)
});
test.it.skip('Owner has received correct quantity of tokens after finalization',
async function () {
let investor = Investor1;
let newBalance = await investor.getTokenBalance(e2eWhitelist) / 1e18;
let balance = e2eWhitelist.minCap + smallAmount + 10;
logger.info("Investor should receive = " + balance);
logger.info("Investor has received balance = " + newBalance);
logger.info("Difference = " + (newBalance - balance));
return await assert.equal(balance, newBalance, "Test FAILED.'Investor has received " + newBalance + " tokens instead " + balance)
});
});

View File

@ -65,7 +65,7 @@ test.describe('POA token-wizard. Test MintedCappedCrowdsale', async function ()
/////////////////////////////////////////////////////////////////////////
test.before(async function () {
logger.info("Version 2.6.0 - Wizard2.0 - MintedCappedCrowdsale ");
logger.info("Version 2.6.0 - Wizard2.0 ");
const scenarioE2eMintedMinCap = './scenarios/scenarioE2eMintedMinCap.json';
const scenarioE2eMintedWhitelist = './scenarios/scenarioE2eMintedWhitelist.json';

View File

@ -53,7 +53,7 @@ class Utils {
let provider = await Utils.getProviderUrl(user.networkID);
let web3 = await new Web3(new Web3.providers.HttpProvider(provider));
let account0 = await web3.eth.getAccounts().then((accounts) => {
return accounts[1];
return accounts[2];
});
logger.info("Send " + amount + " Eth from " + account0 + " to " + user.account);
@ -61,7 +61,7 @@ class Utils {
from: account0,
to: user.account,
value: amount * 1e18
}).then(console.log("Transaction done"));
}).then(logger.info("Transaction done"));
return true;
}
catch (err) {
@ -312,7 +312,7 @@ class Utils {
return process.env.PWD + "/" + fileName;
}
static async compareBalance(balanceEthOwnerBefore, balanceEthOwnerAfter, contribution, rate) {
static async compareBalance(balanceEthOwnerBefore, balanceEthOwnerAfter, contribution, rate, delta) {
let balanceShouldBe = balanceEthOwnerBefore/1e18 + (contribution / rate);
logger.info("contribution / rate= " + (contribution / rate) );
logger.info("rate= " + rate );
@ -320,7 +320,8 @@ class Utils {
logger.info("contribution= " + contribution );
logger.info("balanceShouldBe= " + balanceShouldBe );
logger.info("balanceEthOwnerAfter= " + balanceEthOwnerAfter / 1e18);
let delta = 0.01;
if (delta === undefined) delta = 0.01;
logger.info("delta= " + delta);
return ( Math.abs(balanceShouldBe - balanceEthOwnerAfter/1e18) < delta );
}