diff --git a/.gitmodules b/.gitmodules index 61c462c2a..c1923368c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,7 @@ path = submodules/poa-token-market-net-ico url = https://github.com/poanetwork/ico branch = wizard +[submodule "submodules/token-wizard-test-automation"] + path = submodules/token-wizard-test-automation + url = https://github.com/poanetwork/token-wizard-test-automation + branch = master diff --git a/.travis.yml b/.travis.yml index 77bc3da15..84b2dc5ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,15 @@ install: before_script: - npm run installWeb3 + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - sleep 3 + - wget -N http://chromedriver.storage.googleapis.com/2.30/chromedriver_linux64.zip -P ~/ + - unzip ~/chromedriver_linux64.zip -d ~/ + - rm ~/chromedriver_linux64.zip + - sudo mv -f ~/chromedriver /usr/local/share/ + - sudo chmod +x /usr/local/share/chromedriver + - sudo ln -s /usr/local/share/chromedriver /usr/local/bin/chromedriver script: - npm run lint diff --git a/package.json b/package.json index e41096b43..4c8917ce3 100755 --- a/package.json +++ b/package.json @@ -123,8 +123,9 @@ "deployRegistry": "node scripts/deployRegistry.js", "startWin": "npm run installWeb3 && npm run generateFlatSoliditySafeMathLibContractWin && npm run generateFlatSolidityCrowdsaleNullFinalizeAgentContractWin && npm run generateFlatSolidityCrowdsaleFinalizeAgentContractWin && npm run generateFlatSolidityCrowdsaleContractWin && npm run generateFlatSolidityCrowdsaleTokenContractWin && npm run generateFlatSolidityCrowdsalePricingStrategyContractWin && npm run compileSafeMathLibExtContractWin && npm run compileCrowdsaleNullFinalizeAgentContractWin && npm run compileCrowdsaleFinalizeAgentContractWin && npm run compileCrowdsaleContractWin && npm run compileCrowdsaleTokenContractWin && npm run compileCrowdsalePricingStrategyContractWin && node scripts/start.js", "build": "git submodule update --init --recursive --remote && cd submodules/solidity-flattener && npm install && cd ../../ && npm install && cd submodules/poa-web3-1.0 && npm install && cd ../../ && npm install --no-save submodules/poa-web3-1.0/packages/web3 && npm run generateContracts && npm run compileContracts && node scripts/build.js && cp ./build/index.html ./build/invest.html && cp ./build/index.html ./build/crowdsale.html && cp ./build/index.html ./build/manage.html", - "test": "bash ./start_testrpc.sh && cd ./submodules/poa-token-market-net-ico/ && npm install && node_modules/.bin/truffle migrate --network testrpc && node_modules/.bin/truffle test --network testrpc", + "test": "npm run test:e2e && bash ./start_testrpc.sh && cd ./submodules/poa-token-market-net-ico/ && npm install && node_modules/.bin/truffle migrate --network testrpc && node_modules/.bin/truffle test --network testrpc", "test:dapp": "jest --env=jsdom", + "test:e2e": "cd submodules/token-wizard-test-automation && npm i && npm run test1", "coveralls": "jest --env=jsdom --coverage && cat coverage/lcov.info | coveralls", "generateContracts": "npm run generateFlatSoliditySafeMathLibContract && npm run generateFlatSolidityCrowdsaleNullFinalizeAgentContract && npm run generateFlatSolidityCrowdsaleFinalizeAgentContract && npm run generateFlatSolidityCrowdsaleContract && npm run generateFlatSolidityCrowdsaleTokenContract && npm run generateFlatSolidityCrowdsalePricingStrategyContract && npm run generateFlatSolidityRegistryContract", "generateFlatSoliditySafeMathLibContract": "node $npm_package_config_combine_solidity_script $npm_package_config_tokenmarketnet_path/$npm_package_config_safe_math_lib_contract_name.sol $npm_package_config_contract_folder SafeMathLibExt", diff --git a/src/components/Common/WhitelistInputBlock.js b/src/components/Common/WhitelistInputBlock.js index bf9fc06fc..33ade245c 100644 --- a/src/components/Common/WhitelistInputBlock.js +++ b/src/components/Common/WhitelistInputBlock.js @@ -6,9 +6,10 @@ import Papa from 'papaparse' import '../../assets/stylesheets/application.css'; import { InputField } from './InputField' import { TEXT_FIELDS, VALIDATION_TYPES } from '../../utils/constants' -import { validateAddress } from '../../utils/utils' import { WhitelistItem } from './WhitelistItem' import { inject, observer } from 'mobx-react' +import { whitelistImported } from '../../utils/alerts' +import processWhitelist from '../../utils/processWhitelist' const { ADDRESS, MIN, MAX } = TEXT_FIELDS const {VALID, INVALID} = VALIDATION_TYPES; @@ -80,23 +81,16 @@ export class WhitelistInputBlock extends React.Component { this.setState(newState) } - isAddress = (address) => validateAddress(address) - isNumber = (number) => !isNaN(parseFloat(number)) - onDrop = (acceptedFiles, rejectedFiles) => { acceptedFiles.forEach(file => { Papa.parse(file, { skipEmptyLines: true, complete: results => { - results.data.forEach((row) => { - if (row.length !== 3) return - - const [addr, min, max] = row - - if (!this.isAddress(addr) || !this.isNumber(min) || !this.isNumber(max)) return - - this.props.tierStore.addWhitelistItem({ addr, min, max }, this.props.num) + const { called } = processWhitelist(results.data, item => { + this.props.tierStore.addWhitelistItem(item, this.props.num) }) + + whitelistImported(called) } }) }) diff --git a/src/components/manage/index.js b/src/components/manage/index.js index ca9ebfe57..d85017850 100644 --- a/src/components/manage/index.js +++ b/src/components/manage/index.js @@ -193,15 +193,24 @@ export class Manage extends Component { const lastCrowdsaleAddress = contractStore.crowdsale.addr.slice(-1)[0] return attachToContract(contractStore.crowdsale.abi, lastCrowdsaleAddress) - .then(crowdsaleContract => crowdsaleContract.methods.isCrowdsaleFull().call()) - .then( - (isCrowdsaleFull) => { - const { crowdsaleHasEnded, shouldDistribute, canDistribute } = this.state - const wasDistributed = shouldDistribute && !canDistribute + .then(crowdsaleContract => { + const whenIsFinalized = crowdsaleContract.methods.finalized().call() + const whenIsCrowdsaleFull = crowdsaleContract.methods.isCrowdsaleFull().call() - this.setState({ - canFinalize: (crowdsaleHasEnded || isCrowdsaleFull) && (wasDistributed || !shouldDistribute) - }) + return Promise.all([whenIsFinalized, whenIsCrowdsaleFull]) + }) + .then( + ([isFinalized, isCrowdsaleFull]) => { + if (isFinalized) { + this.setState({ canFinalize: false }) + } else { + const { crowdsaleHasEnded, shouldDistribute, canDistribute } = this.state + const wasDistributed = shouldDistribute && !canDistribute + + this.setState({ + canFinalize: (crowdsaleHasEnded || isCrowdsaleFull) && (wasDistributed || !shouldDistribute) + }) + } }, () => this.setState({ canFinalize: false }) ) @@ -293,9 +302,13 @@ export class Manage extends Component { return sendTXToContract(finalizeMethod.send(opts)) }) .then(() => { - successfulFinalizeAlert() crowdsaleStore.setSelectedProperty('finalized', true) - this.setState({ canFinalize: false }) + this.setState({ canFinalize: false }, () => { + successfulFinalizeAlert().then(() => { + this.setState({ loading: true }) + setTimeout(() => window.location.reload(), 500) + }) + }) }) .catch((err) => { console.log(err) @@ -446,7 +459,7 @@ export class Manage extends Component { tierHasStarted = (index) => { const initialTierValues = this.props.crowdsaleStore.selected.initialTiersValues[index] - return initialTierValues ? Date.now() > new Date(initialTierValues.startTime).getTime() : true + return initialTierValues && new Date(initialTierValues.startTime).getTime() < Date.now() } tierHasEnded = (index) => { @@ -458,7 +471,8 @@ export class Manage extends Component { const { formPristine, canFinalize, shouldDistribute, canDistribute, crowdsaleHasEnded, ownerCurrentUser } = this.state const { generalStore, tierStore, tokenStore, crowdsaleStore } = this.props const { address: crowdsaleAddress, finalized, updatable } = crowdsaleStore.selected - let disabled = !ownerCurrentUser || canDistribute || canFinalize || finalized + + const canEditTier = ownerCurrentUser && !canDistribute && !canFinalize && !finalized const distributeTokensStep = (