Skip to content

Commit

Permalink
test: fix failing fuzz tests
Browse files Browse the repository at this point in the history
  • Loading branch information
0xrajath committed Nov 13, 2024
1 parent caf848c commit d23fc47
Showing 1 changed file with 43 additions and 14 deletions.
57 changes: 43 additions & 14 deletions src/test/unit/RewardsCoordinatorUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,11 @@ contract RewardsCoordinatorUnitTests_initializeAndSetters is RewardsCoordinatorU

contract RewardsCoordinatorUnitTests_setOperatorAVSSplit is RewardsCoordinatorUnitTests {
// Revert when paused
function testFuzz_Revert_WhenPaused(address operator, address avs, uint16 split) public {
function testFuzz_Revert_WhenPaused(
address operator,
address avs,
uint16 split
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
split = uint16(bound(split, 0, ONE_HUNDRED_IN_BIPS));
cheats.prank(pauser);
Expand All @@ -401,7 +405,11 @@ contract RewardsCoordinatorUnitTests_setOperatorAVSSplit is RewardsCoordinatorUn
}

// Revert when operator is not caller
function testFuzz_Revert_WhenOperatorIsNotMsgSender(address operator, address avs, uint16 split) public {
function testFuzz_Revert_WhenOperatorIsNotMsgSender(
address operator,
address avs,
uint16 split
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0) && operator != address(this));
split = uint16(bound(split, 0, ONE_HUNDRED_IN_BIPS));

Expand All @@ -410,7 +418,11 @@ contract RewardsCoordinatorUnitTests_setOperatorAVSSplit is RewardsCoordinatorUn
}

// Revert when split is greater than 100%
function testFuzz_Revert_WhenSplitGreaterThan100(address operator, address avs, uint16 split) public {
function testFuzz_Revert_WhenSplitGreaterThan100(
address operator,
address avs,
uint16 split
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
split = uint16(bound(split, ONE_HUNDRED_IN_BIPS + 1, type(uint16).max));

Expand All @@ -419,7 +431,11 @@ contract RewardsCoordinatorUnitTests_setOperatorAVSSplit is RewardsCoordinatorUn
rewardsCoordinator.setOperatorAVSSplit(operator, avs, split);
}

function testFuzz_setOperatorAVSSplit(address operator, address avs, uint16 split) public {
function testFuzz_setOperatorAVSSplit(
address operator,
address avs,
uint16 split
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
split = uint16(bound(split, 0, ONE_HUNDRED_IN_BIPS));
uint32 activatedAt = uint32(block.timestamp) + activationDelay;
Expand All @@ -436,7 +452,11 @@ contract RewardsCoordinatorUnitTests_setOperatorAVSSplit is RewardsCoordinatorUn
}

// Testing that the split has been initialized for the first time.
function testFuzz_setOperatorAVSSplitFirstTime(address operator, address avs, uint16 split) public {
function testFuzz_setOperatorAVSSplitFirstTime(
address operator,
address avs,
uint16 split
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
split = uint16(bound(split, 0, ONE_HUNDRED_IN_BIPS));
uint32 activatedAt = uint32(block.timestamp) + activationDelay;
Expand All @@ -460,7 +480,7 @@ contract RewardsCoordinatorUnitTests_setOperatorAVSSplit is RewardsCoordinatorUn
uint16 firstSplit,
uint16 secondSplit,
uint32 warpTime
) public {
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
firstSplit = uint16(bound(firstSplit, 0, ONE_HUNDRED_IN_BIPS));
secondSplit = uint16(bound(secondSplit, 0, ONE_HUNDRED_IN_BIPS));
Expand Down Expand Up @@ -492,7 +512,7 @@ contract RewardsCoordinatorUnitTests_setOperatorAVSSplit is RewardsCoordinatorUn
uint16 firstSplit,
uint16 secondSplit,
uint32 warpTime
) public {
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
firstSplit = uint16(bound(firstSplit, 0, ONE_HUNDRED_IN_BIPS));
secondSplit = uint16(bound(secondSplit, 0, ONE_HUNDRED_IN_BIPS));
Expand Down Expand Up @@ -521,7 +541,7 @@ contract RewardsCoordinatorUnitTests_setOperatorAVSSplit is RewardsCoordinatorUn

contract RewardsCoordinatorUnitTests_setOperatorPISplit is RewardsCoordinatorUnitTests {
// Revert when paused
function testFuzz_Revert_WhenPaused(address operator, uint16 split) public {
function testFuzz_Revert_WhenPaused(address operator, uint16 split) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
split = uint16(bound(split, 0, ONE_HUNDRED_IN_BIPS));
cheats.prank(pauser);
Expand All @@ -533,7 +553,10 @@ contract RewardsCoordinatorUnitTests_setOperatorPISplit is RewardsCoordinatorUni
}

// Revert when operator is not caller
function testFuzz_Revert_WhenOperatorIsNotMsgSender(address operator, uint16 split) public {
function testFuzz_Revert_WhenOperatorIsNotMsgSender(
address operator,
uint16 split
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0) && operator != address(this));
split = uint16(bound(split, 0, ONE_HUNDRED_IN_BIPS));

Expand All @@ -542,7 +565,10 @@ contract RewardsCoordinatorUnitTests_setOperatorPISplit is RewardsCoordinatorUni
}

// Revert when split is greater than 100%
function testFuzz_Revert_WhenSplitGreaterThan100(address operator, uint16 split) public {
function testFuzz_Revert_WhenSplitGreaterThan100(
address operator,
uint16 split
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
split = uint16(bound(split, ONE_HUNDRED_IN_BIPS + 1, type(uint16).max));

Expand All @@ -551,7 +577,7 @@ contract RewardsCoordinatorUnitTests_setOperatorPISplit is RewardsCoordinatorUni
rewardsCoordinator.setOperatorPISplit(operator, split);
}

function testFuzz_setOperatorAVSSplit(address operator, uint16 split) public {
function testFuzz_setOperatorAVSSplit(address operator, uint16 split) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
split = uint16(bound(split, 0, ONE_HUNDRED_IN_BIPS));
uint32 activatedAt = uint32(block.timestamp) + activationDelay;
Expand All @@ -568,7 +594,10 @@ contract RewardsCoordinatorUnitTests_setOperatorPISplit is RewardsCoordinatorUni
}

// Testing that the split has been initialized for the first time.
function testFuzz_setOperatorAVSSplitFirstTime(address operator, uint16 split) public {
function testFuzz_setOperatorAVSSplitFirstTime(
address operator,
uint16 split
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
split = uint16(bound(split, 0, ONE_HUNDRED_IN_BIPS));
uint32 activatedAt = uint32(block.timestamp) + activationDelay;
Expand All @@ -591,7 +620,7 @@ contract RewardsCoordinatorUnitTests_setOperatorPISplit is RewardsCoordinatorUni
uint16 firstSplit,
uint16 secondSplit,
uint32 warpTime
) public {
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
firstSplit = uint16(bound(firstSplit, 0, ONE_HUNDRED_IN_BIPS));
secondSplit = uint16(bound(secondSplit, 0, ONE_HUNDRED_IN_BIPS));
Expand Down Expand Up @@ -622,7 +651,7 @@ contract RewardsCoordinatorUnitTests_setOperatorPISplit is RewardsCoordinatorUni
uint16 firstSplit,
uint16 secondSplit,
uint32 warpTime
) public {
) public filterFuzzedAddressInputs(operator) {
cheats.assume(operator != address(0));
firstSplit = uint16(bound(firstSplit, 0, ONE_HUNDRED_IN_BIPS));
secondSplit = uint16(bound(secondSplit, 0, ONE_HUNDRED_IN_BIPS));
Expand Down

0 comments on commit d23fc47

Please sign in to comment.