diff --git a/test/foundry/Constants.sol b/test/foundry/Constants.sol index 597483b..21762da 100644 --- a/test/foundry/Constants.sol +++ b/test/foundry/Constants.sol @@ -3,3 +3,4 @@ pragma solidity ^0.8.13; uint256 constant FIRST_PROFILE_ID = 1; uint256 constant FIRST_PUB_ID = 1; +uint256 constant ISSECP256K1_CURVE_ORDER = 115792089237316195423570985008687907852837564279074904382605163141518161494337; diff --git a/test/foundry/FollowTest.t.sol b/test/foundry/FollowTest.t.sol index dd2b327..9ceb684 100644 --- a/test/foundry/FollowTest.t.sol +++ b/test/foundry/FollowTest.t.sol @@ -4,11 +4,10 @@ pragma solidity ^0.8.13; import './base/BaseTest.t.sol'; import './MetaTxNegatives.t.sol'; import {Strings} from '@openzeppelin/contracts/utils/Strings.sol'; -import './helpers/AssumptionHelpers.sol'; import {IFollowNFT} from 'contracts/interfaces/IFollowNFT.sol'; import '../../contracts/mocks/MockFollowModuleWithRevertFlag.sol'; -contract FollowTest is BaseTest, AssumptionHelpers { +contract FollowTest is BaseTest { using Strings for uint256; uint256 constant MINT_NEW_TOKEN = 0; @@ -98,7 +97,7 @@ contract FollowTest is BaseTest, AssumptionHelpers { function testCannotFollowIfExecutorIsNotTheProfileOwnerOrHisApprovedExecutor(uint256 executorPk) public { - vm.assume(_isValidPk(executorPk)); + executorPk = bound(executorPk, 1, ISSECP256K1_CURVE_ORDER - 1); address executor = vm.addr(executorPk); vm.assume(executor != address(0)); vm.assume(executor != followerProfileOwner); @@ -119,7 +118,7 @@ contract FollowTest is BaseTest, AssumptionHelpers { function testCannotFollowWithUnwrappedTokenIfExecutorIsNotTheProfileOwnerOrHisApprovedExecutor( uint256 executorPk ) public { - vm.assume(_isValidPk(executorPk)); + executorPk = bound(executorPk, 1, ISSECP256K1_CURVE_ORDER - 1); address executor = vm.addr(executorPk); vm.assume(executor != address(0)); vm.assume(executor != followerProfileOwner); @@ -143,7 +142,7 @@ contract FollowTest is BaseTest, AssumptionHelpers { function testCannotFollowWithWrappedTokenIfExecutorIsNotTheProfileOwnerOrHisApprovedExecutor( uint256 executorPk ) public { - vm.assume(_isValidPk(executorPk)); + executorPk = bound(executorPk, 1, ISSECP256K1_CURVE_ORDER - 1); address executor = vm.addr(executorPk); vm.assume(executor != address(0)); vm.assume(executor != followerProfileOwner); @@ -340,7 +339,11 @@ contract FollowTest is BaseTest, AssumptionHelpers { function testFollowAsFollowerApprovedDelegatedExecutor(uint256 approvedDelegatedExecutorPk) public { - vm.assume(_isValidPk(approvedDelegatedExecutorPk)); + approvedDelegatedExecutorPk = bound( + approvedDelegatedExecutorPk, + 1, + ISSECP256K1_CURVE_ORDER - 1 + ); address approvedDelegatedExecutor = vm.addr(approvedDelegatedExecutorPk); vm.assume(approvedDelegatedExecutor != address(0)); vm.assume(approvedDelegatedExecutor != followerProfileOwner); diff --git a/test/foundry/SetBlockStatusTest.t.sol b/test/foundry/SetBlockStatusTest.t.sol index ab44c68..b4040c8 100644 --- a/test/foundry/SetBlockStatusTest.t.sol +++ b/test/foundry/SetBlockStatusTest.t.sol @@ -3,9 +3,8 @@ pragma solidity ^0.8.13; import './base/BaseTest.t.sol'; import './MetaTxNegatives.t.sol'; -import './helpers/AssumptionHelpers.sol'; -contract SetBlockStatusTest is BaseTest, AssumptionHelpers { +contract SetBlockStatusTest is BaseTest { address constant PROFILE_OWNER = address(0); uint256 constant statusSetterProfileOwnerPk = 0x7357; @@ -76,7 +75,11 @@ contract SetBlockStatusTest is BaseTest, AssumptionHelpers { function testCannotSetBlockStatusIfNotOwnerOrApprovedDelegatedExecutorOfSetterProfile( uint256 nonOwnerNorDelegatedExecutorPk ) public virtual { - vm.assume(_isValidPk(nonOwnerNorDelegatedExecutorPk)); + nonOwnerNorDelegatedExecutorPk = bound( + nonOwnerNorDelegatedExecutorPk, + 1, + ISSECP256K1_CURVE_ORDER - 1 + ); address nonOwnerNorDelegatedExecutor = vm.addr(nonOwnerNorDelegatedExecutorPk); vm.assume(nonOwnerNorDelegatedExecutor != address(0)); vm.assume(nonOwnerNorDelegatedExecutor != statusSetterProfileOwner); @@ -377,7 +380,11 @@ contract SetBlockStatusMetaTxTest is SetBlockStatusTest, MetaTxNegatives { function testCannotSetBlockStatusIfNotOwnerOrApprovedDelegatedExecutorOfSetterProfile( uint256 nonOwnerNorDelegatedExecutorPk ) public override { - vm.assume(_isValidPk(nonOwnerNorDelegatedExecutorPk)); + nonOwnerNorDelegatedExecutorPk = bound( + nonOwnerNorDelegatedExecutorPk, + 1, + ISSECP256K1_CURVE_ORDER - 1 + ); address nonOwnerNorDelegatedExecutor = vm.addr(nonOwnerNorDelegatedExecutorPk); vm.assume(nonOwnerNorDelegatedExecutor != address(0)); vm.assume(nonOwnerNorDelegatedExecutor != statusSetterProfileOwner); diff --git a/test/foundry/UnfollowTest.t.sol b/test/foundry/UnfollowTest.t.sol index 6298302..d587df6 100644 --- a/test/foundry/UnfollowTest.t.sol +++ b/test/foundry/UnfollowTest.t.sol @@ -4,10 +4,9 @@ pragma solidity ^0.8.13; import './base/BaseTest.t.sol'; import './MetaTxNegatives.t.sol'; import {Strings} from '@openzeppelin/contracts/utils/Strings.sol'; -import './helpers/AssumptionHelpers.sol'; import {IFollowNFT} from 'contracts/interfaces/IFollowNFT.sol'; -contract UnfollowTest is BaseTest, AssumptionHelpers { +contract UnfollowTest is BaseTest { uint256 constant MINT_NEW_TOKEN = 0; address constant PROFILE_OWNER = address(0); address targetProfileOwner = address(0xC0FFEE); @@ -169,7 +168,11 @@ contract UnfollowTest is BaseTest, AssumptionHelpers { function testUnfollowAsUnfollowerApprovedDelegatedExecutor(uint256 approvedDelegatedExecutorPk) public { - vm.assume(_isValidPk(approvedDelegatedExecutorPk)); + approvedDelegatedExecutorPk = bound( + approvedDelegatedExecutorPk, + 1, + ISSECP256K1_CURVE_ORDER - 1 + ); address approvedDelegatedExecutor = vm.addr(approvedDelegatedExecutorPk); vm.assume(approvedDelegatedExecutor != address(0)); vm.assume(approvedDelegatedExecutor != unfollowerProfileOwner); diff --git a/test/foundry/helpers/AssumptionHelpers.sol b/test/foundry/helpers/AssumptionHelpers.sol deleted file mode 100644 index 98cc024..0000000 --- a/test/foundry/helpers/AssumptionHelpers.sol +++ /dev/null @@ -1,11 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.13; - -contract AssumptionHelpers { - uint256 constant ISSECP256K1_CURVE_ORDER = - 115792089237316195423570985008687907852837564279074904382605163141518161494337; - - function _isValidPk(uint256 pkCandidate) internal pure returns (bool) { - return pkCandidate > 0 && pkCandidate < ISSECP256K1_CURVE_ORDER; - } -}