Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #57 from ampleforth/naguib-audit
Browse files Browse the repository at this point in the history
Set maximum limit for reportExpirationTimeSec
  • Loading branch information
ahnaguib authored Apr 29, 2019
2 parents 11e3dec + 8e6ade4 commit a3ce4bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions contracts/MedianOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ contract MedianOracle is Ownable, IOracle {

uint256 public minimumProviders = 1;

// Timestamp of 1 is used to mark uninitialized and invalidated data.
// This is needed so that timestamp of 1 is always considered expired.
uint256 private constant MAX_REPORT_EXPIRATION_TIME = 10 years;

constructor(uint256 reportExpirationTimeSec_,
uint256 reportDelaySec_,
uint256 minimumProviders_)
public
{
require(reportExpirationTimeSec_ <= MAX_REPORT_EXPIRATION_TIME);
require(minimumProviders_ > 0);
reportExpirationTimeSec = reportExpirationTimeSec_;
reportDelaySec = reportDelaySec_;
Expand All @@ -60,6 +65,7 @@ contract MedianOracle is Ownable, IOracle {
external
onlyOwner
{
require(reportExpirationTimeSec_ <= MAX_REPORT_EXPIRATION_TIME);
reportExpirationTimeSec = reportExpirationTimeSec_;
}

Expand Down
3 changes: 3 additions & 0 deletions test/unit/market_oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ contract('MedianOracle:constructor', async function (accounts) {
});

it('should fail if a parameter is invalid', async function () {
expect(await chain.isEthException(oracle = await MedianOracle.new(60, 10, 1))).to.be.false;
expect(await chain.isEthException(MedianOracle.new(60, 10, 0))).to.be.true;
expect(await chain.isEthException(MedianOracle.new(60 * 60 * 24 * 365 * 11, 10, 1))).to.be.true;
expect(await chain.isEthException(oracle.setReportExpirationTimeSec(60 * 60 * 24 * 365 * 11))).to.be.true;
});
});

Expand Down

0 comments on commit a3ce4bb

Please sign in to comment.