Skip to content

Commit 46f88dd

Browse files
committed
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 c3cbcae commit 46f88dd

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,21 @@ contract GraphEscrowGettersTest is GraphEscrowTest {
3434
uint256 amountDeposit,
3535
uint256 amountThawing,
3636
uint256 amountCollected
37-
) public useGateway useDeposit(amountDeposit) {
38-
vm.assume(amountThawing > 0);
39-
vm.assume(amountDeposit > 0);
40-
vm.assume(amountDeposit >= amountThawing);
41-
vm.assume(amountDeposit >= amountCollected);
42-
vm.assume(amountDeposit - amountCollected < amountThawing);
37+
) public useGateway {
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);
41+
42+
// amountDeposit must be:
43+
// - >= amountThawing (so we can thaw that amount)
44+
// - >= amountCollected (so we can collect that amount)
45+
// - < amountThawing + amountCollected (so that after collecting, balance < thawing)
46+
// With the above bounds, this range is guaranteed to be valid
47+
uint256 minDeposit = amountThawing > amountCollected ? amountThawing : amountCollected;
48+
uint256 maxDeposit = amountThawing + amountCollected - 1;
49+
amountDeposit = bound(amountDeposit, minDeposit, maxDeposit);
50+
51+
_depositTokens(users.verifier, users.indexer, amountDeposit);
4352

4453
// thaw some funds
4554
_thawEscrow(users.verifier, users.indexer, amountThawing);

0 commit comments

Comments
 (0)