Dutch: mincap modif

This commit is contained in:
dennis00010011b 2018-06-27 14:00:33 -07:00
parent 5d8fa5cf96
commit 299fd86838
11 changed files with 212 additions and 142 deletions

View File

@ -160,19 +160,21 @@ Test suite for DutchAuctionCrowdsale , starts with command ```npm run e2eDutch``
```
#### Functional tests for DutchAuctionCrowdsale
```
- Owner can create DutchAuction crowdsale: 2 whitelisted addresses,duration 3 min
- Invest page: Owner's balance has correct value (totalSupply-crowdsaleSupply)
- Owner can create DutchAuction crowdsale: 1 whitelisted addresses,duration 5 min
- Contribution page: Owner's balance has correct value (totalSupply-crowdsaleSupply)
- Whitelisted investor not able to buy before start of crowdsale
- Invest page: Countdown timer is displayed
- Manage page: owner is able to add whitelisted address before start of crowdsale
- Contribution page: Countdown timer is displayed
- Tier starts as scheduled
- Whitelisted investor#1 is not able to buy less than minCap in first transaction
- Whitelisted investor#1 can buy amount equal minCap
- Invest page: Investor's#1 balance is properly changed after purchase
- Whitelisted investor#1 is able to buy less than minCap after first transaction
- Whitelisted investor#1 is able to buy maxCap
- Whitelisted investor's#1 balance limited by maxCap
- Whitelisted investor#2 with zero minCap is able to buy
- Whitelisted investor#2 balance is properly changed
- Manage page: owner is able to add whitelisted address after start of crowdsale
- Whitelisted investor which was added before start can buy amount equal mincap
- Whitelisted investor which was added after start can buy amount equal mincap
- Whitelisted investor is not able to buy less than minCap in first transaction
- Whitelisted investor can buy amount equal minCap
- Contribution page: Investor's balance is properly changed after purchase
- Whitelisted investor is able to buy less than minCap after first transaction
- Whitelisted investor is able to buy maxCap
- Whitelisted investor's balance limited by maxCap
- Crowdsale has finished as schedule
- Whitelisted investor is not able to buy if crowdsale finished
- Not owner is not able to finalize
@ -182,18 +184,24 @@ Test suite for DutchAuctionCrowdsale , starts with command ```npm run e2eDutch``
- Owner has received correct quantity of tokens after finalization
- Owner can create DutchAuction crowdsale: minCap,no whitelist
- Invest page: Owner's balance has correct value (totalSupply-supply)
- Contribution page: Owner's balance has correct value (totalSupply-supply)
- Manage page: owner is able to change minCap before start of crowdsale
- Investor not able to buy before start of crowdsale
- Invest page: countdown timer is displayed
- Crowdsale starts as scheduled
- Contribution page: countdown timer is displayed
- Tier starts as scheduled
- Investor is not able to buy less than minCap in first transaction
- Investor is able to buy amount equal minCap
- Invest page: Investors balance is properly changed after purchase
- Contribution page: Investors balance is properly changed after purchase
- Whitelisted investor is able to buy less than minCap after first transaction
- Whitelisted investor is able to buy maxCap
- Manage page: owner is able to update minCap after start of crowdsale
- minCap should be updated: new investor is not able to buy less than new minCap
- minCap should be updated: new investor is able to buy amount equals new minCap
- Old investor still able to buy amount less than minCap
- Investor is able to buy maxCap
- Owner's Eth balance properly changed
- Owner is able to finalize (if all tokens have been sold)
- Investor has received correct quantity of tokens after finalization
- Investor #1 has received correct quantity of tokens after finalization
- Investor #2 has received correct quantity of tokens after finalization
- Owner has received correct quantity of tokens after finalization
```

View File

@ -42,7 +42,7 @@ class User {
const web3 = await Utils.getWeb3Instance(crowdsale.networkID);
let contractAddress = await Utils.getContractAddressInitCrowdsale(crowdsale);
logger.info("contractAddress" + contractAddress);
let addressRegistryStorage = await Utils.getEnvAddressRegistryStorage();
let addressRegistryStorage = await Utils.getEnvAddressAbstractStorage();
logger.info("addressRegistryStorage" + addressRegistryStorage);
let abi = await Utils.getContractABIInitCrowdsale(crowdsale);
let myContract = new web3.eth.Contract(abi, contractAddress);

View File

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

View File

@ -490,9 +490,9 @@ class ManagePage extends Page {
async fillMinCap(tier, value) {
logger.info(this.name + "fillMinCap , tier# " + tier + " ,value = " + value);
return await this.getFieldMinCap(tier)
&& await super.clearField(fieldMinCap)
&& await super.fillWithWait(fieldMinCap,value);
let element = await this.getFieldMinCap(tier)
return await super.clearField(element)
&& await super.fillWithWait(element, value);
}
}

View File

@ -202,7 +202,7 @@ class MetaMask extends Page {
async fillGasLimit(value) {
logger.info(this.name + " fillGasLimit ");
return await this.clearFieldFromStart(fieldGasLimit)
&& await this.fillWithWait(fieldGasLimit, value)
&& await this.fillWithWait(fieldGasLimit, value);
}

View File

@ -3,24 +3,33 @@
"name": "scenarioDutchRopsten.json",
"ticker": "test",
"decimals": 10,
"totalSupply":10000,
"totalSupply":100,
"walletAddress":"0x56B2e3C3cFf7f3921Dc2e0F8B8e20d1eEc29216b",
"gasprice":100,
"gasprice":1000,
"tiers":[
{
"isWhitelisted":false,
"isWhitelisted":true,
"startDate": "420000",
"startTime": "420000",
"endDate":"700000",
"endTime":"700000",
"minCap":31,
"minRate":100,
"maxRate":1000,
"endDate":"70000000",
"endTime":"70000000",
"minCap":0,
"minRate":1000,
"maxRate":10000,
"supply": 100,
"whitelist":[
{
"address": "0xF16AB2EA0a7F7B28C267cbA3Ed211Ea5c6e27411",
"min": 50,
"max": 150
},
{
"address": "0x9E963042D581D262AdE4E31541360e7FDAeE70C6",
"min": 50,
"max": 150
}
]
}]
}

View File

@ -9,11 +9,11 @@
"tiers":[
{
"isWhitelisted":false,
"startDate": "120000",
"startTime": "120000",
"startDate": "180000",
"startTime": "180000",
"endDate":"23/02/2050",
"endTime":"12:34",
"minCap":101,
"minCap":100,
"minRate":100,
"maxRate":1000,
"supply": 500,

View File

@ -5,14 +5,14 @@
"totalSupply":1000,
"walletAddress":"0xdDdC96314b7f16cB243Cb07e1dE081CA367095E7",
"gasprice":1,
"mincap": 100,
"tiers":[
{
"isWhitelisted":true,
"startDate": "120000",
"startTime": "120000",
"endDate":"300000",
"endTime":"300000",
"startDate": "180000",
"startTime": "180000",
"endDate":"480000",
"endTime":"480000",
"minCap":100,
"minRate":100,
"maxRate":1000,
"supply": 500,
@ -21,11 +21,6 @@
"address": "0xDb0E42Ee8fDaAd8A7f295f447F71A1480c98a373",
"min": 50,
"max": 150
},
{
"address": "0xF16AB2EA0a7F7B28C267cbA3Ed211Ea5c6e27411",
"min": 0,
"max": 300
}
]
}]

View File

@ -21,53 +21,24 @@
"name": "###1",
"allowModify": true,
"isWhitelisted": false,
"startDate": "600000",
"startTime": "600000",
"endDate": "720000",
"endTime": "720000",
"startDate": "420000",
"startTime": "420000",
"endDate": "600000",
"endTime": "600000",
"minCap":11,
"rate": 1000,
"supply": 200,
"whitelist": [
]
},
{
"name": "###2",
"allowModify": false,
"isWhitelisted": true,
"startDate": "",
"startTime": "",
"endDate": "",
"endTime": "",
"minCap":12,
"rate": 2000,
"supply": 400,
"whitelist": [
{
"address": "0xF16AB2EA0a7F7B28C267cbA3Ed211Ea5c6e27411",
"min": 50,
"max": 150
},
{
"address": "0x9E963042D581D262AdE4E31541360e7FDAeE70C6",
"min": 50,
"max": 150
}
]
},
{
"name": "###3",
"allowModify": true,
"isWhitelisted": false,
"startDate": "",
"startTime": "",
"endDate": "",
"endTime": "",
"minCap":13,
"rate": 6000,
"supply": 600,
"whitelist": [
]
}

View File

@ -20,7 +20,7 @@ const MetaMask = require('../pages/MetaMask.js').MetaMask;
const User = require("../entity/User.js").User;
const smallAmount = 0.1;
test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function () {
test.describe('e2e test for TokenWizard2.0/DutchAuctionCrowdsale. v2.7.0 ', async function () {
this.timeout(2400000);//40 min
this.slow(1800000);
@ -67,11 +67,13 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
driver = await Utils.startBrowserWithMetamask();
Owner = new User(driver, user8545_dDdCFile);
Owner.tokenBalance = 0;
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;
Investor2.tokenBalance = 0;
await Utils.receiveEth(Owner, 10);
await Utils.receiveEth(Investor1, 10);
@ -415,7 +417,7 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
*/
//////////////////////// Test SUITE #1 /////////////////////////////
test.it('Owner can create crowdsale: 2 whitelisted addresses,duration 3 min',
test.it('Owner can create crowdsale: 1 whitelisted address,duration 5 min',
async function () {
let owner = Owner;
assert.equal(await owner.setMetaMaskAccount(), true, "Can not set Metamask account");
@ -445,6 +447,18 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(result, false, "Test FAILED. Whitelisted investor can buy before the crowdsale started");
});
test.it('Manage page: owner is able to add whitelisted address before start of crowdsale',
async function () {
let owner = Owner;
let investor = Investor2;
assert.equal(await owner.setMetaMaskAccount(), true, "Can not set Metamask account");
assert.equal(await owner.openManagePage(e2eWhitelist), true, 'Owner can not open manage page');
let tierNumber = 1;
let result = await owner.addWhitelistTier(tierNumber, investor.account, investor.minCap, investor.maxCap);
return await assert.equal(result, true, 'Test FAILED.Owner is NOT able to add whitelisted address before start of crowdsale ');
});
test.it('Invest page: Countdown timer is displayed',
async function () {
let investor = Owner;
@ -468,6 +482,41 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
while (counter-- > 0 && !await investPage.isCrowdsaleStarted());
return await assert.equal(counter > 0, true, 'Test FAILED. Tier has not start in time ');
});
test.it('Manage page: owner is able to add whitelisted address after start of crowdsale',
async function () {
let owner = Owner;
let investor = Owner;
assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
assert.equal(await owner.openManagePage(e2eWhitelist), true, 'Owner can not open manage page');
let tierNumber = 1;
investor.minCap = e2eWhitelist.tiers[0].supply/10;
investor.maxCap = e2eWhitelist.tiers[0].supply;
let result = await owner.addWhitelistTier(tierNumber, investor.account, investor.minCap, investor.maxCap);
return await assert.equal(result, true, 'Test FAILED.Owner is NOT able to add whitelisted address after start of crowdsale ');
});
test.it('Whitelisted investor which was added before start can buy amount equal mincap',
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 = investor.minCap;
investor.tokenBalance += contribution;
let result = await investor.contribute(contribution);
return await assert.equal(result, true, 'Test FAILED. Whitelisted investor that was added before start can not buy');
});
test.it('Whitelisted investor which was added after start can buy amount equal mincap',
async function () {
let investor = Owner;
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 = investor.minCap;
investor.tokenBalance += contribution;
let result = await investor.contribute(contribution);
return await assert.equal(result, true, 'Test FAILED. Whitelisted investor that was added after start can not buy');
});
test.it('Whitelisted investor is not able to buy less than minCap in first transaction',
async function () {
@ -480,7 +529,7 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(result, false, "Test FAILED.Investor can buy less than minCap in first transaction");
});
test.it('Whitelisted investor #1 can buy amount equal mincap',
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');
@ -490,18 +539,18 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
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#1 balance is properly changed after purchase ',
test.it("Contribution page: Investor's balance is properly changed after purchase ",
async function () {
let investor = Investor1;
await investor.openInvestPage(e2eWhitelist);
let newBalance = await investor.getBalanceFromInvestPage(e2eWhitelist);
logger.info("newBalance=" + newBalance);
logger.info("investor.tokenBalance=" + investor.tokenBalance);
let result = (Math.abs(parseFloat(newBalance) - parseFloat(investor.tokenBalance)) < 40);
let result = (Math.abs(parseFloat(newBalance) - parseFloat(investor.tokenBalance)) < 250);
return await assert.equal(result, true, "Test FAILED. Investor can buy but balance did not changed");
});
test.it('Whitelisted investor #1 is able to buy less than mincap after first transaction',
test.it('Whitelisted investor is able to buy less than mincap after first transaction',
async function () {
balanceEthOwnerBefore = await Utils.getBalance(Owner);
let investor = Investor1;
@ -513,7 +562,7 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(result, true, "Test FAILED. Investor can NOT buy less than min after first transaction");
});
test.it('Whitelisted investor #1 is able to buy maxCap',
test.it('Whitelisted investor is able to buy maxCap',
async function () {
let investor = Investor1;
@ -536,28 +585,6 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(result, true, "Test FAILED.Investor can buy more than assigned max");
});
test.it('Whitelisted investor#2 with zero minCap is able to buy',
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('Crowdsale has finished as scheduled',
async function () {
@ -628,8 +655,10 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
test.it('Owner has received correct quantity of tokens after finalization',
async function () {
let investor = Owner;
assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
await investor.openInvestPage(e2eWhitelist);
let shouldBe = parseFloat(await investor.getBalanceFromInvestPage(e2eWhitelist));
let balance = await investor.getTokenBalance(e2eWhitelist) / 1e18;
let shouldBe = e2eWhitelist.totalSupply - e2eWhitelist.tiers[0].supply;
logger.info("Investor should receive = " + shouldBe);
logger.info("Investor has received balance = " + balance);
logger.info("Difference = " + (balance - shouldBe));
@ -647,7 +676,7 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(result, true, 'Test FAILED. Crowdsale has not created ');
});
test.it("Invest page: Owner's balance has correct value (totalSupply-supply) ",
test.it("Contribution page: Owner's balance has correct value (totalSupply-supply) ",
async function () {
balanceEthOwnerBefore = await Utils.getBalance(Owner);
let owner = Owner;
@ -664,7 +693,8 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
let tierNumber = 1;
assert.equal(await owner.setMetaMaskAccount(), true, "Can not set Metamask account");
assert.equal(await owner.openManagePage(e2eMinCap), true, 'Owner can not open manage page');
let result = await owner.changeMinCapFromManagePage(tierNumber, e2eMinCap.tiers[0].minCap - 1);
e2eMinCap.tiers[0].minCap = e2eMinCap.tiers[0].minCap /2;
let result = await owner.changeMinCapFromManagePage(tierNumber, e2eMinCap.tiers[0].minCap);
return await assert.equal(result, true, 'Test FAILED.Owner is NOT able to add whitelisted address before start of crowdsale ');
});
@ -679,7 +709,7 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(result, false, "Test FAILED. Whitelisted investor can buy before the crowdsale started");
});
test.it('Invest page: Countdown timer is displayed',
test.it('Contribution page: Countdown timer is displayed',
async function () {
let investor = Investor1;
await investor.openInvestPage(e2eMinCap);
@ -688,7 +718,7 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.notEqual(result, false, 'Test FAILED. Countdown timer are not displayed ');
});
test.it('Crowdsale starts as scheduled',
test.it('Tier starts as scheduled',
async function () {
let investor = Investor1;
await investor.openInvestPage(e2eMinCap);
@ -702,15 +732,7 @@ 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('Manage page,tier #1: owner is not able to modify mincap after crowdsale has started ',
async function () {
let owner = Owner;
let tierNumber = 1;
assert.equal(await owner.setMetaMaskAccount(), true, "Can not set Metamask account");
assert.equal(await owner.openManagePage(e2eMinCap), true, 'Owner can not open manage page');
let result = await mngPage.isDisabledMinCap(tierNumber);
return await assert.equal(result, true, 'Test FAILED.Manage page: field minCap disabled after start');
});
test.it('Investor is not able to buy less than minCap in first transaction',
async function () {
let investor = Investor1;
@ -733,7 +755,7 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(result, true, 'Test FAILED. Investor can not buy ');
});
test.it('Invest page: Investors balance is properly changed after purchase ',
test.it('Contribution page: Investors balance is properly changed after purchase ',
async function () {
let investor = Investor1;
await investor.openInvestPage(e2eMinCap);
@ -742,7 +764,7 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
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',
test.it('Investor is able to buy less than minCap after first transaction',
async function () {
let investor = Investor1;
assert.equal(await investor.openInvestPage(e2eMinCap), true, 'Investor can not open Invest page');
@ -754,13 +776,62 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
});
test.it('Whitelisted investor is able to buy maxCap',
test.it('Manage page: owner is able to update minCap after start of crowdsale',
async function () {
let owner = Owner;
let tierNumber = 1;
assert.equal(await owner.setMetaMaskAccount(), true, "Can not set Metamask account");
assert.equal(await owner.openManagePage(e2eMinCap), true, 'Owner can not open manage page');
e2eMinCap.tiers[0].minCap = e2eMinCap.tiers[0].minCap *2;
let result = await owner.changeMinCapFromManagePage(tierNumber, e2eMinCap.tiers[0].minCap);
return await assert.equal(result, true, 'Test FAILED.Manage page: owner is not able to update minCap after start of crowdsale ');
});
test.it('minCap should be updated: new investor is not able to buy less than new minCap ',
async function () {
let investor = Investor2;
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.tiers[0].minCap - 1;
let result = await investor.contribute(contribution);
return await assert.equal(result, false, "Test FAILED. minCap wasn't updated");
});
test.it('minCap should be updated: New investor is able to buy amount equals new minCap ',
async function () {
let investor = Investor2;
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].minCap;
investor.tokenBalance = contribution;
let result = await investor.contribute(contribution);
return await assert.equal(result, true, "Test FAILED. Updated minCap in action: New investor is not able to buy amount equals new minCap");
});
test.it('Old investor still able to buy amount less than minCap',
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.tiers[0].minCap/10;
investor.tokenBalance += contribution;
console.log ("investor.tokenBalance= "+investor.tokenBalance)
await investor.contribute(contribution);
let balance = await investor.getBalanceFromInvestPage(e2eMinCap);
let result = (Math.abs(parseFloat(balance) - parseFloat(investor.tokenBalance)) < 1);
return await assert.equal(result, true, "Test FAILED.Investor can not buy maxCap");
});
test.it('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;
investor.tokenBalance = contribution - Investor2.tokenBalance;
await investor.contribute(contribution);
let balance = await investor.getBalanceFromInvestPage(e2eMinCap);
let result = (Math.abs(parseFloat(balance) - parseFloat(investor.tokenBalance)) < 0.1);
@ -776,7 +847,7 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(result, true, "Owner's balance incorrect");
});
test.it.skip('Owner is able to finalize (if all tokens have been sold)',
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");
@ -784,7 +855,7 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(result, true, "Test FAILED.'Owner can NOT finalize ");
});
test.it.skip('Investor has received correct quantity of tokens after finalization',
test.it('Investor #1 has received correct quantity of tokens after finalization',
async function () {
let investor = Investor1;
@ -799,7 +870,23 @@ test.describe('POA token-wizard. Test DutchAuctionCrowdsale', async function ()
return await assert.equal(result, true, "Test FAILED.'Investor has received " + balance + " tokens instead " + shouldBe)
});
test.it.skip('Owner has received correct quantity of tokens after finalization',
test.it('Investor #2 has received correct quantity of tokens after finalization',
async function () {
let investor = Investor2;
assert.equal(await investor.setMetaMaskAccount(), true, "Can not set Metamask account");
await investor.openInvestPage(e2eWhitelist);
let shouldBe = parseFloat(await investor.getBalanceFromInvestPage(e2eMinCap));
let balance = await investor.getTokenBalance(e2eMinCap) / 1e18;
logger.info("Investor should receive = " + shouldBe);
logger.info("Investor has received balance = " + balance);
logger.info("Difference = " + (balance - shouldBe));
let result = (Math.abs(shouldBe - balance) < 1e-6);
return await assert.equal(result, true, "Test FAILED.'Investor has received " + balance + " tokens instead " + shouldBe)
});
test.it('Owner has received correct quantity of tokens after finalization',
async function () {
let investor = Owner;

View File

@ -325,22 +325,22 @@ class Utils {
return (Math.abs(balanceShouldBe - balanceEthOwnerAfter / 1e18) < delta);
}
static async getEnvAddressMintedInitCrowdsale() {
static async getEnvAddressMintedIDXAddress() {
logger.info("Utils:getEnvAddressMintedInitCrowdsale");
require('dotenv').config();
return Object.values(JSON.parse(process.env.REACT_APP_MINTED_CAPPED_CROWDSALE_INIT_CROWDSALE_ADDRESS))[0];
return Object.values(JSON.parse(process.env.REACT_APP_MINTED_CAPPED_IDX_ADDRESS))[0];
}
static async getEnvAddressDutchInitCrowdsale() {
static async getEnvAddressDutchIDXAddress() {
logger.info("Utils:getEnvAddressDutchInitCrowdsale");
require('dotenv').config();
return Object.values(JSON.parse(process.env.REACT_APP_DUTCH_CROWDSALE_INIT_CROWDSALE_ADDRESS))[0];
return Object.values(JSON.parse(process.env.REACT_APP_DUTCH_IDX_ADDRESS))[0];
}
static async getEnvAddressRegistryStorage() {
static async getEnvAddressAbstractStorage() {
logger.info("Utils:getEnvAddressRegistryStorage");
require('dotenv').config();
return Object.values(JSON.parse(process.env.REACT_APP_REGISTRY_STORAGE_ADDRESS))[0];
return Object.values(JSON.parse(process.env.REACT_APP_ABSTRACT_STORAGE_ADDRESS))[0];
}
static async getEnvNetworkId() {
@ -353,13 +353,13 @@ class Utils {
logger.info("Utils:getContractAddressInitCrowdsale");
switch (crowdsale.sort) {
case 'minted':
return Utils.getEnvAddressMintedInitCrowdsale();
return Utils.getEnvAddressMintedIDXAddress();
break;
case 'dutch':
return Utils.getEnvAddressDutchInitCrowdsale();
return Utils.getEnvAddressDutchIDXAddress();
break;
default:
return Utils.getEnvAddressMintedInitCrowdsale();
return Utils.getEnvAddressMintedIDXAddress();
}
}