Skip to content

Commit

Permalink
cancun to TEST_DATA_DEFAULT, add TEST_DATA_PARIS
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy committed Nov 7, 2024
1 parent 289bb43 commit cdda83c
Show file tree
Hide file tree
Showing 20 changed files with 172 additions and 47 deletions.
2 changes: 1 addition & 1 deletion crates/forge/src/multi_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ impl MultiContractRunnerBuilder {
contracts: deployable_contracts,
evm_opts,
env,
evm_spec: self.evm_spec.unwrap_or(SpecId::MERGE),
evm_spec: self.evm_spec.unwrap_or(SpecId::CANCUN),
sender: self.sender,
revert_decoder,
fork: self.fork,
Expand Down
10 changes: 5 additions & 5 deletions crates/forge/tests/cli/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Solidity:
- 0.8.27
Vyper:
- 0.4.1
- 0.4.0
"#]]);
Expand All @@ -174,7 +174,7 @@ forgetest!(can_list_resolved_multiple_compiler_versions_skipped, |prj, cmd| {
r#"
Vyper:
0.4.1:
0.4.0:
├── src/Counter.vy
└── src/ICounter.vyi
Expand Down Expand Up @@ -206,7 +206,7 @@ forgetest!(can_list_resolved_multiple_compiler_versions_skipped_json, |prj, cmd|
],
"Vyper": [
{
"version": "0.4.1",
"version": "0.4.0",
"paths": [
"src/Counter.vy",
"src/ICounter.vyi"
Expand Down Expand Up @@ -242,7 +242,7 @@ Solidity:
Vyper:
0.4.1 (<= cancun):
0.4.0 (<= cancun):
├── src/Counter.vy
└── src/ICounter.vyi
Expand Down Expand Up @@ -287,7 +287,7 @@ forgetest!(can_list_resolved_multiple_compiler_versions_verbose_json, |prj, cmd|
],
"Vyper": [
{
"version": "0.4.1",
"version": "0.4.0",
"evm_version": "[..]",
"paths": [
"src/Counter.vy",
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/tests/cli/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ forgetest!(normalize_config_evm_version, |_prj, cmd| {
let config: Config = serde_json::from_str(&output).unwrap();
assert_eq!(config.evm_version, EvmVersion::Istanbul);

// See <https://github.com/foundry-rs/foundry/issues/7014>
// See <https://github.com/foundry-rs/foundry/issues/7014>
let output = cmd
.forge_fuse()
.args(["config", "--use", "0.8.17", "--json"])
Expand Down
1 change: 1 addition & 0 deletions crates/forge/tests/cli/ext_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn stringutils() {
fn lootloose() {
ExtTester::new("gakonst", "lootloose", "7b639efe97836155a6a6fc626bf1018d4f8b2495")
.install_command(&["make", "install"])
.args(["--evm-version", "paris"])
.run();
}

Expand Down
8 changes: 4 additions & 4 deletions crates/forge/tests/it/cheats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use crate::{
config::*,
test_helpers::{
ForgeTestData, RE_PATH_SEPARATOR, TEST_DATA_CANCUN, TEST_DATA_DEFAULT,
TEST_DATA_MULTI_VERSION,
ForgeTestData, RE_PATH_SEPARATOR, TEST_DATA_DEFAULT, TEST_DATA_MULTI_VERSION,
TEST_DATA_PARIS,
},
};
use alloy_primitives::U256;
Expand Down Expand Up @@ -77,6 +77,6 @@ async fn test_cheats_local_multi_version() {
}

#[tokio::test(flavor = "multi_thread")]
async fn test_cheats_local_cancun() {
test_cheats_local(&TEST_DATA_CANCUN).await
async fn test_cheats_local_paris() {
test_cheats_local(&TEST_DATA_PARIS).await
}
8 changes: 4 additions & 4 deletions crates/forge/tests/it/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::{
config::*,
test_helpers::{RE_PATH_SEPARATOR, TEST_DATA_DEFAULT},
test_helpers::{RE_PATH_SEPARATOR, TEST_DATA_DEFAULT, TEST_DATA_PARIS},
};
use alloy_chains::Chain;
use forge::result::SuiteResult;
Expand Down Expand Up @@ -35,9 +35,9 @@ async fn test_cheats_fork_revert() {
/// Executes all non-reverting fork cheatcodes
#[tokio::test(flavor = "multi_thread")]
async fn test_cheats_fork() {
let mut config = TEST_DATA_DEFAULT.config.clone();
let mut config = TEST_DATA_PARIS.config.clone();
config.fs_permissions = FsPermissions::new(vec![PathPermission::read("./fixtures")]);
let runner = TEST_DATA_DEFAULT.runner_with_config(config);
let runner = TEST_DATA_PARIS.runner_with_config(config);
let filter = Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}Fork"))
.exclude_tests(".*Revert");
TestConfig::with_filter(runner, filter).run().await;
Expand Down Expand Up @@ -86,7 +86,7 @@ async fn test_launch_fork_ws() {
/// Tests that we can transact transactions in forking mode
#[tokio::test(flavor = "multi_thread")]
async fn test_transact_fork() {
let runner = TEST_DATA_DEFAULT.runner();
let runner = TEST_DATA_PARIS.runner();
let filter = Filter::new(".*", ".*", &format!(".*fork{RE_PATH_SEPARATOR}Transact"));
TestConfig::with_filter(runner, filter).run().await;
}
Expand Down
4 changes: 2 additions & 2 deletions crates/forge/tests/it/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ contract FuzzerDictTest is Test {
.unwrap();

// Test that immutable address is used as fuzzed input, causing test to fail.
cmd.args(["test", "--fuzz-seed", "100", "--mt", "testImmutableOwner"]).assert_failure();
cmd.args(["test", "--fuzz-seed", "119", "--mt", "testImmutableOwner"]).assert_failure();
// Test that storage address is used as fuzzed input, causing test to fail.
cmd.forge_fuse()
.args(["test", "--fuzz-seed", "100", "--mt", "testStorageOwner"])
.args(["test", "--fuzz-seed", "119", "--mt", "testStorageOwner"])
.assert_failure();
});

Expand Down
7 changes: 5 additions & 2 deletions crates/forge/tests/it/repros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,16 @@ test_repro!(8383, false, None, |res| {
let test = res.test_results.remove("testP256VerifyOutOfBounds()").unwrap();
assert_eq!(test.status, TestStatus::Success);
match test.kind {
TestKind::Unit { gas } => assert_eq!(gas, 3103),
TestKind::Unit { gas } => assert_eq!(gas, 3101),
_ => panic!("not a unit test kind"),
}
});

// https://github.com/foundry-rs/foundry/issues/1543
test_repro!(1543);
test_repro!(
#[ignore = "TBD"]
1543
);

// https://github.com/foundry-rs/foundry/issues/6643
test_repro!(6643);
Expand Down
6 changes: 1 addition & 5 deletions crates/forge/tests/it/spec.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
//! Integration tests for EVM specifications.

use crate::{config::*, test_helpers::TEST_DATA_DEFAULT};
use foundry_evm::revm::primitives::SpecId;
use foundry_test_utils::Filter;

#[tokio::test(flavor = "multi_thread")]
async fn test_shanghai_compat() {
let filter = Filter::new("", "ShanghaiCompat", ".*spec");
TestConfig::with_filter(TEST_DATA_DEFAULT.runner(), filter)
.evm_spec(SpecId::SHANGHAI)
.run()
.await;
TestConfig::with_filter(TEST_DATA_DEFAULT.runner(), filter).run().await;
}
28 changes: 14 additions & 14 deletions crates/forge/tests/it/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ static VYPER: LazyLock<PathBuf> = LazyLock::new(|| std::env::temp_dir().join("vy
/// Profile for the tests group. Used to configure separate configurations for test runs.
pub enum ForgeTestProfile {
Default,
Cancun,
Paris,
MultiVersion,
}

impl fmt::Display for ForgeTestProfile {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Default => write!(f, "default"),
Self::Cancun => write!(f, "cancun"),
Self::Paris => write!(f, "paris"),
Self::MultiVersion => write!(f, "multi-version"),
}
}
}

impl ForgeTestProfile {
/// Returns true if the profile is Cancun.
pub fn is_cancun(&self) -> bool {
matches!(self, Self::Cancun)
/// Returns true if the profile is Paris.
pub fn is_paris(&self) -> bool {
matches!(self, Self::Paris)
}

pub fn root(&self) -> PathBuf {
Expand All @@ -66,8 +66,8 @@ impl ForgeTestProfile {
let mut settings =
Settings { libraries: Libraries::parse(&libs).unwrap(), ..Default::default() };

if matches!(self, Self::Cancun) {
settings.evm_version = Some(EvmVersion::Cancun);
if matches!(self, Self::Paris) {
settings.evm_version = Some(EvmVersion::Paris);
}

let settings = SolcConfig::builder().settings(settings).build();
Expand Down Expand Up @@ -155,8 +155,8 @@ impl ForgeTestProfile {
"fork/Fork.t.sol:DssExecLib:0xfD88CeE74f7D78697775aBDAE53f9Da1559728E4".to_string(),
];

if self.is_cancun() {
config.evm_version = EvmVersion::Cancun;
if self.is_paris() {
config.evm_version = EvmVersion::Paris;
}

config
Expand Down Expand Up @@ -195,8 +195,8 @@ impl ForgeTestData {
let mut runner = MultiContractRunnerBuilder::new(Arc::new(self.config.clone()))
.sender(self.evm_opts.sender)
.with_test_options(self.test_opts.clone());
if self.profile.is_cancun() {
runner = runner.evm_spec(SpecId::CANCUN);
if self.profile.is_paris() {
runner = runner.evm_spec(SpecId::MERGE);
}

runner
Expand Down Expand Up @@ -338,9 +338,9 @@ pub fn get_compiled(project: &mut Project) -> ProjectCompileOutput {
pub static TEST_DATA_DEFAULT: LazyLock<ForgeTestData> =
LazyLock::new(|| ForgeTestData::new(ForgeTestProfile::Default));

/// Data for tests requiring Cancun support on Solc and EVM level.
pub static TEST_DATA_CANCUN: LazyLock<ForgeTestData> =
LazyLock::new(|| ForgeTestData::new(ForgeTestProfile::Cancun));
/// Data for tests requiring Paris support on Solc and EVM level.
pub static TEST_DATA_PARIS: LazyLock<ForgeTestData> =
LazyLock::new(|| ForgeTestData::new(ForgeTestProfile::Paris));

/// Data for tests requiring Cancun support on Solc and EVM level.
pub static TEST_DATA_MULTI_VERSION: LazyLock<ForgeTestData> =
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion testdata/default/cheats/Etch.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ contract EtchTest is DSTest {
Vm constant vm = Vm(HEVM_ADDRESS);

function testEtch() public {
address target = address(10);
address target = address(11);
bytes memory code = hex"1010";
vm.etch(target, code);
assertEq(string(code), string(target.code));
Expand Down
4 changes: 2 additions & 2 deletions testdata/default/repros/Issue5929.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ contract Issue5929Test is DSTest {
Vm constant vm = Vm(HEVM_ADDRESS);

function test_transact_not_working() public {
vm.createSelectFork("mainnet", 15625301);
vm.createSelectFork("mainnet", 21134547);
// https://etherscan.io/tx/0x96a129768ec66fd7d65114bf182f4e173bf0b73a44219adaf71f01381a3d0143
vm.transact(hex"96a129768ec66fd7d65114bf182f4e173bf0b73a44219adaf71f01381a3d0143");
vm.transact(hex"7dcff74771babf9c23363c4228e55a27f50224d4596b1ba6608b0b45712f94ba");
}
}
4 changes: 2 additions & 2 deletions testdata/default/repros/Issue6538.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ contract Issue6538Test is DSTest {
Vm constant vm = Vm(HEVM_ADDRESS);

function test_transact() public {
bytes32 lastHash = 0xdbdce1d5c14a6ca17f0e527ab762589d6a73f68697606ae0bb90df7ac9ec5087;
bytes32 lastHash = 0x4b70ca8c5a0990b43df3064372d424d46efa41dfaab961754b86c5afb2df4f61;
vm.createSelectFork("mainnet", lastHash);
bytes32 txhash = 0xadbe5cf9269a001d50990d0c29075b402bcc3a0b0f3258821881621b787b35c6;
bytes32 txhash = 0x7dcff74771babf9c23363c4228e55a27f50224d4596b1ba6608b0b45712f94ba;
vm.transact(txhash);
}
}
6 changes: 3 additions & 3 deletions testdata/default/repros/Issue8006.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ contract Mock {
contract Issue8006Test is DSTest {
Vm constant vm = Vm(HEVM_ADDRESS);
IERC20 dai;
bytes32 transaction = 0x67cbad73764049e228495a3f90144aab4a37cb4b5fd697dffc234aa5ed811ace;
bytes32 transaction = 0xb23f389b26eb6f95c08e275ec2c360ab3990169492ff0d3e7b7233a3f81d299f;

function setUp() public {
vm.createSelectFork("mainnet", 16261704);
vm.createSelectFork("mainnet", 21134541);
dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
}

Expand All @@ -30,7 +30,7 @@ contract Issue8006Test is DSTest {
vm.etch(address(dai), address(new Mock()).code);
assertEq(dai.totalSupply(), 1);
vm.rollFork(transaction);
assertEq(dai.totalSupply(), 5155217627191887307044676292);
assertEq(dai.totalSupply(), 3324657947511778619416491233);
}

function testRollForkEtchCalled() public {
Expand Down
Loading

0 comments on commit cdda83c

Please sign in to comment.