Skip to content

Commit

Permalink
Merge pull request PraneshASP#12 from PraneshASP/feat/deployment-script
Browse files Browse the repository at this point in the history
✨ Deployment scripts
  • Loading branch information
PraneshASP authored Feb 10, 2023
2 parents 5c3a499 + 9d16337 commit b625437
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
ROPSTEN_URL=https://eth-ropsten.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
RPC_URL=<RPC_URL>
PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1
3 changes: 3 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ jobs:

- name: Run Tests
run: forge test -vvv
env:
RPC_URL: ${{ secrets.RPC_URL }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.env

#Hardhat files
#Build files
cache
artifacts
broadcast
14 changes: 14 additions & 0 deletions scripts/DeployMath.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.15;

import "foundry-huff/HuffDeployer.sol";
import "forge-std/Script.sol";

import {IMath} from "../src/interfaces/IMath.sol";

contract DeployMath is Script {
function run() public returns (IMath math) {
math = IMath(HuffDeployer.broadcast("wrappers/MathWrapper"));
console2.log("MathWrapper contract deployed to: ", address(math));
}
}
19 changes: 19 additions & 0 deletions scripts/DeployWadRayMath.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.15;

import "foundry-huff/HuffDeployer.sol";
import "forge-std/Script.sol";

import {IWadRayMath} from "../src/interfaces/IWadRayMath.sol";

contract DeployWadRayMath is Script {
function run() public returns (IWadRayMath wadRayMath) {
wadRayMath = IWadRayMath(
HuffDeployer.broadcast("wrappers/WadMathWrapper")
);
console2.log(
"WadRayMathWrapper contract deployed to: ",
address(wadRayMath)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include '../../../src/Math.huff'
#include '../Math.huff'

/* Interface */
#define function addNumbers(uint256,uint256) nonpayable returns (uint256)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include '../../../src/WadRayMath.huff'
#include '../WadRayMath.huff'
/* Interface */
#define function wadMul(uint256,uint256) nonpayable returns (uint256)
#define function wadDiv(uint256,uint256) nonpayable returns (uint256)
Expand Down
4 changes: 1 addition & 3 deletions test/foundry/Math.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ contract MathTest is Test {
uint256 public constant MIN = type(uint256).min;

function setUp() public {
address addr = HuffDeployer.deploy(
"../test/foundry/wrappers/MathWrapper"
);
address addr = HuffDeployer.deploy("./wrappers/MathWrapper");
// Hardcoding the deployed address as there are some issues with --ffi and huffc
math = IMath(addr);
}
Expand Down
39 changes: 39 additions & 0 deletions test/foundry/MathForkTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "forge-std/Test.sol";
import {HuffDeployer} from "foundry-huff/HuffDeployer.sol";
import {IMath} from "../../src/interfaces/IMath.sol";

contract MathForkTest is Test {
IMath public math;

function setUp() public {
vm.createSelectFork(vm.envString("RPC_URL"));
math = IMath(0x999581D8C0BADA05502945fF3e490f41aE9e4102);
}

function testAddNumbers() public {
uint256 result = math.addNumbers(420, 69);
assertEq(result, 489);
}

function testSubNumbers() public {
uint256 result = math.subNumbers(420, 69);
assertEq(result, 351);
}

function testMultiplyNumbers() public {
uint256 result = math.multiplyNumbers(100, 69);
assertEq(result, 6900);
}

function testDivideNumbers() public {
uint256 result = math.divideNumbers(200, 10);
assertEq(result, 20);
}

function testAbs() public view {
require(math.abs(1, 10) == 9);
}
}
4 changes: 1 addition & 3 deletions test/foundry/WadRayMath.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ contract WadRayMathTest is Test {

/// @dev Setup the testing environment.
function setUp() public {
sut = IWadRayMath(
HuffDeployer.deploy("../test/foundry/wrappers/WadRayMathWrapper")
);
sut = IWadRayMath(HuffDeployer.deploy("./wrappers/WadRayMathWrapper"));
}

function testDeployment() public {
Expand Down

0 comments on commit b625437

Please sign in to comment.