Skip to content

Commit

Permalink
test: hash consensus version getter
Browse files Browse the repository at this point in the history
  • Loading branch information
manneredboor committed Feb 8, 2023
1 parent 60357af commit 7cba25b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,8 @@ contract HashConsensusTimeTravellable is HashConsensus {
function getReportProcessor() external view returns (address) {
return _reportProcessor;
}

function getConsensusVersion() external view returns (uint256) {
return _getConsensusVersion();
}
}
30 changes: 29 additions & 1 deletion test/0.8.9/oracle/hash-consensus-report-processor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const {
ZERO_HASH, HASH_1, HASH_2, HASH_3, HASH_4, HASH_5,
CONSENSUS_VERSION, deployHashConsensus} = require('./hash-consensus-deploy.test')

const CONSENSUS_VERSION_2 = 2

const HashConsensus = artifacts.require('HashConsensusTimeTravellable')
const MockReportProcessor = artifacts.require('MockReportProcessor')

Expand All @@ -28,7 +30,7 @@ contract('HashConsensus', ([admin, member1, member2, member3, member4, member5,
const deployed = await deployHashConsensus(admin, options)
consensus = deployed.consensus
reportProcessor1 = deployed.reportProcessor
reportProcessor2 = await MockReportProcessor.new(CONSENSUS_VERSION, { from: admin })
reportProcessor2 = await MockReportProcessor.new(CONSENSUS_VERSION_2, { from: admin })
}

const deployProcessorZero = async () => {
Expand All @@ -45,6 +47,13 @@ contract('HashConsensus', ([admin, member1, member2, member3, member4, member5,
'there should be zero address for processor',
)
})

it('consensus version equals zero', async () => {
assert.equal(
await consensus.getConsensusVersion(),
0,
)
})
})

context('with initial processor', () => {
Expand Down Expand Up @@ -87,6 +96,25 @@ contract('HashConsensus', ([admin, member1, member2, member3, member4, member5,
assertEvent(tx, 'ReportProcessorSet', {expectedArgs: {processor: reportProcessor2.address, prevProcessor: reportProcessor1.address}})
})
})

context('consensus version', () => {
beforeEach(deploy)

it('equals to version of initial processor', async () => {
assert.equal(
await consensus.getConsensusVersion(),
CONSENSUS_VERSION,
)
})

it('equals to new processor version after it was changed', async () => {
await consensus.setReportProcessor(reportProcessor2.address)
assert.equal(
await consensus.getConsensusVersion(),
CONSENSUS_VERSION_2,
)
})
})
})
})
})

0 comments on commit 7cba25b

Please sign in to comment.