Skip to content

Commit

Permalink
Shanghai compat test
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy committed Nov 7, 2024
1 parent 0acbb72 commit 702c270
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/forge/tests/it/spec.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
//! Integration tests for EVM specifications.

use crate::{config::*, test_helpers::TEST_DATA_DEFAULT};
use crate::{config::*, test_helpers::TEST_DATA_PARIS};
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).run().await;
TestConfig::with_filter(TEST_DATA_PARIS.runner(), filter)
.evm_spec(SpecId::SHANGHAI)
.run()
.await;
}
29 changes: 29 additions & 0 deletions testdata/paris/spec/ShanghaiCompat.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.18;

import "ds-test/test.sol";
import "cheats/Vm.sol";

contract ShanghaiCompat is DSTest {
Vm constant vm = Vm(HEVM_ADDRESS);

function testPush0() public {
address target = address(uint160(uint256(0xc4f3)));

bytes memory bytecode = hex"365f5f37365ff3";
// 36 CALLDATASIZE
// 5F PUSH0
// 5F PUSH0
// 37 CALLDATACOPY -> copies calldata at mem[0..calldatasize]

// 36 CALLDATASIZE
// 5F PUSH0
// F3 RETURN -> returns mem[0..calldatasize]

vm.etch(target, bytecode);

(bool success, bytes memory result) = target.call(bytes("hello PUSH0"));
assertTrue(success);
assertEq(string(result), "hello PUSH0");
}
}

0 comments on commit 702c270

Please sign in to comment.