Skip to content

Commit

Permalink
Feature/pool 328 as the governor i wish to add controlled (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
robsecord committed Jul 31, 2020
1 parent 06065c9 commit 8a2e9ef
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions contracts/prize-pool/PrizePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,13 @@ abstract contract PrizePool is OwnableUpgradeSafe, BaseRelayRecipient, Reentranc
}
}

/// @notice Allows the Governor to add Controlled Tokens to the Prize Pool
/// @param _controlledToken The address of the Controlled Token to add
function addControlledToken(address _controlledToken) external onlyOwner {
require(ControlledToken(_controlledToken).controller() == this, "PrizePool/token-ctrlr-mismatch");
_tokens.addAddress(_controlledToken);
}

/// @notice Emergency shutdown of the Prize Pool by detaching the Prize Strategy
/// @dev Called by the PrizeStrategy contract to issue an Emergency Shutdown of a corrupted Prize Strategy
function detachPrizeStrategy() external onlyOwner {
Expand Down
25 changes: 25 additions & 0 deletions test/CompoundPrizePool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,31 @@ describe('CompoundPrizePool', function() {
})
})

describe('addControlledToken()', () => {
let newToken

beforeEach(async () => {
newToken = await deployMockContract(wallet, ControlledToken.abi, overrides)
})

it('should allow owner to add controlled tokens', async () => {
await newToken.mock.controller.returns(prizePool.address)
await expect(prizePool.addControlledToken(newToken.address))
.to.not.be.revertedWith('PrizePool/token-ctrlr-mismatch')
})

it('should not allow adding uncontrolled tokens', async () => {
await newToken.mock.controller.returns(newToken.address)
await expect(prizePool.addControlledToken(newToken.address))
.to.be.revertedWith('PrizePool/token-ctrlr-mismatch')
})

it('should not allow anyone else to call', async () => {
await expect(prizePool.connect(wallet2).addControlledToken(newToken.address))
.to.be.revertedWith('Ownable: caller is not the owner')
})
})

describe('detachPrizeStrategy()', () => {
it('should allow owner to detach', async () => {
await prizePool.detachPrizeStrategy()
Expand Down

0 comments on commit 8a2e9ef

Please sign in to comment.