diff --git a/contracts/modules/STO/PreSaleSTO.sol b/contracts/modules/STO/PreSaleSTO.sol index 65f1b00ad..5e518bea0 100644 --- a/contracts/modules/STO/PreSaleSTO.sol +++ b/contracts/modules/STO/PreSaleSTO.sol @@ -77,8 +77,10 @@ contract PreSaleSTO is ISTO { require(now <= endTime, "Current time should less than the endTime"); require(_amount > 0, "No. of tokens provided should be greater the zero"); ISecurityToken(securityToken).mint(_investor, _amount); + if (investors[_investor] == uint256(0)) { + investorCount = investorCount.add(1); + } investors[_investor] = investors[_investor].add(_amount); - investorCount = investorCount.add(1); fundsRaised[uint8(FundRaiseType.ETH)] = fundsRaised[uint8(FundRaiseType.ETH)].add(_etherContributed); fundsRaised[uint8(FundRaiseType.POLY)] = fundsRaised[uint8(FundRaiseType.POLY)].add(_polyContributed); totalTokensSold = totalTokensSold.add(_amount); diff --git a/test/m_presale_sto.js b/test/m_presale_sto.js index acc282ca2..e21ac6df3 100644 --- a/test/m_presale_sto.js +++ b/test/m_presale_sto.js @@ -352,7 +352,13 @@ contract("PreSaleSTO", accounts => { ); }); - it("Should failed at the time of buying the tokens -- Because STO has started", async () => { + it("Should buy some more tokens to previous investor", async() => { + await I_PreSaleSTO.allocateTokens(account_investor1, web3.utils.toWei("1000", "ether"), web3.utils.toWei("1", "ether"), 0, { from: account_issuer }); + // No change in the investor count + assert.equal((await I_PreSaleSTO.getNumberInvestors.call()).toNumber(), 3); + }) + + it("Should failed at the time of buying the tokens -- Because STO has ended", async () => { await increaseTime(duration.days(100)); // increased beyond the end time of the STO await catchRevert(