Skip to content

Commit

Permalink
test: add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Dec 4, 2024
1 parent 76db11d commit c65b451
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion packages/contracts-rfq/test/FastBridgeV2.Management.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ contract FastBridgeV2ManagementTest is FastBridgeV2Test, IAdminV2Errors {
address public governorA = makeAddr("Governor A");

event CancelDelayUpdated(uint256 oldCancelDelay, uint256 newCancelDelay);
event DeployBlockSet(uint256 blockNumber);
event FeeRateUpdated(uint256 oldFeeRate, uint256 newFeeRate);
event FeesSwept(address token, address recipient, uint256 amount);

Expand Down Expand Up @@ -46,6 +47,11 @@ contract FastBridgeV2ManagementTest is FastBridgeV2Test, IAdminV2Errors {
fastBridge.setCancelDelay(newCancelDelay);
}

function setDeployBlock(address caller, uint256 blockNumber) public {
vm.prank(caller);
fastBridge.setDeployBlock(blockNumber);
}

function setProtocolFeeRate(address caller, uint256 newFeeRate) public {
vm.prank(caller);
fastBridge.setProtocolFeeRate(newFeeRate);
Expand All @@ -68,8 +74,10 @@ contract FastBridgeV2ManagementTest is FastBridgeV2Test, IAdminV2Errors {
setGovernor(caller, governorA);
}

function test_defaultCancelDelay() public view {
function test_defaultValues() public view {
assertEq(fastBridge.cancelDelay(), DEFAULT_CANCEL_DELAY);
assertEq(fastBridge.deployBlock(), block.number);
assertEq(fastBridge.protocolFeeRate(), 0);
}

// ═════════════════════════════════════════════ SET CANCEL DELAY ══════════════════════════════════════════════════
Expand Down Expand Up @@ -100,6 +108,21 @@ contract FastBridgeV2ManagementTest is FastBridgeV2Test, IAdminV2Errors {
setCancelDelay(caller, 4 days);
}

// ═════════════════════════════════════════════ SET DEPLOY BLOCK ══════════════════════════════════════════════════

function test_setDeployBlock() public {
vm.expectEmit(address(fastBridge));
emit DeployBlockSet(123_456);
setDeployBlock(admin, 123_456);
assertEq(fastBridge.deployBlock(), 123_456);
}

function test_setDeployBlock_revertNotAdmin(address caller) public {
vm.assume(caller != admin);
expectUnauthorized(caller, fastBridge.DEFAULT_ADMIN_ROLE());
setDeployBlock(caller, 123_456);
}

// ═══════════════════════════════════════════ SET PROTOCOL FEE RATE ═══════════════════════════════════════════════

function test_setProtocolFeeRate() public {
Expand Down

0 comments on commit c65b451

Please sign in to comment.