Skip to content

Commit

Permalink
Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
giraffe0x committed Feb 5, 2024
1 parent e247d96 commit 9460d4e
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"solidity.compileUsingRemoteVersion": "v0.8.24+commit.e11b9ed9"
}
6 changes: 6 additions & 0 deletions bytecode/Basic.hex
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
600e600d600039600e6000f3fe600560030160005260206000f3

only first line of this file is used
we can write comments here

e.g., I compiled Basic.yul and took its bytecode. Then I deleted DUP1 opcode to test the contract without it
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
src = "src"
out = "out"
libs = ["lib"]
ffi = true

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
3 changes: 3 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
deploy-yul/=lib/deploy-yul/contracts/
ds-test/=lib/forge-std/lib/ds-test/src/
forge-std/=lib/forge-std/src/
14 changes: 0 additions & 14 deletions src/Counter.sol

This file was deleted.

31 changes: 31 additions & 0 deletions test/Basic.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.24;

import "forge-std/Test.sol";
import "deploy-yul/BytecodeDeployer.sol";
import "deploy-yul/YulDeployer.sol";
import "forge-std/console.sol";

contract BasicTest is Test {
YulDeployer yulDeployer = new YulDeployer();
BytecodeDeployer bytecodeDeployer = new BytecodeDeployer();
address basic;
address basicBytecode;

function setUp() external {
basic = yulDeployer.deployContract("Basic");
basicBytecode = bytecodeDeployer.deployContract("Basic");
}

function testBasic() external {
(bool success, bytes memory result) = basic.staticcall("");
assertEq(uint256(bytes32(result)), 8);
assertTrue(success);
}

function testBasicBytecode() external {
(bool success, bytes memory result) = basicBytecode.staticcall("");
assertEq(uint256(bytes32(result)), 8);
assertTrue(success);
}
}
24 changes: 0 additions & 24 deletions test/Counter.t.sol

This file was deleted.

13 changes: 13 additions & 0 deletions yul/Basic.yul
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
object "Basic" {
code {
datacopy(0, dataoffset("Runtime"), datasize("Runtime"))
return(0, datasize("Runtime"))
}
object "Runtime" {
code {
let sum := add(3, 5)
mstore(0x0, sum)
return(0x0, 0x20)
}
}
}

0 comments on commit 9460d4e

Please sign in to comment.