Skip to content

Commit

Permalink
internal s23: set bytecode_hash = zero (#59)
Browse files Browse the repository at this point in the history
* test: add size snapshot before bytecode_hash=none

* internal s23: set bytecode_hash = zero

* test: add CLPositionDescriptorOffChainSize size
  • Loading branch information
ChefMist authored Nov 28, 2024
1 parent 74529e4 commit a390e4a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .forge-snapshots/CLPositionDescriptorOffChainSize.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2568
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fs_permissions = [
{ access = "read", path = "./test/bin/" },
]
evm_version = 'cancun'
bytecode_hash = "none"

[fuzz]
runs = 1000 # change this for higher number of fuzz/invariant locally
Expand Down
15 changes: 14 additions & 1 deletion test/pool-cl/CLPositionDescriptorOffChain.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.24;

import {Test} from "forge-std/Test.sol";
import {GasSnapshot} from "forge-gas-snapshot/GasSnapshot.sol";
import {CLPositionDescriptorOffChain} from "../../src/pool-cl/CLPositionDescriptorOffChain.sol";
import {ICLPositionManager} from "../../src/pool-cl/interfaces/ICLPositionManager.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
Expand All @@ -19,14 +20,26 @@ contract FakeTokenURIContract is ICLPositionDescriptor {
}
}

contract CLPositionDescriptorOffChainTest is Test {
contract CLPositionDescriptorOffChainTest is Test, GasSnapshot {
CLPositionDescriptorOffChain clPositionDescriptorOffChain;

error ContractSizeTooLarge(uint256 diff);

function setUp() public {
clPositionDescriptorOffChain =
new CLPositionDescriptorOffChain("https://pancakeswap.finance/v4/pool-cl/positions/");
}

function test_bytecodeSize() public {
snapSize("CLPositionDescriptorOffChainSize", address(clPositionDescriptorOffChain));

// forge coverage will run with '--ir-minimum' which set optimizer run to min
// thus we do not want to revert for forge coverage case
if (vm.envExists("FOUNDRY_PROFILE") && address(clPositionDescriptorOffChain).code.length > 24576) {
revert ContractSizeTooLarge(address(clPositionDescriptorOffChain).code.length - 24576);
}
}

function testTokenURI() public view {
// tokenId=1
string memory tokenURI = clPositionDescriptorOffChain.tokenURI(ICLPositionManager(address(0)), 1);
Expand Down

0 comments on commit a390e4a

Please sign in to comment.