diff --git a/contracts/schemes/Locking4Reputation.sol b/contracts/schemes/Locking4Reputation.sol index 1ab1b83d..542de34e 100644 --- a/contracts/schemes/Locking4Reputation.sol +++ b/contracts/schemes/Locking4Reputation.sol @@ -117,6 +117,9 @@ contract Locking4Reputation { uint256 score = _period.mul(_amount).mul(_numerator).div(_denominator); require(score > 0, "score must me > 0"); scores[_locker] = scores[_locker].add(score); + //verify that redeem will not overflow for this locker + require((scores[_locker] * reputationReward)/scores[_locker] == reputationReward, + "score is too high"); totalScore = totalScore.add(score); emit Lock(_locker, lockingId, _amount, _period); diff --git a/package-lock.json b/package-lock.json index 75a205f3..e87e0916 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc", - "version": "0.0.1-rc.6", + "version": "0.0.1-rc.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ca33f466..5a4e9376 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc", - "version": "0.0.1-rc.6", + "version": "0.0.1-rc.7", "description": "A platform for building DAOs", "files": [ "contracts/", @@ -16,7 +16,7 @@ }, "scripts": { "test": "cross-conf-env run-with-ganache --ganache-cmd 'npm run ganache' 'npm run truffle compile && npm run truffle migrate && npm run truffle test'", - "ganache": "cross-conf-env ganache-cli --gasLimit npm_package_config_gasLimit --account=\"0x0191ecbd1b150b8a3c27c27010ba51b45521689611e669109e034fd66ae69621,9999999999999999999999999999999999999999999\" --account=\"0x00f360233e89c65970a41d4a85990ec6669526b2230e867c352130151453180d,9999999999999999999999999999999999999999999\" --account=\"0x987a26abca7432016104ce2f24ce639340e25afe06ac69f68791399e7a5d1028,9999999999999999999999999999999999999999999\" --account=\"0x89af34b1b7347834048b99423dad174a14bf14540d720d72c16ae92e94b987cb,9999999999999999999999999999999999999999999\" --account=\"0xc867be647eb2bc51e4c0d61066859875cf3634fe949b6f5f85c69ab90e485b37,9999999999999999999999999999999999999999999\" --account=\"0xefabcc2377dee5e51b5a9e65a3854aec85fbbec3cb584d8ad4f9679869fb33c6,9999999999999999999999999999999999999999999\"", + "ganache": "cross-conf-env ganache-cli --gasLimit npm_package_config_gasLimit --account=\"0x0191ecbd1b150b8a3c27c27010ba51b45521689611e669109e034fd66ae69621,0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\" --account=\"0x00f360233e89c65970a41d4a85990ec6669526b2230e867c352130151453180d,9999999999999999999999999999999999999999999\" --account=\"0x987a26abca7432016104ce2f24ce639340e25afe06ac69f68791399e7a5d1028,9999999999999999999999999999999999999999999\" --account=\"0x89af34b1b7347834048b99423dad174a14bf14540d720d72c16ae92e94b987cb,9999999999999999999999999999999999999999999\" --account=\"0xc867be647eb2bc51e4c0d61066859875cf3634fe949b6f5f85c69ab90e485b37,9999999999999999999999999999999999999999999\" --account=\"0xefabcc2377dee5e51b5a9e65a3854aec85fbbec3cb584d8ad4f9679869fb33c6,9999999999999999999999999999999999999999999\"", "start": "pm2 start truffle -- serve", "lint": "eslint .", "lint --fix": "eslint --fix .", diff --git a/test/lockingeth4reputation.js b/test/lockingeth4reputation.js index 614b8bfc..766eed01 100644 --- a/test/lockingeth4reputation.js +++ b/test/lockingeth4reputation.js @@ -61,6 +61,20 @@ contract('LockingEth4Reputation', accounts => { }); + it("score too high", async () => { + let testSetup = await setup(accounts); + let BigNumber = require('bignumber.js'); + BigNumber.set({ DECIMAL_PLACES: 0, ROUNDING_MODE: 4 }); + let maxUint = ((new BigNumber(2)).toPower(256).sub(1)).div(100).add(1); + try { + await testSetup.lockingEth4Reputation.lock(1,{value:maxUint.toString(10)}); + assert(false, "score too high should revert"); + } catch(error) { + helpers.assertVMException(error); + } + + }); + it("cannot lock without initialize", async () => { let testSetup = await setup(accounts,100,0,3000,3000,6000,false); try {