-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from skalenetwork/enhancement/SKALE-2347-roun…
…ding-errors Enhancement/skale 2347 rounding errors
- Loading branch information
Showing
66 changed files
with
427 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
pragma solidity 0.5.16; | ||
|
||
import "../utils/MathUtils.sol"; | ||
|
||
|
||
contract MathUtilsTester { | ||
using MathUtils for uint; | ||
|
||
function boundedSub(uint256 a, uint256 b) external returns (uint256) { | ||
return a.boundedSub(b); | ||
} | ||
|
||
function boundedSubWithoutEvent(uint256 a, uint256 b) external pure returns (uint256) { | ||
return a.boundedSubWithoutEvent(b); | ||
} | ||
|
||
function muchGreater(uint256 a, uint256 b) external pure returns (bool) { | ||
return a.muchGreater(b); | ||
} | ||
|
||
function approximatelyEqual(uint256 a, uint256 b) external pure returns (bool) { | ||
return a.approximatelyEqual(b); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
StringUtils.sol - SKALE Manager | ||
Copyright (C) 2018-Present SKALE Labs | ||
@author DmytroStebaiev | ||
SKALE Manager is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
SKALE Manager is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
pragma solidity 0.5.16; | ||
|
||
|
||
library MathUtils { | ||
event UnderflowError( | ||
uint a, | ||
uint b | ||
); | ||
|
||
uint constant EPS = 1e6; | ||
|
||
function boundedSub(uint256 a, uint256 b) internal returns (uint256) { | ||
if (a >= b) { | ||
return a - b; | ||
} else { | ||
emit UnderflowError(a, b); | ||
return 0; | ||
} | ||
} | ||
|
||
function boundedSubWithoutEvent(uint256 a, uint256 b) internal pure returns (uint256) { | ||
if (a >= b) { | ||
return a - b; | ||
} else { | ||
return 0; | ||
} | ||
} | ||
|
||
function muchGreater(uint256 a, uint256 b) internal pure returns (bool) { | ||
assert(uint(-1) - EPS > b); | ||
return a > b + EPS; | ||
} | ||
|
||
function approximatelyEqual(uint256 a, uint256 b) internal pure returns (bool) { | ||
if (a > b) { | ||
return a - b < EPS; | ||
} else { | ||
return b - a < EPS; | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
for file in test/$TESTFOLDERS/* | ||
do | ||
file=${file:7} | ||
if [ ! -f "test/$file" ]; then | ||
file="delegation/$file" | ||
fi | ||
npx buidler coverage --testfiles test/$file --solcoverjs .solcover.js || exit 4 | ||
#!/bin/bash | ||
|
||
npx buidler coverage --solcoverjs .solcover.js || exit $? | ||
bash <(curl -s https://codecov.io/bash) | ||
done |
Oops, something went wrong.