Skip to content

Commit

Permalink
Merge pull request #55 from smart-transaction/refactor/example-names-…
Browse files Browse the repository at this point in the history
…and-categories

Renamed worked example and Partial function to SelfCheckout
  • Loading branch information
TokenTitan authored Jul 30, 2024
2 parents f040202 + dc73c7d commit 75c86a2
Show file tree
Hide file tree
Showing 40 changed files with 162 additions and 162 deletions.
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ src = 'src'
out = 'out'
libs = ['lib']
evm_version = "cancun"
solc = "0.8.23"
solc = "0.8.26"

ffi = true
ast = true
Expand Down
2 changes: 1 addition & 1 deletion script/BaseDeployer.s.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.19;
pragma solidity 0.8.26;

import {Script} from "forge-std/Script.sol";

Expand Down
2 changes: 1 addition & 1 deletion script/CallBreaker.s.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.19;
pragma solidity 0.8.26;

import {Script} from "forge-std/Script.sol";
import {CallBreaker} from "../src/timetravel/CallBreaker.sol";
Expand Down
2 changes: 1 addition & 1 deletion script/Laminator.s.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.19;
pragma solidity 0.8.26;

import {Script} from "forge-std/Script.sol";
import {BaseDeployer} from "./BaseDeployer.s.sol";
Expand Down
2 changes: 1 addition & 1 deletion script/SmarterContract.s.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.19;
pragma solidity 0.8.26;

import {Script} from "forge-std/Script.sol";
import {BaseDeployer} from "./BaseDeployer.s.sol";
Expand Down
20 changes: 10 additions & 10 deletions script/test/CronTwoCounter.s.sol → script/test/CronCounter.s.sol
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.19;
pragma solidity 0.8.26;

import {Script} from "forge-std/Script.sol";
import {BaseDeployer} from "../BaseDeployer.s.sol";
import {CronTwoCounter} from "test/examples/CronTwoCounter.sol";
import {CronCounter} from "test/examples/CronCounter.sol";
import {MyErc20} from "test/examples/MyErc20.sol";

/* solhint-disable no-console*/
import {console2} from "forge-std/console2.sol";

contract DeployCronTwoCounter is Script, BaseDeployer {
contract DeployCronCounter is Script, BaseDeployer {
address private _callBreaker;

/// @dev Compute the CREATE2 addresses for contracts (proxy, counter).
/// @param salt The salt for the CronTwoCounter contract.
/// @param salt The salt for the CronCounter contract.
modifier computeCreate2(bytes32 salt) {
_callBreaker = vm.envAddress("CALL_BREAKER_ADDRESS");

_create2addr =
computeCreate2Address(salt, hashInitCode(type(CronTwoCounter).creationCode, abi.encode(_callBreaker)));
computeCreate2Address(salt, hashInitCode(type(CronCounter).creationCode, abi.encode(_callBreaker)));

_;
}
Expand All @@ -33,10 +33,10 @@ contract DeployCronTwoCounter is Script, BaseDeployer {
computeCreate2(_salt)
returns (address)
{
console2.log("CronTwoCounter create2 address:", _create2addr, "\n");
console2.log("CronCounter create2 address:", _create2addr, "\n");

for (uint256 i; i < deployForks.length;) {
console2.log("Deploying CronTwoCounter to chain: ", uint256(deployForks[i]), "\n");
console2.log("Deploying CronCounter to chain: ", uint256(deployForks[i]), "\n");

createSelectFork(deployForks[i]);

Expand All @@ -51,10 +51,10 @@ contract DeployCronTwoCounter is Script, BaseDeployer {

/// @dev Function to perform actual deployment.
function chainDeploySmartedContract() private broadcast(_deployerPrivateKey) {
address cronTwoCounter = address(new CronTwoCounter{salt: _salt}(_callBreaker));
address cronTwoCounter = address(new CronCounter{salt: _salt}(_callBreaker));

require(_create2addr == cronTwoCounter, "Address mismatch CronTwoCounter");
require(_create2addr == cronTwoCounter, "Address mismatch CronCounter");

console2.log("CronTwoCounter deployed at address:", cronTwoCounter, "\n");
console2.log("CronCounter deployed at address:", cronTwoCounter, "\n");
}
}
6 changes: 3 additions & 3 deletions script/test/SelfCheckout.s.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.19;
pragma solidity 0.8.26;

import {Script} from "forge-std/Script.sol";
import {BaseDeployer} from "../BaseDeployer.s.sol";
import {SelfCheckout} from "test/examples/SelfCheckout.sol";
import {BaseDeployer} from "script/BaseDeployer.s.sol";
import {SelfCheckout} from "test/examples/DeFi/SelfCheckout.sol";
import {MyErc20} from "test/examples/MyErc20.sol";

/* solhint-disable no-console*/
Expand Down
2 changes: 1 addition & 1 deletion test/CallBreaker.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import "forge-std/Test.sol";

Expand Down
8 changes: 4 additions & 4 deletions test/CronTwoExample.t.sol → test/CronCounter.t.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import "forge-std/Vm.sol";

import "./solve-lib/CronTwo.sol";
import "./solve-lib/CronCounterLib.sol";

import "../src/lamination/Laminator.sol";
import "../src/timetravel/CallBreaker.sol";

contract CronTwoTest is Test, CronTwoLib {
contract CronTest is Test, CronCounterLib {
address deployer;
address pusher;
address filler;
Expand All @@ -33,7 +33,7 @@ contract CronTwoTest is Test, CronTwoLib {
vm.label(filler, "filler");
}

function testrun1CronTwo() external {
function testrun1Cron() external {
uint256 laminatorSequenceNumber;

vm.startPrank(pusher);
Expand Down
7 changes: 3 additions & 4 deletions test/FlashLiquidityTest.t.sol → test/FlashLiquidity.t.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import "../src/timetravel/CallBreaker.sol";
import "../test/examples/LimitOrder.sol";
import "../test/solve-lib/FlashLiquidityExample.sol";
import "../test/solve-lib/FlashLiquidityLib.sol";

contract FlashLiquidityTest is Test, FlashLiquidityExampleLib {
contract FlashLiquidityTest is Test, FlashLiquidityLib {
address deployer;
address pusher;
address filler;
Expand Down
2 changes: 1 addition & 1 deletion test/FlashPillTest.t.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import "../src/timetravel/CallBreaker.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/GasSnapshot.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import {Test} from "forge-std/Test.sol";
import {LaminatorHarness} from "./Laminator.t.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/Laminator.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import "forge-std/Test.sol";

Expand Down
10 changes: 5 additions & 5 deletions test/PartialFunctionTest.t.sol → test/MEVTimeCompute.t.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.23;
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import "src/timetravel/CallBreaker.sol";
import "test/examples/MEVOracle/PartialFunctionContract.sol";
import "test/solve-lib/MEVOracle/PartialFunctionExample.sol";
import "test/examples/MEVOracle/MEVTimeCompute.sol";
import "test/solve-lib/MEVTimeOracle/MEVTimeComputeLib.sol";

contract PartialFunctionTest is Test, PartialFunctionExampleLib {
contract MEVTimeComputeTest is Test, MEVTimeComputeLib {
address deployer;
address pusher;
address filler;
Expand All @@ -31,7 +31,7 @@ contract PartialFunctionTest is Test, PartialFunctionExampleLib {
vm.label(filler, "filler");
}

function testPartialFunction() external {
function testMEVTimeCompute() external {
uint256 laminatorSequenceNumber;

vm.startPrank(pusher);
Expand Down
2 changes: 1 addition & 1 deletion test/NoopTurnerTest.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import "../src/timetravel/CallBreaker.sol";
Expand Down
6 changes: 3 additions & 3 deletions test/PnP.t.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import "../src/timetravel/CallBreaker.sol";
import "../test/examples/PnP.sol";
import "../test/solve-lib/PnPExample.sol";
import "../test/solve-lib/PnPLib.sol";

contract PnPTest is Test, PnPExampleLib {
contract PnPTest is Test, PnPLib {
address deployer;
address pusher;
address filler;
Expand Down
6 changes: 3 additions & 3 deletions test/Sandwich.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ pragma solidity ^0.8.19;
import "forge-std/Test.sol";
import "forge-std/Vm.sol";

import "./solve-lib/CronTwo.sol";
import "./solve-lib/CronCounterLib.sol";

import "../src/lamination/Laminator.sol";
import "../src/timetravel/CallBreaker.sol";

contract CronTwoTest is Test, CronTwoLib {
contract CronTest is Test, CronCounterLib {
address deployer;
address pusher;
address filler;
Expand All @@ -33,7 +33,7 @@ contract CronTwoTest is Test, CronTwoLib {
vm.label(filler, "filler");
}

function testrun1CronTwo() external {
function testrun1Cron() external {
uint256 laminatorSequenceNumber;

vm.startPrank(pusher);
Expand Down
17 changes: 8 additions & 9 deletions test/WorkedExample.t.sol → test/SelfCheckout.t.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import "forge-std/Vm.sol";

import "./solve-lib/WorkedExample.sol";
import "src/lamination/Laminator.sol";
import "src/timetravel/CallBreaker.sol";
import "test/examples/DeFi/SelfCheckout.sol";
import "test/examples/MyErc20.sol";
import "test/solve-lib/DeFi/SelfCheckoutLib.sol";

import "../src/lamination/Laminator.sol";
import "../src/timetravel/CallBreaker.sol";
import "../test/examples/SelfCheckout.sol";
import "../test/examples/MyErc20.sol";

contract WorkedExampleTest is Test, WorkedExampleLib {
contract SelfCheckoutTest is Test, SelfCheckoutLib {
address deployer;
address pusher;
address filler;
Expand All @@ -35,7 +34,7 @@ contract WorkedExampleTest is Test, WorkedExampleLib {
vm.label(filler, "filler");
}

function test_workedExample() external {
function test_selfCheckout() external {
uint256 laminatorSequenceNumber;

vm.startPrank(pusher);
Expand Down
33 changes: 25 additions & 8 deletions test/LimitOrder.t.sol → test/SlippageProtection.t.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import "forge-std/Test.sol";
import "../src/timetravel/CallBreaker.sol";
import "../test/examples/LimitOrder.sol";
import "../test/solve-lib/LimitOrderExample.sol";
import "src/timetravel/CallBreaker.sol";
import "test/solve-lib/SlippageProtectionLib.sol";

contract LimitOrderTest is Test, LimitOrderExampleLib {
contract SlippageProtectionTest is Test, SlippageProtectionLib {
address deployer;
address pusher;
address filler;
Expand All @@ -31,18 +30,19 @@ contract LimitOrderTest is Test, LimitOrderExampleLib {
vm.label(filler, "filler");
}

function testLimitOrder() external {
function testSlippageProtection() external {
uint256 laminatorSequenceNumber;
uint256 maxSlippage = 10;

vm.startPrank(pusher);
laminatorSequenceNumber = userLand();
laminatorSequenceNumber = userLand(maxSlippage);
vm.stopPrank();

// go forward in time
vm.roll(block.number + 1);

vm.startPrank(filler);
solverLand(laminatorSequenceNumber, filler);
solverLand(laminatorSequenceNumber, filler, maxSlippage);
vm.stopPrank();

assertFalse(callbreaker.isPortalOpen());
Expand All @@ -52,4 +52,21 @@ contract LimitOrderTest is Test, LimitOrderExampleLib {
assertTrue(init);
assertTrue(exec);
}

function testSlippageProtectionRevert() external {
uint256 laminatorSequenceNumber;
uint256 maxSlippage = 1;

vm.startPrank(pusher);
laminatorSequenceNumber = userLand(maxSlippage);
vm.stopPrank();

// go forward in time
vm.roll(block.number + 1);

vm.startPrank(filler);
vm.expectRevert();
solverLand(laminatorSequenceNumber, filler, maxSlippage);
vm.stopPrank();
}
}
2 changes: 1 addition & 1 deletion test/SmarterContract.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import "forge-std/Test.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/TimeTypes.t.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import {Test} from "forge-std/Test.sol";
import {CallObject, CallObjectStorage} from "../src/TimeTypes.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/CallBreakerHarness.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import {CallBreaker, CallObject, ReturnObject} from "src/timetravel/CallBreaker.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/contracts/SmarterContractHarness.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import {SmarterContract, CallObject} from "src/timetravel/SmarterContract.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.6.2 <0.9.0;
pragma solidity 0.8.26;

import "../../src/timetravel/SmarterContract.sol";

contract CronTwoCounter is SmarterContract {
contract CronCounter is SmarterContract {
mapping(address => uint256) private _counters;

constructor(address _callbreaker) SmarterContract(_callbreaker) {}
Expand Down
Loading

0 comments on commit 75c86a2

Please sign in to comment.