Skip to content

Commit

Permalink
Merge pull request #237 from lambdaclass/evm-integration-tests-new
Browse files Browse the repository at this point in the history
Evm integration tests new
  • Loading branch information
IAvecilla authored Aug 20, 2024
2 parents c40ac2d + 4078be8 commit 6a785da
Show file tree
Hide file tree
Showing 26 changed files with 2,875 additions and 44 deletions.
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 49 files
+1 −1 .github/workflows/l1-contracts-ci.yaml
+0 −117 .github/workflows/l1-contracts-foundry-ci.yaml
+9 −9 .gitmodules
+5 −1 .markdownlintignore
+4 −0 .prettierignore
+4 −0 .solhintignore
+28 −8 l1-contracts/contracts/dev-contracts/test/DummySharedBridge.sol
+12 −1 l1-contracts/deploy-scripts/AcceptAdmin.s.sol
+11 −13 l1-contracts/deploy-scripts/DeployL2Contracts.sol
+2 −2 l1-contracts/deploy-scripts/DeployPaymaster.s.sol
+2 −2 l1-contracts/deploy-scripts/Utils.sol
+3 −0 l1-contracts/foundry.toml
+0 −1 l1-contracts/lib/forge-std
+1 −0 l1-contracts/lib/forge-std
+0 −1 l1-contracts/lib/murky
+1 −0 l1-contracts/lib/murky
+0 −1 l1-contracts/lib/openzeppelin-contracts
+1 −0 l1-contracts/lib/openzeppelin-contracts
+0 −1 l1-contracts/lib/openzeppelin-contracts-upgradeable
+1 −0 l1-contracts/lib/openzeppelin-contracts-upgradeable
+8 −10 l1-contracts/scripts/register-hyperchain.ts
+11 −0 l1-contracts/src.ts/deploy.ts
+643 −50 l1-contracts/test/foundry/unit/concrete/Bridgehub/experimental_bridge.t.sol
+28 −8 l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/ClaimFailedDeposit.t.sol
+43 −8 l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/Deposit.t.sol
+16 −2 l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/FinalizeWithdrawal.sol
+2 −2 l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/Reentrancy.t.sol
+3 −6 l1-contracts/test/foundry/unit/concrete/Bridges/L1Erc20Bridge/_L1Erc20Bridge_Shared.t.sol
+6 −4 l1-contracts/test/unit_tests/l2-upgrade.test.spec.ts
+1 −1 l1-contracts/test/unit_tests/proxy_test.spec.ts
+15 −0 l2-contracts/.gitignore
+12 −0 l2-contracts/foundry.toml
+1 −0 l2-contracts/lib/forge-std
+1 −0 l2-contracts/lib/openzeppelin-contracts
+1 −0 l2-contracts/lib/openzeppelin-contracts-upgradeable
+1 −0 lib/forge-std
+1 −0 lib/murky
+1 −0 lib/openzeppelin-contracts
+1 −0 lib/openzeppelin-contracts-upgradeable
+15 −0 system-contracts/.gitignore
+3 −4 system-contracts/bootloader/bootloader.yul
+1 −1 system-contracts/contracts/ContractDeployer.sol
+1 −1 system-contracts/contracts/DefaultAccount.sol
+0 −4 system-contracts/contracts/EvmConstants.sol
+2 −4 system-contracts/contracts/EvmGasManager.sol
+12 −12 system-contracts/contracts/EvmInterpreter.yul
+2 −2 system-contracts/contracts/precompiles/CodeOracle.yul
+11 −0 system-contracts/foundry.toml
+1 −0 system-contracts/lib/forge-std
+1 −0 system-contracts/lib/openzeppelin-contracts
+1 −0 system-contracts/lib/openzeppelin-contracts-upgradeable
+19 −4 system-contracts/scripts/preprocess-bootloader.ts
+444 −569 yarn.lock
30 changes: 30 additions & 0 deletions core/tests/ts-integration/contracts/create/TestEVMCreate.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IContractDeployer {
function evmCodeHash(address key) external returns (bytes32);

function createEVM(
bytes calldata _initCode
) external payable returns (address newAddress);

function create2EVM(
bytes32 _salt,
bytes calldata _initCode
) external payable returns (address);
}

/// @notice An example of a system contract that be used for local testing.
/// @dev It is not used anywhere except for testing
contract TestEVMCreate {
IContractDeployer deployer = IContractDeployer(address(0x8006));

function create(bytes calldata _code) external {
deployer.createEVM(_code);
}

function create2(bytes32 _salt, bytes calldata _code) external payable {
deployer.create2EVM{value:msg.value}(_salt, _code);
}
}
76 changes: 76 additions & 0 deletions core/tests/ts-integration/contracts/token/ERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.0;

contract ERC20{
string public symbol;
string public name;
uint8 public decimals;
uint public totalSupply;

mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;

event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);

constructor() {
symbol = "TEST";
name = "Test Coin";
decimals = 18;
totalSupply = 1000000;
balances[msg.sender] = totalSupply;
emit Transfer(address(0), msg.sender, totalSupply);
}


function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}

function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}

function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}

function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}

function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
return allowed[tokenOwner][spender];
}

function safeAdd(uint a, uint b) internal pure returns (uint c) {
c = a + b;
require(c >= a);
}

function safeSub(uint a, uint b) internal pure returns (uint c) {
require(b <= a);
c = a - b;
}

function safeMul(uint a, uint b) internal pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}

function safeDiv(uint a, uint b) internal pure returns (uint c) {
require(b > 0);
c = a / b;
}

}
Loading

0 comments on commit 6a785da

Please sign in to comment.