Skip to content

Commit

Permalink
Foundry AutomationForwarder Refactored (#9786)
Browse files Browse the repository at this point in the history
* refactored

* yarn prettier + go wrappers
  • Loading branch information
JonWong203 authored Jul 12, 2023
1 parent 0a7f867 commit 7531372
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

import {IAutomationRegistryConsumer} from "../../interfaces/IAutomationRegistryConsumer.sol";
import {AutomationForwarder} from "../../AutomationForwarder.sol";
import {MockKeeperRegistry2_1} from "../../mocks/MockKeeperRegistry2_1.sol";
import {UpkeepCounter} from "../../mocks/UpkeepCounter.sol";
import "forge-std/Test.sol";
import {IAutomationRegistryConsumer} from "../interfaces/IAutomationRegistryConsumer.sol";
import {AutomationForwarder} from "../AutomationForwarder.sol";
import {MockKeeperRegistry2_1} from "../mocks/MockKeeperRegistry2_1.sol";
import {UpkeepCounter} from "../mocks/UpkeepCounter.sol";
import {BaseTest} from "./BaseTest.t.sol";

// in contracts directory, run
// forge test --match-path src/v0.8/dev/automation/2_1/test/AutomationForwarder/AutomationForwarder.t.sol
// forge test --match-path src/v0.8/dev/automation/2_1/test/AutomationForwarder.t.sol

contract AutomationForwarderSetUp is Test {
contract AutomationForwarderSetUp is BaseTest {
AutomationForwarder internal forwarder;
IAutomationRegistryConsumer internal default_registry;
UpkeepCounter internal default_target;
address internal OWNER;
address internal constant STRANGER = address(999);
uint256 constant GAS = 1e18;

function setUp() public {
function setUp() public override {
default_registry = IAutomationRegistryConsumer(new MockKeeperRegistry2_1());
default_target = new UpkeepCounter(10000, 1);
vm.startPrank(address(default_registry));
Expand All @@ -32,7 +30,7 @@ contract AutomationForwarderSetUp is Test {
}
}

contract AutomationForwarderTest_forward is AutomationForwarderSetUp {
contract AutomationForwarder_forward is AutomationForwarderSetUp {
function testBasicSuccess() public {
uint256 prevCount = default_target.counter();
bytes memory selector = getSelector("performUpkeep(bytes)", "performDataHere");
Expand Down Expand Up @@ -63,7 +61,7 @@ contract AutomationForwarderTest_forward is AutomationForwarderSetUp {
}
}

contract AutomationForwarderTest_updateRegistry is AutomationForwarderSetUp {
contract AutomationForwarder_updateRegistry is AutomationForwarderSetUp {
function testBasicSuccess() public {
address newRegistry = address(1);
forwarder.updateRegistry(address(newRegistry));
Expand Down
12 changes: 12 additions & 0 deletions contracts/src/v0.8/dev/automation/2_1/test/BaseTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

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

contract BaseTest is Test, StructFactory {
function setUp() public virtual {
vm.startPrank(OWNER);
deal(OWNER, 1e20);
}
}
7 changes: 7 additions & 0 deletions contracts/src/v0.8/dev/automation/2_1/test/StructFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16;

contract StructFactory {
address internal OWNER;
address internal constant STRANGER = address(999);
}

0 comments on commit 7531372

Please sign in to comment.