Skip to content

Commit

Permalink
Pin some tests to Paris
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy committed Oct 17, 2024
1 parent 84c9838 commit 8e8f311
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
45 changes: 36 additions & 9 deletions crates/forge/tests/cli/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//! Contains various tests for checking forge's commands

use crate::constants::*;
use foundry_compilers::artifacts::{remappings::Remapping, ConfigurableContractArtifact, Metadata};
use foundry_compilers::artifacts::{
remappings::Remapping, ConfigurableContractArtifact, EvmVersion, Metadata,
};
use foundry_config::{
parse_with_profile, BasicConfig, Chain, Config, FuzzConfig, InvariantConfig, SolidityErrorCode,
};
Expand Down Expand Up @@ -1521,8 +1523,9 @@ forgetest!(gas_report_all_contracts, |prj, cmd| {
prj.insert_ds_test();
prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap();

// report for all
// report for all, pin test to Paris EVM version.
prj.write_config(Config {
evm_version: EvmVersion::Paris,
gas_reports: (vec!["*".to_string()]),
gas_reports_ignore: (vec![]),
..Default::default()
Expand Down Expand Up @@ -1566,7 +1569,11 @@ forgetest!(gas_report_all_contracts, |prj, cmd| {
{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}}
"#]].is_jsonlines());

prj.write_config(Config { gas_reports: (vec![]), ..Default::default() });
prj.write_config(Config {
evm_version: EvmVersion::Paris,
gas_reports: (vec![]),
..Default::default()
});
cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#"
...
| src/Contracts.sol:ContractOne contract | | | | | |
Expand Down Expand Up @@ -1605,7 +1612,11 @@ forgetest!(gas_report_all_contracts, |prj, cmd| {
{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}}
"#]].is_jsonlines());

prj.write_config(Config { gas_reports: (vec!["*".to_string()]), ..Default::default() });
prj.write_config(Config {
evm_version: EvmVersion::Paris,
gas_reports: (vec!["*".to_string()]),
..Default::default()
});
cmd.forge_fuse().arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#"
...
| src/Contracts.sol:ContractOne contract | | | | | |
Expand Down Expand Up @@ -1645,6 +1656,7 @@ forgetest!(gas_report_all_contracts, |prj, cmd| {
"#]].is_jsonlines());

prj.write_config(Config {
evm_version: EvmVersion::Paris,
gas_reports: (vec![
"ContractOne".to_string(),
"ContractTwo".to_string(),
Expand Down Expand Up @@ -1696,7 +1708,11 @@ forgetest!(gas_report_some_contracts, |prj, cmd| {
prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap();

// report for One
prj.write_config(Config { gas_reports: vec!["ContractOne".to_string()], ..Default::default() });
prj.write_config(Config {
evm_version: EvmVersion::Paris,
gas_reports: vec!["ContractOne".to_string()],
..Default::default()
});
cmd.forge_fuse();
cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#"
...
Expand All @@ -1719,7 +1735,11 @@ forgetest!(gas_report_some_contracts, |prj, cmd| {
"#]].is_jsonlines());

// report for Two
prj.write_config(Config { gas_reports: vec!["ContractTwo".to_string()], ..Default::default() });
prj.write_config(Config {
evm_version: EvmVersion::Paris,
gas_reports: vec!["ContractTwo".to_string()],
..Default::default()
});
cmd.forge_fuse();
cmd.arg("test").arg("--gas-report").assert_success().stdout_eq(str![[r#"
...
Expand All @@ -1740,6 +1760,7 @@ forgetest!(gas_report_some_contracts, |prj, cmd| {

// report for Three
prj.write_config(Config {
evm_version: EvmVersion::Paris,
gas_reports: vec!["ContractThree".to_string()],
..Default::default()
});
Expand Down Expand Up @@ -1769,8 +1790,9 @@ forgetest!(gas_ignore_some_contracts, |prj, cmd| {
prj.insert_ds_test();
prj.add_source("Contracts.sol", GAS_REPORT_CONTRACTS).unwrap();

// ignore ContractOne
// ignore ContractOne, pin test to Paris EVM version.
prj.write_config(Config {
evm_version: EvmVersion::Paris,
gas_reports: (vec!["*".to_string()]),
gas_reports_ignore: (vec!["ContractOne".to_string()]),
..Default::default()
Expand Down Expand Up @@ -1805,9 +1827,10 @@ forgetest!(gas_ignore_some_contracts, |prj, cmd| {
{"gas":103375,"size":255,"functions":{"bar":{"bar()":{"calls":1,"min":64984,"mean":64984,"median":64984,"max":64984}}}}
"#]].is_jsonlines());

// ignore ContractTwo
// ignore ContractTwo, pin test to Paris EVM version.
cmd.forge_fuse();
prj.write_config(Config {
evm_version: EvmVersion::Paris,
gas_reports: (vec![]),
gas_reports_ignore: (vec!["ContractTwo".to_string()]),
..Default::default()
Expand Down Expand Up @@ -1842,9 +1865,10 @@ forgetest!(gas_ignore_some_contracts, |prj, cmd| {
{"gas":103591,"size":256,"functions":{"baz":{"baz()":{"calls":1,"min":260712,"mean":260712,"median":260712,"max":260712}}}}
"#]].is_jsonlines());

// ignore ContractThree
// ignore ContractThree, pin test to Paris EVM version.
cmd.forge_fuse();
prj.write_config(Config {
evm_version: EvmVersion::Paris,
gas_reports: (vec![
"ContractOne".to_string(),
"ContractTwo".to_string(),
Expand Down Expand Up @@ -2180,6 +2204,9 @@ Compiler run successful!

// checks that build --sizes includes all contracts even if unchanged
forgetest_init!(can_build_sizes_repeatedly, |prj, cmd| {
// Pin test to Paris EVM version.
let config = Config { evm_version: EvmVersion::Paris, ..Default::default() };
prj.write_config(config);
prj.clear_cache();

cmd.args(["build", "--sizes"]).assert_success().stdout_eq(str![[r#"
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
5 changes: 5 additions & 0 deletions crates/forge/tests/cli/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
use crate::constants::TEMPLATE_CONTRACT;
use alloy_primitives::{hex, Address, Bytes};
use anvil::{spawn, NodeConfig};
use foundry_compilers::artifacts::EvmVersion;
use foundry_config::Config;
use foundry_test_utils::{
rpc,
util::{OTHER_SOLC_VERSION, SOLC_VERSION},
Expand Down Expand Up @@ -176,6 +178,7 @@ script failed: revert: failed
// Tests that the manually specified gas limit is used when using the --unlocked option
forgetest_async!(can_execute_script_command_with_manual_gas_limit_unlocked, |prj, cmd| {
foundry_test_utils::util::initialize(prj.root());
prj.write_config(Config { evm_version: EvmVersion::Paris, ..Default::default() });
let deploy_script = prj
.add_source(
"Foo",
Expand Down Expand Up @@ -278,6 +281,7 @@ ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
// Tests that the manually specified gas limit is used.
forgetest_async!(can_execute_script_command_with_manual_gas_limit, |prj, cmd| {
foundry_test_utils::util::initialize(prj.root());
prj.write_config(Config { evm_version: EvmVersion::Paris, ..Default::default() });
let deploy_script = prj
.add_source(
"Foo",
Expand Down Expand Up @@ -458,6 +462,7 @@ result: uint256 255

forgetest_async!(can_broadcast_script_skipping_simulation, |prj, cmd| {
foundry_test_utils::util::initialize(prj.root());
prj.write_config(Config { evm_version: EvmVersion::Paris, ..Default::default() });
// This example script would fail in on-chain simulation
let deploy_script = prj
.add_source(
Expand Down
16 changes: 14 additions & 2 deletions crates/forge/tests/cli/test_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Contains various tests for `forge test`.

use alloy_primitives::U256;
use foundry_compilers::artifacts::EvmVersion;
use foundry_config::{Config, FuzzConfig};
use foundry_test_utils::{
rpc, str,
Expand Down Expand Up @@ -543,6 +544,7 @@ forgetest_init!(exit_code_error_on_fail_fast_with_json, |prj, cmd| {
// https://github.com/foundry-rs/foundry/pull/6531
forgetest_init!(fork_traces, |prj, cmd| {
prj.wipe_contracts();
prj.write_config(Config { evm_version: EvmVersion::Paris, ..Default::default() });

let endpoint = rpc::next_http_archive_rpc_endpoint();

Expand Down Expand Up @@ -1190,7 +1192,11 @@ forgetest_init!(internal_functions_trace, |prj, cmd| {
prj.clear();

// Disable optimizer because for simple contract most functions will get inlined.
prj.write_config(Config { optimizer: false, ..Default::default() });
prj.write_config(Config {
optimizer: false,
evm_version: EvmVersion::Paris,
..Default::default()
});

prj.add_test(
"Simple",
Expand Down Expand Up @@ -1268,7 +1274,11 @@ forgetest_init!(internal_functions_trace_memory, |prj, cmd| {
prj.clear();

// Disable optimizer because for simple contract most functions will get inlined.
prj.write_config(Config { optimizer: false, ..Default::default() });
prj.write_config(Config {
optimizer: false,
evm_version: EvmVersion::Paris,
..Default::default()
});

prj.add_test(
"Simple",
Expand Down Expand Up @@ -1399,6 +1409,7 @@ contract DeterministicRandomnessTest is Test {
// https://github.com/foundry-rs/foundry/issues/5491
forgetest_init!(gas_metering_pause_last_call, |prj, cmd| {
prj.wipe_contracts();
prj.write_config(Config { evm_version: EvmVersion::Paris, ..Default::default() });

prj.add_test(
"ATest.t.sol",
Expand Down Expand Up @@ -1565,6 +1576,7 @@ forgetest_init!(pause_tracing, |prj, cmd| {
prj.insert_ds_test();
prj.insert_vm();
prj.clear();
prj.write_config(Config { evm_version: EvmVersion::Paris, ..Default::default() });

prj.add_source(
"Pause.t.sol",
Expand Down

0 comments on commit 8e8f311

Please sign in to comment.