Skip to content

Commit

Permalink
test: AccountingOracle.submitReportData fills ExtraDataProcessingStat…
Browse files Browse the repository at this point in the history
…e after call
  • Loading branch information
manneredboor committed Feb 13, 2023
1 parent 12baa27 commit 53be633
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ contract AccountingOracleTimeTravellable is AccountingOracle, ITimeProvider {
address consensus = CONSENSUS_CONTRACT_POSITION.getStorageAddress();
return ITimeProvider(consensus).getTime();
}

function getExtraDataProcessingState() external view returns (ExtraDataProcessingState memory) {
return _storageExtraDataProcessingState().value;
}
}
26 changes: 25 additions & 1 deletion test/0.8.9/oracle/accounting-oracle-submit-report-data.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const {
EXTRA_DATA_FORMAT_LIST,
SLOTS_PER_FRAME,
SECONDS_PER_SLOT,
GENESIS_TIME
GENESIS_TIME,
ZERO_HASH
} = require('./accounting-oracle-deploy.test')

contract('AccountingOracle', ([admin, account1, account2, member1, member2, stranger]) => {
Expand Down Expand Up @@ -491,5 +492,28 @@ contract('AccountingOracle', ([admin, account1, account2, member1, member2, stra
)
})
})

context('ExtraDataProcessingState', () => {
it('should be empty from start', async () => {
const data = await oracle.getExtraDataProcessingState()
assert.equals(data.refSlot, '0')
assert.equals(data.dataFormat, '0')
assert.equals(data.itemsCount, '0')
assert.equals(data.itemsProcessed, '0')
assert.equals(data.lastSortingKey, '0')
assert.equals(data.dataHash, ZERO_HASH)
})

it('should be filled with report data after submitting', async () => {
await oracle.submitReportData(reportItems, oracleVersion, { from: member1 })
const data = await oracle.getExtraDataProcessingState()
assert.equals(data.refSlot, reportFields.refSlot)
assert.equals(data.dataFormat, reportFields.extraDataFormat)
assert.equals(data.itemsCount, reportFields.extraDataItemsCount)
assert.equals(data.itemsProcessed, '0')
assert.equals(data.lastSortingKey, '0')
assert.equals(data.dataHash, reportFields.extraDataHash)
})
})
})
})

0 comments on commit 53be633

Please sign in to comment.