Skip to content

Commit

Permalink
fix the investor count (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
satyamakgec authored and pabloruiz55 committed Oct 22, 2018
1 parent 1190a4e commit c150045
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion contracts/modules/STO/PreSaleSTO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion test/m_presale_sto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c150045

Please sign in to comment.