Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions contracts/MedianOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ contract MedianOracle is OwnableUpgradeable, IOracle {
.timestamp;
if (reportTimestampPast < minValidTimestamp) {
// Past report is too old.
emit ReportTimestampOutOfRange(providerAddress);
// Deprecated: emit ReportTimestampOutOfRange(providerAddress);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just remove it, rather than commenting it out. Dont think any of our off-chain services rely on this log.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a good idea to leave so that previous logs are still understandable

} else if (reportTimestampPast > maxValidTimestamp) {
// Past report is too recent.
emit ReportTimestampOutOfRange(providerAddress);
// Deprecated: emit ReportTimestampOutOfRange(providerAddress);
} else {
// Using past report.
validReports[size++] = providerReports[providerAddress][index_past].payload;
Expand All @@ -198,7 +198,7 @@ contract MedianOracle is OwnableUpgradeable, IOracle {
// Recent report is not too recent.
if (reportTimestampRecent < minValidTimestamp) {
// Recent report is too old.
emit ReportTimestampOutOfRange(providerAddress);
// Deprecated: emit ReportTimestampOutOfRange(providerAddress);
} else {
// Using recent report.
validReports[size++] = providerReports[providerAddress][index_recent].payload;
Expand Down
45 changes: 4 additions & 41 deletions test/unit/MedianOracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,7 @@ describe('MedianOracle:getData', async function () {
await oracle.connect(A).pushReport(BigNumber.from('1053200000000000000'))
await increaseTime(10)
})

it('should emit ReportTimestampOutOfRange message', async function () {
await expect(oracle.getData())
.to.emit(oracle, 'ReportTimestampOutOfRange')
.withArgs(await C.getAddress())
})

it('should calculate the exchange rate', async function () {
await expect(callerContract.getData())
.to.emit(callerContract, 'ReturnValueUInt256Bool')
Expand All @@ -355,12 +350,7 @@ describe('MedianOracle:getData', async function () {
await increaseTime(10)
await oracle.connect(B).pushReport(BigNumber.from('1041000000000000000'))
})

it('should emit ReportTimestampOutOfRange message', async function () {
await expect(oracle.getData())
.to.emit(oracle, 'ReportTimestampOutOfRange')
.withArgs(await B.getAddress())
})

it('should calculate the exchange rate', async function () {
await expect(callerContract.getData())
.to.emit(callerContract, 'ReturnValueUInt256Bool')
Expand Down Expand Up @@ -389,12 +379,7 @@ describe('MedianOracle:getData', async function () {
await increaseTime(10)
await oracle.connect(B).pushReport(BigNumber.from('1041000000000000000'))
})

it('should emit ReportTimestampOutOfRange message', async function () {
await expect(oracle.getData())
.to.emit(oracle, 'ReportTimestampOutOfRange')
.withArgs(await B.getAddress())
})

it('should not have a valid result', async function () {
await expect(callerContract.getData())
.to.emit(callerContract, 'ReturnValueUInt256Bool')
Expand All @@ -417,19 +402,7 @@ describe('MedianOracle:getData', async function () {

await increaseTime(61)
})

it('should emit 2 ReportTimestampOutOfRange messages', async function () {
const tx = await oracle.getData()
const txReceipt = await tx.wait()
const txEvents = txReceipt.events?.filter((x: any) => {
return x.event == 'ReportTimestampOutOfRange'
})
expect(txEvents.length).to.equal(2)
const eventA = txEvents[0]
expect(eventA.args.provider).to.equal(await A.getAddress())
const eventB = txEvents[1]
expect(eventB.args.provider).to.equal(await B.getAddress())
})

it('should return false and 0', async function () {
await expect(callerContract.getData())
.to.emit(callerContract, 'ReturnValueUInt256Bool')
Expand All @@ -451,11 +424,6 @@ describe('MedianOracle:getData', async function () {
})

describe('when recent is too recent and past is too old', function () {
it('should emit ReportTimestampOutOfRange message', async function () {
await expect(oracle.getData())
.to.emit(oracle, 'ReportTimestampOutOfRange')
.withArgs(await A.getAddress())
})
it('should fail', async function () {
await expect(callerContract.getData())
.to.emit(callerContract, 'ReturnValueUInt256Bool')
Expand All @@ -478,11 +446,6 @@ describe('MedianOracle:getData', async function () {
})

describe('when recent is too recent and past is too recent', function () {
it('should emit ReportTimestampOutOfRange message', async function () {
await expect(oracle.getData())
.to.emit(oracle, 'ReportTimestampOutOfRange')
.withArgs(await A.getAddress())
})
it('should fail', async function () {
await expect(callerContract.getData())
.to.emit(callerContract, 'ReturnValueUInt256Bool')
Expand Down