Skip to content
This repository was archived by the owner on Apr 30, 2024. It is now read-only.

Commit b3152a3

Browse files
authored
New Unified Test Framework (#90)
* refactor: move mock files * feat: new and redone mock files * fix: add proper interfaces * fix: mock interfaces and lints * fix: add public states in interfaces * feat: simplify testing framework with easy setups * refactor: minor changes in deploy script imports * refactor: modify tests to use the new unified test framework * style: linting * refactor: Tagging Module inherit Base Module * fix: Param changes after rebase #85 * refactor: test folder structure * feat: update mock modules after rebase #85 * refactor: Param changes after rebase #85, typo fix * style: solhint * nit: setUp fix & remove comments, names, and unused vars * nit: comments * refactor: remove interface fn in AccessController * fix: Update workflow to skip size check on test files * refactor: add file ext .t.sol to skip build (test)
1 parent 3986d5b commit b3152a3

File tree

59 files changed

+2100
-1455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2100
-1455
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ jobs:
4747
run: |
4848
ls -R ${{ github.workspace }}
4949
50+
# first, build contracts excluding the tests and scripts. Check contract sizes in this step.
51+
# then, build contracts including the tests and scripts. Don't check contract sizes.
5052
- name: Run Forge build
5153
run: |
5254
forge --version
53-
forge build --force --sizes
55+
forge build --force --sizes --skip test --skip script
56+
forge build
5457
id: build
5558

5659
- name: Run Forge tests
@@ -72,4 +75,4 @@ jobs:
7275
# - name: Code Coverage
7376
# run:
7477
# forge coverage --report lcov --report summary
75-
# id: forge-code-coverage
78+
# id: forge-code-coverage

contracts/interfaces/modules/dispute/IDisputeModule.sol

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,32 @@ interface IDisputeModule {
6161
/// @param disputeId The dispute id
6262
event DisputeResolved(uint256 disputeId);
6363

64+
/// @notice Dispute id
65+
function disputeId() external view returns (uint256);
66+
67+
/// @notice The address of the base arbitration policy
68+
function baseArbitrationPolicy() external view returns (address);
69+
70+
/// @notice Indicates if a dispute tag is whitelisted
71+
/// @param tag The dispute tag
72+
function isWhitelistedDisputeTag(bytes32 tag) external view returns (bool allowed);
73+
74+
/// @notice Indicates if an arbitration policy is whitelisted
75+
/// @param arbitrationPolicy The address of the arbitration policy
76+
function isWhitelistedArbitrationPolicy(address arbitrationPolicy) external view returns (bool allowed);
77+
78+
/// @notice Indicates if an arbitration relayer is whitelisted for a given arbitration policy
79+
/// @param arbitrationPolicy The address of the arbitration policy
80+
/// @param arbitrationRelayer The address of the arbitration relayer
81+
function isWhitelistedArbitrationRelayer(
82+
address arbitrationPolicy,
83+
address arbitrationRelayer
84+
) external view returns (bool allowed);
85+
86+
/// @notice Arbitration policy for a given ipId
87+
/// @param ipId The ipId
88+
function arbitrationPolicies(address ipId) external view returns (address policy);
89+
6490
/// @notice Whitelists a dispute tag
6591
/// @param tag The dispute tag
6692
/// @param allowed Indicates if the dispute tag is whitelisted or not
@@ -77,6 +103,15 @@ interface IDisputeModule {
77103
/// @param allowed Indicates if the arbitration relayer is whitelisted or not
78104
function whitelistArbitrationRelayer(address arbitrationPolicy, address arbPolicyRelayer, bool allowed) external;
79105

106+
/// @notice Sets the base arbitration policy
107+
/// @param _arbitrationPolicy The address of the arbitration policy
108+
function setBaseArbitrationPolicy(address _arbitrationPolicy) external;
109+
110+
/// @notice Sets the arbitration policy for an ipId
111+
/// @param _ipId The ipId
112+
/// @param _arbitrationPolicy The address of the arbitration policy
113+
function setArbitrationPolicy(address _ipId, address _arbitrationPolicy) external;
114+
80115
/// @notice Raises a dispute
81116
/// @param targetIpId The ipId that is the target of the dispute
82117
/// @param linkToDisputeEvidence The link of the dispute evidence

contracts/interfaces/modules/royalty/IRoyaltyModule.sol

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ interface IRoyaltyModule is IModule {
2929
/// @param amount The amount that is paid
3030
event RoyaltyPaid(address receiverIpId, address payerIpId, address sender, address token, uint256 amount);
3131

32+
/// @notice Indicates if a royalty policy is whitelisted
33+
/// @param royaltyPolicy The address of the royalty policy
34+
function isWhitelistedRoyaltyPolicy(address royaltyPolicy) external view returns (bool);
35+
36+
/// @notice Indicates if a royalty token is whitelisted
37+
/// @param token The address of the royalty token
38+
function isWhitelistedRoyaltyToken(address token) external view returns (bool);
39+
40+
/// @notice Indicates the royalty policy for a given ipId
41+
/// @param ipId The ipId
42+
function royaltyPolicies(address ipId) external view returns (address);
43+
44+
/// @notice Indicates if a royalty policy is immutable
45+
/// @param ipId The ipId
46+
function isRoyaltyPolicyImmutable(address ipId) external view returns (bool);
47+
3248
/// @notice Sets the licensing module
3349
/// @param licensingModule The address of the licensing module
3450
function setLicensingModule(address licensingModule) external;

contracts/interfaces/registries/ILicenseRegistry.sol

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity ^0.8.23;
33

4+
import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
5+
46
import { Licensing } from "../../lib/Licensing.sol";
57

68
/// @title ILicenseRegistry
79

8-
interface ILicenseRegistry {
10+
interface ILicenseRegistry is IERC1155 {
911
/// @notice Emitted when a license is minted
1012
/// @param creator The address that created the license
1113
/// @param receiver The address that received the license

contracts/modules/tagging/TaggingModule.sol

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ pragma solidity ^0.8.23;
66
import { ShortString, ShortStrings } from "@openzeppelin/contracts/utils/ShortStrings.sol";
77
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
88
import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
9+
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
910

1011
import { ShortStringOps } from "../../utils/ShortStringOps.sol";
1112
import { ITaggingModule } from "../../interfaces/modules/ITaggingModule.sol";
1213
import { TAGGING_MODULE_KEY } from "../../lib/modules/Module.sol";
14+
import { BaseModule } from "../BaseModule.sol";
1315

14-
contract TaggingModule is ITaggingModule {
16+
contract TaggingModule is BaseModule, ITaggingModule {
1517
using ERC165Checker for address;
1618
using ShortStrings for *;
1719
using EnumerableSet for EnumerableSet.Bytes32Set;
@@ -54,7 +56,7 @@ contract TaggingModule is ITaggingModule {
5456
return ShortString.wrap(_tagsForIpIds[ipId].at(index)).toString();
5557
}
5658

57-
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
58-
return interfaceId == type(ITaggingModule).interfaceId;
59+
function supportsInterface(bytes4 interfaceId) public view virtual override(BaseModule, IERC165) returns (bool) {
60+
return interfaceId == type(ITaggingModule).interfaceId || super.supportsInterface(interfaceId);
5961
}
6062
}

script/foundry/deployment/Main.s.sol

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ import { BroadcastManager } from "../../../script/foundry/utils/BroadcastManager
4242
import { JsonDeploymentHandler } from "../../../script/foundry/utils/JsonDeploymentHandler.s.sol";
4343

4444
// test
45-
import { MockERC20 } from "test/foundry/mocks/MockERC20.sol";
46-
import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
45+
import { MockERC20 } from "test/foundry/mocks/token/MockERC20.sol";
46+
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";
4747

4848
contract Main is Script, BroadcastManager, JsonDeploymentHandler {
4949
using StringUtil for uint256;
@@ -238,12 +238,15 @@ contract Main is Script, BroadcastManager, JsonDeploymentHandler {
238238
);
239239
_postdeploy(contractKey, address(disputeModule));
240240

241+
contractKey = "ArbitrationPolicySP";
242+
_predeploy(contractKey);
241243
arbitrationPolicySP = new ArbitrationPolicySP(
242244
address(disputeModule),
243245
address(erc20),
244246
ARBITRATION_PRICE,
245247
address(governance)
246248
);
249+
_postdeploy(contractKey, address(arbitrationPolicySP));
247250

248251
contractKey = "RoyaltyPolicyLS";
249252
_predeploy(contractKey);
@@ -361,13 +364,15 @@ contract Main is Script, BroadcastManager, JsonDeploymentHandler {
361364
CREATE POLICY FRAMEWORK MANAGERS
362365
////////////////////////////////////////////////////////////////*/
363366

367+
_predeploy("UMLPolicyFrameworkManager");
364368
UMLPolicyFrameworkManager umlPfm = new UMLPolicyFrameworkManager(
365369
address(accessController),
366370
address(ipAccountRegistry),
367371
address(licensingModule),
368372
"uml",
369373
"https://uml-license.com/{id}.json"
370374
);
375+
_postdeploy("UMLPolicyFrameworkManager", address(umlPfm));
371376
licensingModule.registerPolicyFrameworkManager(address(umlPfm));
372377
frameworkAddrs["uml"] = address(umlPfm);
373378

@@ -555,8 +560,8 @@ contract Main is Script, BroadcastManager, JsonDeploymentHandler {
555560

556561
address[] memory accounts = new address[](2);
557562
// order matters, otherwise error: InvalidSplit__AccountsOutOfOrder
558-
accounts[0] = ipAcct3_claimer;
559-
accounts[1] = ipAcct[3];
563+
accounts[1] = ipAcct3_claimer;
564+
accounts[0] = ipAcct[3];
560565

561566
royaltyPolicyLS.distributeFunds(ipAcct[3], address(erc20), accounts, address(0));
562567
}

script/foundry/deployment/MockAssets.s.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { stdJson } from "forge-std/StdJson.sol";
1010
import { BroadcastManager } from "../../../script/foundry/utils/BroadcastManager.s.sol";
1111
import { JsonDeploymentHandler } from "../../../script/foundry/utils/JsonDeploymentHandler.s.sol";
1212
// test
13-
import { MockERC20 } from "test/foundry/mocks/MockERC20.sol";
14-
import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
13+
import { MockERC20 } from "test/foundry/mocks/token/MockERC20.sol";
14+
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";
1515

1616
contract MockAssets is Script, BroadcastManager, JsonDeploymentHandler {
1717
using stdJson for string;

test/foundry/AccessController.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import { AccessPermission } from "contracts/lib/AccessPermission.sol";
1313
import { Errors } from "contracts/lib/Errors.sol";
1414
import { IPAccountRegistry } from "contracts/registries/IPAccountRegistry.sol";
1515
import { ModuleRegistry } from "contracts/registries/ModuleRegistry.sol";
16-
import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
17-
import { MockModule } from "test/foundry/mocks/MockModule.sol";
18-
import { MockOrchestratorModule } from "test/foundry/mocks/MockOrchestratorModule.sol";
16+
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";
17+
import { MockModule } from "test/foundry/mocks/module/MockModule.sol";
18+
import { MockOrchestratorModule } from "test/foundry/mocks/module/MockOrchestratorModule.sol";
1919
import { Governance } from "contracts/governance/Governance.sol";
2020

2121
contract AccessControllerTest is Test {

test/foundry/IPAccount.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import { ModuleRegistry } from "contracts/registries/ModuleRegistry.sol";
1212
import { Governance } from "contracts/governance/Governance.sol";
1313
import { Errors } from "contracts/lib/Errors.sol";
1414

15-
import { MockAccessController } from "test/foundry/mocks/MockAccessController.sol";
16-
import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
17-
import { MockModule } from "test/foundry/mocks/MockModule.sol";
15+
import { MockAccessController } from "test/foundry/mocks/access/MockAccessController.sol";
16+
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";
17+
import { MockModule } from "test/foundry/mocks/module/MockModule.sol";
1818

1919
contract IPAccountTest is Test {
2020
IPAccountRegistry public registry;

test/foundry/IPAccountMetaTx.t.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import { AccessPermission } from "contracts/lib/AccessPermission.sol";
1515
import { Governance } from "contracts/governance/Governance.sol";
1616
import { Errors } from "contracts/lib/Errors.sol";
1717

18-
import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
19-
import { MockModule } from "test/foundry/mocks/MockModule.sol";
20-
import { MockMetaTxModule } from "test/foundry/mocks/MockMetaTxModule.sol";
18+
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";
19+
import { MockModule } from "test/foundry/mocks/module/MockModule.sol";
20+
import { MockMetaTxModule } from "test/foundry/mocks/module/MockMetaTxModule.sol";
2121

2222
contract IPAccountMetaTxTest is Test {
2323
IPAccountRegistry public registry;

0 commit comments

Comments
 (0)