Skip to content

Commit c150045

Browse files
satyamakgecpabloruiz55
authored andcommitted
fix the investor count (#366)
1 parent 1190a4e commit c150045

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

contracts/modules/STO/PreSaleSTO.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ contract PreSaleSTO is ISTO {
7777
require(now <= endTime, "Current time should less than the endTime");
7878
require(_amount > 0, "No. of tokens provided should be greater the zero");
7979
ISecurityToken(securityToken).mint(_investor, _amount);
80+
if (investors[_investor] == uint256(0)) {
81+
investorCount = investorCount.add(1);
82+
}
8083
investors[_investor] = investors[_investor].add(_amount);
81-
investorCount = investorCount.add(1);
8284
fundsRaised[uint8(FundRaiseType.ETH)] = fundsRaised[uint8(FundRaiseType.ETH)].add(_etherContributed);
8385
fundsRaised[uint8(FundRaiseType.POLY)] = fundsRaised[uint8(FundRaiseType.POLY)].add(_polyContributed);
8486
totalTokensSold = totalTokensSold.add(_amount);

test/m_presale_sto.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,13 @@ contract("PreSaleSTO", accounts => {
352352
);
353353
});
354354

355-
it("Should failed at the time of buying the tokens -- Because STO has started", async () => {
355+
it("Should buy some more tokens to previous investor", async() => {
356+
await I_PreSaleSTO.allocateTokens(account_investor1, web3.utils.toWei("1000", "ether"), web3.utils.toWei("1", "ether"), 0, { from: account_issuer });
357+
// No change in the investor count
358+
assert.equal((await I_PreSaleSTO.getNumberInvestors.call()).toNumber(), 3);
359+
})
360+
361+
it("Should failed at the time of buying the tokens -- Because STO has ended", async () => {
356362
await increaseTime(duration.days(100)); // increased beyond the end time of the STO
357363

358364
await catchRevert(

0 commit comments

Comments
 (0)