Skip to content

Commit

Permalink
Fixes OZ Audit 2 issues M01 and L02
Browse files Browse the repository at this point in the history
  • Loading branch information
asselstine committed Oct 15, 2020
1 parent 711585c commit 435c0e8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 3 additions & 1 deletion buidler.config.js
Expand Up @@ -22,11 +22,13 @@ const testnetUser1 = '0x573bd3868b7672332c4D22076f55Cb0b597eb5Fd' // Account 3
const testnetUser2 = '0x7Cfc5a12506d92F29D52EC7B8d1148f46e9296ED' // Account 4
const testnetUser3 = '0x50D6d6195b102f9b58A29a57E3D71822881033a5' // Account 5

const optimizerEnabled = !process.env.OPTIMIZER_DISABLED

const config = {
solc: {
version: "0.6.12",
optimizer: {
enabled: true,
enabled: optimizerEnabled,
runs: 200
},
evmVersion: "istanbul"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -11,7 +11,7 @@
"reinstall": "rm -rf node_modules/ && rm -f yarn.lock && yarn",
"verify": "yarn hint && yarn test",
"hint": "solhint \"contracts/**/*.sol\"",
"test": "buidler test",
"test": "OPTIMIZER_DISABLED=true buidler test",
"compile": "buidler --show-stack-traces --max-memory 8192 compile",
"start": "buidler node --port $LOCAL_BUIDLEREVM_PORT",
"coverage": "rm -rf build cache test-results.xml && buidler coverage --network coverage --temp build",
Expand Down
20 changes: 20 additions & 0 deletions test/PrizePool.test.js
Expand Up @@ -227,6 +227,26 @@ describe('PrizePool', function() {
})

describe('captureAwardBalance()', () => {
it('should handle when the balance is less than the collateral', async () => {
await ticket.mock.totalSupply.returns(toWei('100'))
await yieldSourceStub.mock.balance.returns(toWei('99.9999'))

await expect(prizePool.captureAwardBalance()).to.not.emit(prizePool, 'ReserveFeeCaptured');
expect(await prizePool.awardBalance()).to.equal(toWei('0'))
})

it('should handle the situ when the total accrued interest is less than the captured total', async () => {
await ticket.mock.totalSupply.returns(toWei('100'))
await yieldSourceStub.mock.balance.returns(toWei('110'))

await comptroller.mock.reserveRateMantissa.returns('0')

// first capture the 10 tokens
await prizePool.captureAwardBalance()

await yieldSourceStub.mock.balance.returns(toWei('109.999'))
})

it('should track the yield less the total token supply', async () => {
await ticket.mock.totalSupply.returns(toWei('100'))
await yieldSourceStub.mock.balance.returns(toWei('110'))
Expand Down

0 comments on commit 435c0e8

Please sign in to comment.