Skip to content

Commit 2fc082e

Browse files
authored
fix: resolve fuzz test failure in testGetBalance_WhenCollectedOverThawing (#1268)
Replace vm.assume with bounded inputs to fix "vm.assume rejected too many inputs" error. The previous implementation used overly restrictive constraints that caused the fuzzer to reject most random inputs. Now limits amountThawing and amountCollected to half of MAX_STAKING_TOKENS, guaranteeing valid deposit ranges while maintaining test coverage.
1 parent 6cad737 commit 2fc082e

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

packages/horizon/test/unit/escrow/getters.t.sol

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,17 @@ contract GraphEscrowGettersTest is GraphEscrowTest {
3535
uint256 amountThawing,
3636
uint256 amountCollected
3737
) public useGateway {
38-
amountThawing = bound(amountThawing, 1, MAX_STAKING_TOKENS);
39-
amountCollected = bound(amountCollected, 1, MAX_STAKING_TOKENS);
38+
// Limit thawing and collected to half of MAX_STAKING_TOKENS to ensure valid deposit range
39+
amountThawing = bound(amountThawing, 1, MAX_STAKING_TOKENS / 2);
40+
amountCollected = bound(amountCollected, 1, MAX_STAKING_TOKENS / 2);
4041

4142
// amountDeposit must be:
4243
// - >= amountThawing (so we can thaw that amount)
4344
// - >= amountCollected (so we can collect that amount)
4445
// - < amountThawing + amountCollected (so that after collecting, balance < thawing)
45-
// - <= MAX_STAKING_TOKENS (consistent with other tests)
46+
// With the above bounds, this range is guaranteed to be valid
4647
uint256 minDeposit = amountThawing > amountCollected ? amountThawing : amountCollected;
4748
uint256 maxDeposit = amountThawing + amountCollected - 1;
48-
if (maxDeposit > MAX_STAKING_TOKENS) {
49-
maxDeposit = MAX_STAKING_TOKENS;
50-
}
51-
vm.assume(minDeposit <= maxDeposit);
5249
amountDeposit = bound(amountDeposit, minDeposit, maxDeposit);
5350

5451
_depositTokens(users.verifier, users.indexer, amountDeposit);

0 commit comments

Comments
 (0)