diff --git a/contracts/MedianOracle.sol b/contracts/MedianOracle.sol index 52b4200..bce5046 100644 --- a/contracts/MedianOracle.sol +++ b/contracts/MedianOracle.sol @@ -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; @@ -129,6 +130,8 @@ contract MedianOracle is Ownable, IOracle { reports[index_past].timestamp = now; reports[index_past].payload = payload; + + emit ProviderReportPushed(providerAddress, payload, now); } /** diff --git a/test/unit/median_oracle.js b/test/unit/median_oracle.js index 16938b6..c51fcc0 100644 --- a/test/unit/median_oracle.js +++ b/test/unit/median_oracle.js @@ -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) {