Skip to content

Commit 32abf73

Browse files
committed
test(protocol-contracts): fix tests
1 parent 5ca7621 commit 32abf73

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

protocol-contracts/staking/contracts/OperatorRewarder.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ contract OperatorRewarder is Ownable {
146146
* @param basisPoints Maximum fee in basis points (max 10000).
147147
*/
148148
function setMaxfee(uint16 basisPoints) public virtual onlyOwner {
149+
require(basisPoints != _maxfeeBasisPoints, MaxFeeAlreadySet(basisPoints, _maxfeeBasisPoints));
150+
149151
_setMaxfee(basisPoints);
150152
}
151153

@@ -155,6 +157,8 @@ contract OperatorRewarder is Ownable {
155157
* @param basisPoints Fee in basis points (cannot be greater than the maximum fee).
156158
*/
157159
function setFee(uint16 basisPoints) public virtual onlyBeneficiary {
160+
require(basisPoints != feeBasisPoints(), FeeAlreadySet(basisPoints, feeBasisPoints()));
161+
158162
_setFee(basisPoints);
159163
}
160164

@@ -320,7 +324,6 @@ contract OperatorRewarder is Ownable {
320324
*/
321325
function _setMaxfee(uint16 basisPoints) internal virtual {
322326
require(basisPoints <= 10000, InvalidBasisPoints(basisPoints));
323-
require(basisPoints != _maxfeeBasisPoints, MaxFeeAlreadySet(basisPoints, _maxfeeBasisPoints));
324327

325328
if (basisPoints < _feeBasisPoints) {
326329
_setFee(basisPoints);
@@ -337,7 +340,6 @@ contract OperatorRewarder is Ownable {
337340
*/
338341
function _setFee(uint16 basisPoints) internal virtual {
339342
require(basisPoints <= 10000, InvalidBasisPoints(basisPoints));
340-
require(basisPoints != feeBasisPoints(), FeeAlreadySet(basisPoints, feeBasisPoints()));
341343
require(basisPoints <= _maxfeeBasisPoints, MaxBasisPointsExceeded(basisPoints, _maxfeeBasisPoints));
342344

343345
_claimFee();

protocol-contracts/staking/test/OperatorRewarder.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ describe('OperatorRewarder', function () {
7575
.withArgs(ethers.ZeroAddress);
7676
});
7777

78+
it('should not transfer beneficiary address to same address', async function () {
79+
await expect(this.mock.connect(this.admin).transferBeneficiary(this.beneficiary.address))
80+
.to.be.revertedWithCustomError(this.mock, 'BeneficiaryAlreadySet')
81+
.withArgs(this.beneficiary.address);
82+
});
83+
7884
it('should not transfer beneficiary address if not owner', async function () {
7985
await expect(this.mock.connect(this.anyone).transferBeneficiary(this.anyone.address))
8086
.to.be.revertedWithCustomError(this.mock, 'OwnableUnauthorizedAccount')
@@ -333,6 +339,13 @@ describe('OperatorRewarder', function () {
333339
.to.be.revertedWithCustomError(this.mock, 'InvalidBasisPoints')
334340
.withArgs(10001);
335341
});
342+
343+
it('should revert if max fee already set', async function () {
344+
await this.mock.connect(this.admin).setMaxfee(1000);
345+
await expect(this.mock.connect(this.admin).setMaxfee(1000))
346+
.to.be.revertedWithCustomError(this.mock, 'MaxFeeAlreadySet')
347+
.withArgs(1000, 1000);
348+
});
336349
});
337350

338351
describe('setFee', async function () {
@@ -389,6 +402,13 @@ describe('OperatorRewarder', function () {
389402
.withArgs(10001);
390403
});
391404

405+
it('should revert if fee already set', async function () {
406+
await this.mock.connect(this.beneficiary).setFee(1000);
407+
await expect(this.mock.connect(this.beneficiary).setFee(1000))
408+
.to.be.revertedWithCustomError(this.mock, 'FeeAlreadySet')
409+
.withArgs(1000, 1000);
410+
});
411+
392412
it('should revert if over max fee', async function () {
393413
await this.mock.connect(this.admin).setMaxfee(1000);
394414
await expect(this.mock.connect(this.beneficiary).setFee(1234))

0 commit comments

Comments
 (0)