Skip to content

Commit

Permalink
feat: Validate collector is never address(0) (#45)
Browse files Browse the repository at this point in the history
* feat: Validate fee collector is not address 0

* chore: Test that the fee collector is not 0
  • Loading branch information
fzavalia authored Mar 13, 2023
1 parent a3183dd commit 1a23493
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contracts/ens/DCLControllerV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ contract DCLControllerV2 is Ownable {
}

function _setFeeCollector(address _feeCollector) internal {
require(_feeCollector != address(0), "Invalid fee collector");

emit FeeCollectorChanged(feeCollector, _feeCollector);

feeCollector = _feeCollector;
Expand Down
19 changes: 19 additions & 0 deletions test/SubdomainWithDCLControllerV2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,18 @@ describe('DCL Names V2 with DCLControllerV2', function () {
'Registrar should be a contract'
)
})

it('reverts if fee collector is address 0', async function () {
await assertRevert(
DCLControllerV2.new(
manaContract.address,
dclRegistrarContract.address,
ZERO_ADDRESS,
creationParams
),
'Invalid fee collector'
)
})
})

describe('Register', function () {
Expand Down Expand Up @@ -2435,6 +2447,13 @@ describe('DCL Names V2 with DCLControllerV2', function () {
'Ownable: caller is not the owner'
)
})

it('reverts when the fee collector is address 0', async function () {
await assertRevert(
dclControllerContract.setFeeCollector(ZERO_ADDRESS, fromDeployer),
'Invalid fee collector'
)
})
})
})

Expand Down

0 comments on commit 1a23493

Please sign in to comment.