Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: run fork test against mainnet deployment #345

Merged
merged 2 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity >=0.8.22;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Test } from "forge-std/src/Test.sol";
import { FlowNFTDescriptor } from "src/FlowNFTDescriptor.sol";
import { ISablierFlow } from "src/interfaces/ISablierFlow.sol";
import { SablierFlow } from "src/SablierFlow.sol";
import { ERC20MissingReturn } from "./mocks/ERC20MissingReturn.sol";
import { ERC20Mock } from "./mocks/ERC20Mock.sol";
Expand All @@ -30,7 +31,7 @@ abstract contract Base_Test is Assertions, Modifiers, Test {
ERC20Mock internal usdc;
ERC20MissingReturn internal usdt;

SablierFlow internal flow;
ISablierFlow internal flow;
FlowNFTDescriptor internal nftDescriptor;

/*//////////////////////////////////////////////////////////////////////////
Expand Down
12 changes: 8 additions & 4 deletions tests/fork/Fork.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity >=0.8.22;

import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ISablierFlow } from "src/interfaces/ISablierFlow.sol";

import { Base_Test } from "../Base.t.sol";

Expand Down Expand Up @@ -37,11 +38,14 @@ abstract contract Fork_Test is Base_Test {
//////////////////////////////////////////////////////////////////////////*/

function setUp() public virtual override {
// Fork Ethereum Mainnet at a specific block number. The block number is for the `OCT_1_2024` date.
vm.createSelectFork({ blockNumber: 20_866_919, urlOrAlias: "mainnet" });
// Fork Ethereum Mainnet at a block number after the Sablier deployment.
vm.createSelectFork({ blockNumber: 21_330_578, urlOrAlias: "mainnet" });

// The base is set up after the fork is selected so that the base test contracts are deployed on the fork.
Base_Test.setUp();
// Load mainnet address of flow.
flow = ISablierFlow(0x2D9221a63E12AA796619cb381Ec4A71b201281f5);

// Label the flow contract.
vm.label(address(flow), "Flow");

// Label the tokens.
for (uint256 i = 0; i < tokens.length; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract SetNFTDescriptor_Integration_Concrete_Test is Shared_Integration_Concre
// It should re-set the NFT descriptor
flow.setNFTDescriptor(nftDescriptor);
vm.expectCall(address(nftDescriptor), abi.encodeCall(FlowNFTDescriptor.tokenURI, (flow, 1)));
flow.tokenURI({ streamId: defaultStreamId });
flow.tokenURI(defaultStreamId);
}

function test_WhenNewAndOldNFTDescriptorsAreNotSame() external whenCallerAdmin {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/concrete/token-uri/tokenURI.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { Shared_Integration_Concrete_Test } from "../Concrete.t.sol";
contract TokenURI_Integration_Concrete_Test is Shared_Integration_Concrete_Test {
function test_RevertGiven_NFTNotExist() external {
vm.expectRevert(abi.encodeWithSelector(IERC721Errors.ERC721NonexistentToken.selector, nullStreamId));
flow.tokenURI({ streamId: nullStreamId });
flow.tokenURI(nullStreamId);
}

function test_GivenNFTExists() external view {
// It should return the correct token URI
string memory actualURI = flow.tokenURI({ streamId: defaultStreamId });
string memory actualURI = flow.tokenURI(defaultStreamId);
// solhint-disable max-line-length,quotes
string memory expectedURI =
"data:application/json;base64,eyJkZXNjcmlwdGlvbiI6ICJUaGlzIE5GVCByZXByZXNlbnRzIGEgcGF5bWVudCBzdHJlYW0gaW4gU2FibGllciBGbG93IiwiZXh0ZXJuYWxfd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