Skip to content

Commit

Permalink
Single DeployHelper for Deployment and Tests (storyprotocol#36)
Browse files Browse the repository at this point in the history
- Use new BaseTest and remove mock deployers
- Modify some tests to clarify on caller using vm prank
- Minor lint fixes for state variable visibility
- Mock royalty policy LAP
- Prepare codebase structure to remove some mocks in next PR
- Remove unused test files
- refactor(script): Remove deployment of IPAccountRegistry and use alt
  • Loading branch information
jdubpark authored Apr 9, 2024
1 parent ca20a9d commit ec35ce0
Show file tree
Hide file tree
Showing 38 changed files with 578 additions and 1,430 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/foundry_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

- name: Run Forge tests
run: |
forge test -vvv --fork-url https://gateway.tenderly.co/public/sepolia --fork-block-number 5196000
forge test -vvv
id: forge-test

- name: Run solhint
Expand Down
617 changes: 20 additions & 597 deletions script/foundry/deployment/Main.s.sol

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions script/foundry/utils/BroadcastManager.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ pragma solidity ^0.8.23;

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

import { StringUtil } from "../../../script/foundry/utils/StringUtil.sol";
import { StringUtil } from "./StringUtil.sol";
import { MockERC20 } from "../../../test/foundry/mocks/token/MockERC20.sol";

contract BroadcastManager is Script {
address public multisig;
Expand All @@ -13,17 +14,17 @@ contract BroadcastManager is Script {
uint256 deployerPrivateKey;
if (block.chainid == 1) { // Tenderly mainnet fork
deployerPrivateKey = vm.envUint("MAINNET_PRIVATEKEY");
deployer = vm.envAddress("MAINNET_DEPLOYER_ADDRESS");
deployer = vm.addr(deployerPrivateKey);
multisig = vm.envAddress("MAINNET_MULTISIG_ADDRESS");
vm.startBroadcast(deployerPrivateKey);
} else if (block.chainid == 11155111) {
deployerPrivateKey = vm.envUint("SEPOLIA_PRIVATEKEY");
deployer = vm.envAddress("SEPOLIA_DEPLOYER_ADDRESS");
deployer = vm.addr(deployerPrivateKey);
multisig = vm.envAddress("SEPOLIA_MULTISIG_ADDRESS");
vm.startBroadcast(deployerPrivateKey);
} else if (block.chainid == 31337) {
multisig = address(0x456);
deployer = address(0x999);
require(deployer != address(0), "Deployer not set");
multisig = vm.addr(0x987321);
vm.startPrank(deployer);
} else {
revert("Unsupported chain");
Expand Down
373 changes: 373 additions & 0 deletions script/foundry/utils/DeployHelper.sol

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions script/foundry/utils/JsonDeploymentHandler.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ contract JsonDeploymentHandler is Script {
using StringUtil for uint256;
using stdJson for string;

string output;
string readJson;
string chainId;
string key;
string internalKey = "key";
// keep all variables private to avoid conflicts
string private output;
string private readJson;
string private chainId;
string private key;
string private internalKey = "key";

constructor(string memory _key) {
chainId = (block.chainid).toString();
Expand Down
6 changes: 4 additions & 2 deletions test/foundry/IPAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ contract IPAccountTest is BaseTest {

function setUp() public override {
super.setUp();
deployConditionally();
postDeploymentSetup();

module = new MockModule(address(ipAssetRegistry), address(moduleRegistry), "MockModule");

vm.startPrank(u.admin); // used twice, name() and registerModule()
moduleRegistry.registerModule(module.name(), address(module));
vm.stopPrank();
}

function test_IPAccount_Idempotency() public {
Expand Down
5 changes: 1 addition & 4 deletions test/foundry/IPAccountMetaTx.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ contract IPAccountMetaTxTest is BaseTest {

function setUp() public override {
super.setUp();
buildDeployAccessCondition(DeployAccessCondition({ accessController: true, governance: false }));
buildDeployRegistryCondition(DeployRegistryCondition({ moduleRegistry: true, licenseRegistry: false }));
deployConditionally();
postDeploymentSetup();

ownerPrivateKey = 0xA11111;
callerPrivateKey = 0xB22222;
owner = vm.addr(ownerPrivateKey);
Expand Down
2 changes: 0 additions & 2 deletions test/foundry/IPAccountStorage.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ contract IPAccountStorageTest is BaseTest {

function setUp() public override {
super.setUp();
deployConditionally();
postDeploymentSetup();

module = new MockModule(address(ipAssetRegistry), address(moduleRegistry), "MockModule");

Expand Down
2 changes: 0 additions & 2 deletions test/foundry/IPAccountStorageOps.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ contract IPAccountStorageOpsTest is BaseTest {

function setUp() public override {
super.setUp();
deployConditionally();
postDeploymentSetup();

module = new MockModule(address(ipAssetRegistry), address(moduleRegistry), "MockModule");

Expand Down
5 changes: 2 additions & 3 deletions test/foundry/access/AccessControlled.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ contract AccessControlledTest is BaseTest {

function setUp() public override {
super.setUp();
buildDeployAccessCondition(DeployAccessCondition({ accessController: true, governance: true }));
deployConditionally();
postDeploymentSetup();

mockNFT.mintId(owner, tokenId);
address deployedAccount = ipAccountRegistry.registerIpAccount(block.chainid, address(mockNFT), tokenId);
Expand All @@ -31,6 +28,8 @@ contract AccessControlledTest is BaseTest {
address(moduleRegistry),
"MockAccessControlledModule"
);

vm.prank(u.admin);
moduleRegistry.registerModule("MockAccessControlledModule", address(mockModule));
}

Expand Down
Loading

0 comments on commit ec35ce0

Please sign in to comment.