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

Commit

Permalink
Dev branch review
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnaguib committed Apr 23, 2019
1 parent e5efb21 commit faacfab
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion contracts/MarketOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ contract MedianOracle is Ownable, IOracle {
// The number of seconds after which the report is deemed expired.
uint256 public reportExpirationTimeSec;

// The number of seconds since reporting that has to pass before a report
// is usable.
uint256 public reportDelaySec;

uint256 public minimumProviders = 1;
Expand All @@ -50,6 +52,7 @@ contract MedianOracle is Ownable, IOracle {
{
reportExpirationTimeSec = reportExpirationTimeSec_;
reportDelaySec = reportDelaySec_;
require(minimumProviders_ > 0);
minimumProviders = minimumProviders_;
}

Expand Down Expand Up @@ -189,7 +192,7 @@ contract MedianOracle is Ownable, IOracle {
* @return The number of providers.
*/
function providersSize()
public
external
view
returns (uint256)
{
Expand Down
2 changes: 1 addition & 1 deletion contracts/lib/Select.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.4.24 ;
pragma solidity ^0.4.24;
import "openzeppelin-solidity/contracts/math/SafeMath.sol";

library Select {
Expand Down
15 changes: 12 additions & 3 deletions test/unit/market_oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ async function setupContractsAndAccounts (accounts) {
oracle = await MedianOracle.new(60, 10, 1);
}

contract('MedianOracle:constructor', async function (accounts) {
before(async function () {
await setupContractsAndAccounts(accounts);
});

it('should fail if a parameter is invalid', async function () {
expect(await chain.isEthException(MedianOracle.new(60, 10, 0))).to.be.true;
});
});

contract('MedianOracle:providersSize', async function (accounts) {
before(async function () {
await setupContractsAndAccounts(accounts);
Expand Down Expand Up @@ -61,11 +71,10 @@ contract('MedianOracle:pushReport', async function (accounts) {
await setupContractsAndAccounts(accounts);
});
it('should only push from authorized source', async function () {
expect(
await chain.isEthException(oracle.pushReport(1000000000000000000, { from: A }))
).to.be.true;
expect(await chain.isEthException(oracle.pushReport(1000000000000000000, { from: A }))).to.be.true;
oracle.addProvider(A, { from: deployer });
await oracle.pushReport(1000000000000000000, { from: A });
// should fail if reportDelaySec did not pass since the previous push
expect(await chain.isEthException(oracle.pushReport(1000000000000000000, { from: A }))).to.be.true;
});
});
Expand Down

0 comments on commit faacfab

Please sign in to comment.