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 #69 from ampleforth/naguib-push-log
Browse files Browse the repository at this point in the history
Add ProviderReportPushed log
  • Loading branch information
ahnaguib authored May 31, 2019
2 parents 3fe6042 + 0050294 commit 5e0a501
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions contracts/MedianOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ contract MedianOracle is Ownable, IOracle {
event ProviderAdded(address provider);
event ProviderRemoved(address provider);
event ReportTimestampOutOfRange(address provider);
event ProviderReportPushed(address indexed provider, uint256 payload, uint256 timestamp);

// The number of seconds after which the report is deemed expired.
uint256 public reportExpirationTimeSec;
Expand Down Expand Up @@ -129,6 +130,8 @@ contract MedianOracle is Ownable, IOracle {

reports[index_past].timestamp = now;
reports[index_past].payload = payload;

emit ProviderReportPushed(providerAddress, payload, now);
}

/**
Expand Down
11 changes: 10 additions & 1 deletion test/unit/median_oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,19 @@ contract('MedianOracle:pushReport', async function (accounts) {
it('should only push from authorized source', async function () {
expect(await chain.isEthException(oracle.pushReport(1000000000000000000, { from: A }))).to.be.true;
oracle.addProvider(A, { from: deployer });
await oracle.pushReport(1000000000000000000, { from: A });
r = 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;
});
it('should emit ProviderReportPushed message', async function () {
const logs = r.logs;
const event = logs[0];
expect(event.event).to.eq('ProviderReportPushed');
expect(event.args.provider).to.eq(A);
event.args.payload.should.be.bignumber.eq(1000000000000000000);
const block = await chain.web3.eth.getBlock(logs[0].blockNumber);
event.args.timestamp.should.be.bignumber.eq(block.timestamp);
});
});

contract('MedianOracle:addProvider:accessControl', async function (accounts) {
Expand Down

0 comments on commit 5e0a501

Please sign in to comment.