Skip to content

Commit

Permalink
test: deploy libraries through DeployOptimized contract
Browse files Browse the repository at this point in the history
  • Loading branch information
smol-ninja committed Nov 8, 2024
1 parent 2973ad3 commit 358a061
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
12 changes: 0 additions & 12 deletions test/Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,6 @@ abstract contract Base_Test is Assertions, Calculations, DeployOptimized, Modifi
return user;
}

/// @dev Deploys the optimized {Helpers} and {VestingMath} libraries and assign them to linked addresses.
function deployOptimizedLibraries() internal {
address helpers = deployCode("out-optimized/Helpers.sol/Helpers.json");
address vestingMath = deployCode("out-optimized/VestingMath.sol/VestingMath.json");
vm.etch(0x7715bE116061E014Bb721b46Dc78Dd57C91FDF9b, helpers.code);
vm.etch(0x26F9d826BDed47Fc472526aE8095B75ac336963C, vestingMath.code);
}

/// @dev Conditionally deploys the protocol normally or from an optimized source compiled with `--via-ir`.
/// We cannot use the {DeployProtocol} script because some tests rely on hard coded addresses for the
/// deployed contracts. Since the script itself would have to be deployed, using it would bump the
Expand All @@ -164,10 +156,6 @@ abstract contract Base_Test is Assertions, Calculations, DeployOptimized, Modifi
lockup = new SablierLockup(users.admin, nftDescriptor, defaults.MAX_COUNT());
merkleFactory = new SablierMerkleFactory(users.admin);
} else {
// Deploy the optimized libraries.
deployOptimizedLibraries();

// Deploy the optimized contracts.
(nftDescriptor, lockup, batchLockup, merkleFactory) =
deployOptimizedProtocol(users.admin, defaults.MAX_COUNT());
}
Expand Down
7 changes: 4 additions & 3 deletions test/core/fork/NFTDescriptor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ contract NFTDescriptor_Fork_Test is Fork_Test {
/// @dev Loads the Lockup v1.2.0 contracts pre-deployed on Mainnet.
modifier loadDeployments_v1_3_0() {
// TODO: Add the deployment addresses for Lockup v1.3.0.
// Deploy some streams temporarity for the test
resetPrank({ msgSender: users.sender });
lockup.createWithDurationsLL(defaults.createWithDurations(), defaults.durations());
_;
}

Expand Down Expand Up @@ -260,9 +263,7 @@ contract NFTDescriptor_Fork_Test is Fork_Test {
/// Given enough fuzz runs, all the following scenarios will be fuzzed:
/// - Multiple values of streamId.
function testForkFuzz_TokenURI_Lockup_v1_3_0(uint256 streamId) external loadDeployments_v1_3_0 {
// TODO: Uncomment it after the deployment.
// streamId = _bound(streamId, 1, lockup.nextStreamId() - 1);
streamId = 1;
streamId = _bound(streamId, 1, lockup.nextStreamId() - 1);

// Set the new NFT descriptor for the previous version of Lockup.
resetPrank({ msgSender: lockup.admin() });
Expand Down
1 change: 0 additions & 1 deletion test/periphery/fork/Fork.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity >=0.8.22 <0.9.0;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ISablierLockup } from "src/core/interfaces/ISablierLockup.sol";
import { Merkle } from "./../../utils/Murky.sol";
import { Periphery_Test } from "./../Periphery.t.sol";

Expand Down
3 changes: 1 addition & 2 deletions test/periphery/fork/assets/USDC.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { MerkleLL_Fork_Test } from "../merkle-campaign/MerkleLL.t.sol";
import { MerkleLT_Fork_Test } from "../merkle-campaign/MerkleLT.t.sol";

/// @dev An ERC-20 asset with 6 decimals.
// TODO: Update addresses to mainnet once deployed.
IERC20 constant usdc = IERC20(0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238);
IERC20 constant usdc = IERC20(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);

contract USDC_CreateWithTimestampsLD_BatchLockup_Fork_Test is CreateWithTimestampsLD_BatchLockup_Fork_Test(usdc) { }

Expand Down
3 changes: 1 addition & 2 deletions test/periphery/fork/assets/USDT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { MerkleLL_Fork_Test } from "../merkle-campaign/MerkleLL.t.sol";
import { MerkleLT_Fork_Test } from "../merkle-campaign/MerkleLT.t.sol";

/// @dev An ERC-20 asset that suffers from the missing return value bug.
// TODO: Update addresses to mainnet once deployed.
IERC20 constant usdt = IERC20(0x7169D38820dfd117C3FA1f22a697dBA58d90BA06);
IERC20 constant usdt = IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7);

contract USDT_CreateWithTimestampsLD_BatchLockup_Fork_Test is CreateWithTimestampsLD_BatchLockup_Fork_Test(usdt) { }

Expand Down
15 changes: 14 additions & 1 deletion test/utils/DeployOptimized.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.22 <0.9.0;

import { CommonBase } from "forge-std/src/Base.sol";
import { StdCheats } from "forge-std/src/StdCheats.sol";

import { ILockupNFTDescriptor } from "../../src/core/interfaces/ILockupNFTDescriptor.sol";
import { ISablierLockup } from "../../src/core/interfaces/ISablierLockup.sol";
import { ISablierBatchLockup } from "../../src/periphery/interfaces/ISablierBatchLockup.sol";
import { ISablierMerkleFactory } from "../../src/periphery/interfaces/ISablierMerkleFactory.sol";

abstract contract DeployOptimized is StdCheats {
abstract contract DeployOptimized is StdCheats, CommonBase {
/*//////////////////////////////////////////////////////////////////////////
CORE
//////////////////////////////////////////////////////////////////////////*/

/// @dev Deploys the optimized {Helpers} and {VestingMath} libraries and assign them to linked addresses.
function deployOptimizedLibraries() internal {
address helpers = deployCode("out-optimized/Helpers.sol/Helpers.json");
address vestingMath = deployCode("out-optimized/VestingMath.sol/VestingMath.json");
vm.etch(0x7715bE116061E014Bb721b46Dc78Dd57C91FDF9b, helpers.code);
vm.etch(0x26F9d826BDed47Fc472526aE8095B75ac336963C, vestingMath.code);
}

/// @dev Deploys {SablierLockup} from an optimized source compiled with `--via-ir`.
function deployOptimizedLockup(
address initialAdmin,
Expand All @@ -22,6 +31,10 @@ abstract contract DeployOptimized is StdCheats {
internal
returns (ISablierLockup)
{
// Deploy the libraries.
deployOptimizedLibraries();

// Deploy the Lockup contract.
return ISablierLockup(
deployCode(
"out-optimized/SablierLockup.sol/SablierLockup.json",
Expand Down

0 comments on commit 358a061

Please sign in to comment.