From f4beee6b17b31006304ccc0bf87e106fa8807d0d Mon Sep 17 00:00:00 2001 From: Michael Sun <35479365+8sunyuan@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:05:21 -0500 Subject: [PATCH] test: fuzz staker address != delegationApprover (#360) Failing fuzz test was result of fuzzed staker address being the same address as delegationApprover address --- src/test/unit/DelegationUnit.t.sol | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/test/unit/DelegationUnit.t.sol b/src/test/unit/DelegationUnit.t.sol index 596b048e2..019b3d9d8 100644 --- a/src/test/unit/DelegationUnit.t.sol +++ b/src/test/unit/DelegationUnit.t.sol @@ -232,7 +232,7 @@ contract DelegationManagerUnitTests is EigenLayerUnitTestSetup, IDelegationManag _registerOperator(operator, operatorDetails, emptyStringForMetadataURI); } - function _registerOperatorWith1271DelegationApprover(address operator) internal { + function _registerOperatorWith1271DelegationApprover(address operator) internal returns (ERC1271WalletMock) { address delegationSigner = cheats.addr(delegationSignerPrivateKey); /** * deploy a ERC1271WalletMock contract with the `delegationSigner` address as the owner, @@ -241,11 +241,13 @@ contract DelegationManagerUnitTests is EigenLayerUnitTestSetup, IDelegationManag ERC1271WalletMock wallet = new ERC1271WalletMock(delegationSigner); IDelegationManager.OperatorDetails memory operatorDetails = IDelegationManager.OperatorDetails({ - earningsReceiver: defaultOperator, + earningsReceiver: operator, delegationApprover: address(wallet), stakerOptOutWindowBlocks: 0 }); - _registerOperator(defaultOperator, operatorDetails, emptyStringForMetadataURI); + _registerOperator(operator, operatorDetails, emptyStringForMetadataURI); + + return wallet; } function _registerOperator( @@ -1414,8 +1416,8 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests { // register *this contract* as an operator // filter inputs, since this will fail when the staker is already registered as an operator - cheats.assume(staker != defaultOperator); - _registerOperatorWith1271DelegationApprover(defaultOperator); + ERC1271WalletMock wallet = _registerOperatorWith1271DelegationApprover(defaultOperator); + cheats.assume(staker != address(wallet) && staker != defaultOperator); // calculate the delegationSigner's signature ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry = _getApproverSignature(