Skip to content

Commit

Permalink
fix(test): Simplify tests
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
  • Loading branch information
jdubpark committed Apr 5, 2024
1 parent 2f6a913 commit c92685c
Show file tree
Hide file tree
Showing 30 changed files with 165 additions and 270 deletions.
12 changes: 10 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 Expand Up @@ -52,6 +54,12 @@ contract IPAccountTest is BaseTest {

IIPAccount ipAccount = IIPAccount(payable(account));

// Register vm.addr(2) as a valid module to test isValidSigner
bytes32 moduleNameHash = keccak256(abi.encodePacked("MockModuleAddr2"));
bytes32 moduleRegistryStorageLocation = 0xa17d78ae7aee011aefa3f1388acb36741284b44eb3fcffe23ecc3a736eaa2700;
bytes32 entrySlot = keccak256(abi.encodePacked(moduleRegistryStorageLocation, moduleNameHash));
vm.store(address(moduleRegistry), entrySlot, bytes32(uint256(uint160(vm.addr(2)))));

// Check token and owner functions
(uint256 chainId_, address tokenAddress_, uint256 tokenId_) = ipAccount.token();
assertEq(chainId_, block.chainid);
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 c92685c

Please sign in to comment.