From 19bab5e0cd7805a39cf2f1f280a1afcf4614aedf Mon Sep 17 00:00:00 2001 From: Miguel de Elias Date: Fri, 4 Oct 2024 14:26:07 -0300 Subject: [PATCH 1/2] fix(Horizon): withdraw delegation with beneficiary test fix --- packages/horizon/test/staking/delegation/withdraw.t.sol | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/horizon/test/staking/delegation/withdraw.t.sol b/packages/horizon/test/staking/delegation/withdraw.t.sol index 866f49942..ff8e74b15 100644 --- a/packages/horizon/test/staking/delegation/withdraw.t.sol +++ b/packages/horizon/test/staking/delegation/withdraw.t.sol @@ -192,6 +192,10 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { // Beneficiary withdraws delegated tokens resetPrank(beneficiary); + // Burn the tokens if the beneficiary has more than the delegation amount so we don't overflow the balance + if (token.balanceOf(beneficiary) > delegationAmount) { + token.burn(delegationAmount); + } _withdrawDelegated(users.indexer, subgraphDataServiceAddress, address(0), 0, 1); } From 2acd8252300afb7cb6625a0d58d074b5d107299c Mon Sep 17 00:00:00 2001 From: Miguel de Elias Date: Fri, 4 Oct 2024 16:32:01 -0300 Subject: [PATCH 2/2] fix: skip addresses that will overflow --- packages/horizon/test/staking/delegation/withdraw.t.sol | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/horizon/test/staking/delegation/withdraw.t.sol b/packages/horizon/test/staking/delegation/withdraw.t.sol index ff8e74b15..b7644c62a 100644 --- a/packages/horizon/test/staking/delegation/withdraw.t.sol +++ b/packages/horizon/test/staking/delegation/withdraw.t.sol @@ -179,6 +179,8 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { useDelegation(delegationAmount) { vm.assume(beneficiary != address(0)); + // Skip beneficiary if balance will overflow + vm.assume(token.balanceOf(beneficiary) < type(uint256).max - delegationAmount); // Delegator undelegates to beneficiary resetPrank(users.delegator); @@ -192,10 +194,6 @@ contract HorizonStakingWithdrawDelegationTest is HorizonStakingTest { // Beneficiary withdraws delegated tokens resetPrank(beneficiary); - // Burn the tokens if the beneficiary has more than the delegation amount so we don't overflow the balance - if (token.balanceOf(beneficiary) > delegationAmount) { - token.burn(delegationAmount); - } _withdrawDelegated(users.indexer, subgraphDataServiceAddress, address(0), 0, 1); }