Skip to content

Commit dda5b9f

Browse files
authored
Merge pull request #281 from ampleforth/GetData_readonly
Remove emit ReportTimestampOutOfRange so getData is read only
2 parents 1068015 + 27bee44 commit dda5b9f

File tree

2 files changed

+7
-44
lines changed

2 files changed

+7
-44
lines changed

contracts/MedianOracle.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ contract MedianOracle is OwnableUpgradeable, IOracle {
186186
.timestamp;
187187
if (reportTimestampPast < minValidTimestamp) {
188188
// Past report is too old.
189-
emit ReportTimestampOutOfRange(providerAddress);
189+
// Deprecated: emit ReportTimestampOutOfRange(providerAddress);
190190
} else if (reportTimestampPast > maxValidTimestamp) {
191191
// Past report is too recent.
192-
emit ReportTimestampOutOfRange(providerAddress);
192+
// Deprecated: emit ReportTimestampOutOfRange(providerAddress);
193193
} else {
194194
// Using past report.
195195
validReports[size++] = providerReports[providerAddress][index_past].payload;
@@ -198,7 +198,7 @@ contract MedianOracle is OwnableUpgradeable, IOracle {
198198
// Recent report is not too recent.
199199
if (reportTimestampRecent < minValidTimestamp) {
200200
// Recent report is too old.
201-
emit ReportTimestampOutOfRange(providerAddress);
201+
// Deprecated: emit ReportTimestampOutOfRange(providerAddress);
202202
} else {
203203
// Using recent report.
204204
validReports[size++] = providerReports[providerAddress][index_recent].payload;

test/unit/MedianOracle.ts

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,7 @@ describe('MedianOracle:getData', async function () {
324324
await oracle.connect(A).pushReport(BigNumber.from('1053200000000000000'))
325325
await increaseTime(10)
326326
})
327-
328-
it('should emit ReportTimestampOutOfRange message', async function () {
329-
await expect(oracle.getData())
330-
.to.emit(oracle, 'ReportTimestampOutOfRange')
331-
.withArgs(await C.getAddress())
332-
})
327+
333328
it('should calculate the exchange rate', async function () {
334329
await expect(callerContract.getData())
335330
.to.emit(callerContract, 'ReturnValueUInt256Bool')
@@ -355,12 +350,7 @@ describe('MedianOracle:getData', async function () {
355350
await increaseTime(10)
356351
await oracle.connect(B).pushReport(BigNumber.from('1041000000000000000'))
357352
})
358-
359-
it('should emit ReportTimestampOutOfRange message', async function () {
360-
await expect(oracle.getData())
361-
.to.emit(oracle, 'ReportTimestampOutOfRange')
362-
.withArgs(await B.getAddress())
363-
})
353+
364354
it('should calculate the exchange rate', async function () {
365355
await expect(callerContract.getData())
366356
.to.emit(callerContract, 'ReturnValueUInt256Bool')
@@ -389,12 +379,7 @@ describe('MedianOracle:getData', async function () {
389379
await increaseTime(10)
390380
await oracle.connect(B).pushReport(BigNumber.from('1041000000000000000'))
391381
})
392-
393-
it('should emit ReportTimestampOutOfRange message', async function () {
394-
await expect(oracle.getData())
395-
.to.emit(oracle, 'ReportTimestampOutOfRange')
396-
.withArgs(await B.getAddress())
397-
})
382+
398383
it('should not have a valid result', async function () {
399384
await expect(callerContract.getData())
400385
.to.emit(callerContract, 'ReturnValueUInt256Bool')
@@ -417,19 +402,7 @@ describe('MedianOracle:getData', async function () {
417402

418403
await increaseTime(61)
419404
})
420-
421-
it('should emit 2 ReportTimestampOutOfRange messages', async function () {
422-
const tx = await oracle.getData()
423-
const txReceipt = await tx.wait()
424-
const txEvents = txReceipt.events?.filter((x: any) => {
425-
return x.event == 'ReportTimestampOutOfRange'
426-
})
427-
expect(txEvents.length).to.equal(2)
428-
const eventA = txEvents[0]
429-
expect(eventA.args.provider).to.equal(await A.getAddress())
430-
const eventB = txEvents[1]
431-
expect(eventB.args.provider).to.equal(await B.getAddress())
432-
})
405+
433406
it('should return false and 0', async function () {
434407
await expect(callerContract.getData())
435408
.to.emit(callerContract, 'ReturnValueUInt256Bool')
@@ -451,11 +424,6 @@ describe('MedianOracle:getData', async function () {
451424
})
452425

453426
describe('when recent is too recent and past is too old', function () {
454-
it('should emit ReportTimestampOutOfRange message', async function () {
455-
await expect(oracle.getData())
456-
.to.emit(oracle, 'ReportTimestampOutOfRange')
457-
.withArgs(await A.getAddress())
458-
})
459427
it('should fail', async function () {
460428
await expect(callerContract.getData())
461429
.to.emit(callerContract, 'ReturnValueUInt256Bool')
@@ -478,11 +446,6 @@ describe('MedianOracle:getData', async function () {
478446
})
479447

480448
describe('when recent is too recent and past is too recent', function () {
481-
it('should emit ReportTimestampOutOfRange message', async function () {
482-
await expect(oracle.getData())
483-
.to.emit(oracle, 'ReportTimestampOutOfRange')
484-
.withArgs(await A.getAddress())
485-
})
486449
it('should fail', async function () {
487450
await expect(callerContract.getData())
488451
.to.emit(callerContract, 'ReturnValueUInt256Bool')

0 commit comments

Comments
 (0)