Skip to content

Commit 0551da5

Browse files
fix: update deposit limit check to only check incoming deposit amount
Co-Authored-By: Tejas Badadare <[email protected]>
1 parent c629578 commit 0551da5

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

target_chains/ethereum/contracts/contracts/pulse/Scheduler.sol

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,7 @@ abstract contract Scheduler is IScheduler, SchedulerState {
536536
];
537537

538538
// Check deposit limit for permanent subscriptions
539-
if (
540-
params.isPermanent &&
541-
status.balanceInWei + msg.value > MAX_DEPOSIT_LIMIT
542-
) {
539+
if (params.isPermanent && msg.value > MAX_DEPOSIT_LIMIT) {
543540
revert MaxDepositLimitExceeded();
544541
}
545542

target_chains/ethereum/contracts/forge-test/PulseScheduler.t.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -818,14 +818,14 @@ contract SchedulerTest is Test, SchedulerEvents, PulseSchedulerTestUtils {
818818
"Balance should match deposit amount"
819819
);
820820

821-
// Test 3: Adding funds to a permanent subscription that would exceed MAX_DEPOSIT_LIMIT should fail
822-
uint256 additionalFunds = 1 wei;
823-
vm.deal(address(this), additionalFunds);
821+
// Test 3: Adding funds to a permanent subscription with deposit exceeding MAX_DEPOSIT_LIMIT should fail
822+
uint256 largeAdditionalFunds = maxDepositLimit + 1;
823+
vm.deal(address(this), largeAdditionalFunds);
824824

825825
vm.expectRevert(
826826
abi.encodeWithSelector(MaxDepositLimitExceeded.selector)
827827
);
828-
scheduler.addFunds{value: additionalFunds}(subscriptionId);
828+
scheduler.addFunds{value: largeAdditionalFunds}(subscriptionId);
829829

830830
// Test 4: Adding funds to a permanent subscription within MAX_DEPOSIT_LIMIT should succeed
831831
// Create a non-permanent subscription to test partial funding

0 commit comments

Comments
 (0)