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

New Unified Test Framework #90

Merged
merged 20 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ jobs:
run: |
ls -R ${{ github.workspace }}

# first, build contracts excluding the tests and scripts. Check contract sizes in this step.
# then, build contracts including the tests and scripts. Don't check contract sizes.
- name: Run Forge build
run: |
forge --version
forge build --force --sizes
forge build --force --sizes --skip test --skip script
forge build
id: build

- name: Run Forge tests
Expand All @@ -72,4 +75,4 @@ jobs:
# - name: Code Coverage
# run:
# forge coverage --report lcov --report summary
# id: forge-code-coverage
# id: forge-code-coverage
35 changes: 35 additions & 0 deletions contracts/interfaces/modules/dispute/IDisputeModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,32 @@ interface IDisputeModule {
/// @param disputeId The dispute id
event DisputeResolved(uint256 disputeId);

/// @notice Dispute id
function disputeId() external view returns (uint256);

/// @notice The address of the base arbitration policy
function baseArbitrationPolicy() external view returns (address);

/// @notice Indicates if a dispute tag is whitelisted
/// @param tag The dispute tag
function isWhitelistedDisputeTag(bytes32 tag) external view returns (bool allowed);

/// @notice Indicates if an arbitration policy is whitelisted
/// @param arbitrationPolicy The address of the arbitration policy
function isWhitelistedArbitrationPolicy(address arbitrationPolicy) external view returns (bool allowed);

/// @notice Indicates if an arbitration relayer is whitelisted for a given arbitration policy
/// @param arbitrationPolicy The address of the arbitration policy
/// @param arbitrationRelayer The address of the arbitration relayer
function isWhitelistedArbitrationRelayer(
address arbitrationPolicy,
address arbitrationRelayer
) external view returns (bool allowed);

/// @notice Arbitration policy for a given ipId
/// @param ipId The ipId
function arbitrationPolicies(address ipId) external view returns (address policy);

/// @notice Whitelists a dispute tag
/// @param tag The dispute tag
/// @param allowed Indicates if the dispute tag is whitelisted or not
Expand All @@ -77,6 +103,15 @@ interface IDisputeModule {
/// @param allowed Indicates if the arbitration relayer is whitelisted or not
function whitelistArbitrationRelayer(address arbitrationPolicy, address arbPolicyRelayer, bool allowed) external;

/// @notice Sets the base arbitration policy
/// @param _arbitrationPolicy The address of the arbitration policy
function setBaseArbitrationPolicy(address _arbitrationPolicy) external;

/// @notice Sets the arbitration policy for an ipId
/// @param _ipId The ipId
/// @param _arbitrationPolicy The address of the arbitration policy
function setArbitrationPolicy(address _ipId, address _arbitrationPolicy) external;

/// @notice Raises a dispute
/// @param targetIpId The ipId that is the target of the dispute
/// @param linkToDisputeEvidence The link of the dispute evidence
Expand Down
16 changes: 16 additions & 0 deletions contracts/interfaces/modules/royalty/IRoyaltyModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ interface IRoyaltyModule is IModule {
/// @param amount The amount that is paid
event RoyaltyPaid(address receiverIpId, address payerIpId, address sender, address token, uint256 amount);

/// @notice Indicates if a royalty policy is whitelisted
/// @param royaltyPolicy The address of the royalty policy
function isWhitelistedRoyaltyPolicy(address royaltyPolicy) external view returns (bool);

/// @notice Indicates if a royalty token is whitelisted
/// @param token The address of the royalty token
function isWhitelistedRoyaltyToken(address token) external view returns (bool);

/// @notice Indicates the royalty policy for a given ipId
/// @param ipId The ipId
function royaltyPolicies(address ipId) external view returns (address);

/// @notice Indicates if a royalty policy is immutable
/// @param ipId The ipId
function isRoyaltyPolicyImmutable(address ipId) external view returns (bool);

/// @notice Sets the licensing module
/// @param licensingModule The address of the licensing module
function setLicensingModule(address licensingModule) external;
Expand Down
4 changes: 3 additions & 1 deletion contracts/interfaces/registries/ILicenseRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.23;

import { IERC1155 } from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

import { Licensing } from "../../lib/Licensing.sol";

/// @title ILicenseRegistry

interface ILicenseRegistry {
interface ILicenseRegistry is IERC1155 {
/// @notice Emitted when a license is minted
/// @param creator The address that created the license
/// @param receiver The address that received the license
Expand Down
8 changes: 5 additions & 3 deletions contracts/modules/tagging/TaggingModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ pragma solidity ^0.8.23;
import { ShortString, ShortStrings } from "@openzeppelin/contracts/utils/ShortStrings.sol";
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";

import { ShortStringOps } from "../../utils/ShortStringOps.sol";
import { ITaggingModule } from "../../interfaces/modules/ITaggingModule.sol";
import { TAGGING_MODULE_KEY } from "../../lib/modules/Module.sol";
import { BaseModule } from "../BaseModule.sol";

contract TaggingModule is ITaggingModule {
contract TaggingModule is BaseModule, ITaggingModule {
using ERC165Checker for address;
using ShortStrings for *;
using EnumerableSet for EnumerableSet.Bytes32Set;
Expand Down Expand Up @@ -54,7 +56,7 @@ contract TaggingModule is ITaggingModule {
return ShortString.wrap(_tagsForIpIds[ipId].at(index)).toString();
}

function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(ITaggingModule).interfaceId;
function supportsInterface(bytes4 interfaceId) public view virtual override(BaseModule, IERC165) returns (bool) {
return interfaceId == type(ITaggingModule).interfaceId || super.supportsInterface(interfaceId);
}
}
13 changes: 9 additions & 4 deletions script/foundry/deployment/Main.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import { BroadcastManager } from "../../../script/foundry/utils/BroadcastManager
import { JsonDeploymentHandler } from "../../../script/foundry/utils/JsonDeploymentHandler.s.sol";

// test
import { MockERC20 } from "test/foundry/mocks/MockERC20.sol";
import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
import { MockERC20 } from "test/foundry/mocks/token/MockERC20.sol";
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";

contract Main is Script, BroadcastManager, JsonDeploymentHandler {
using StringUtil for uint256;
Expand Down Expand Up @@ -238,12 +238,15 @@ contract Main is Script, BroadcastManager, JsonDeploymentHandler {
);
_postdeploy(contractKey, address(disputeModule));

contractKey = "ArbitrationPolicySP";
_predeploy(contractKey);
arbitrationPolicySP = new ArbitrationPolicySP(
address(disputeModule),
address(erc20),
ARBITRATION_PRICE,
address(governance)
);
_postdeploy(contractKey, address(arbitrationPolicySP));

contractKey = "RoyaltyPolicyLS";
_predeploy(contractKey);
Expand Down Expand Up @@ -361,13 +364,15 @@ contract Main is Script, BroadcastManager, JsonDeploymentHandler {
CREATE POLICY FRAMEWORK MANAGERS
////////////////////////////////////////////////////////////////*/

_predeploy("UMLPolicyFrameworkManager");
UMLPolicyFrameworkManager umlPfm = new UMLPolicyFrameworkManager(
address(accessController),
address(ipAccountRegistry),
address(licensingModule),
"uml",
"https://uml-license.com/{id}.json"
);
_postdeploy("UMLPolicyFrameworkManager", address(umlPfm));
licensingModule.registerPolicyFrameworkManager(address(umlPfm));
frameworkAddrs["uml"] = address(umlPfm);

Expand Down Expand Up @@ -555,8 +560,8 @@ contract Main is Script, BroadcastManager, JsonDeploymentHandler {

address[] memory accounts = new address[](2);
// order matters, otherwise error: InvalidSplit__AccountsOutOfOrder
accounts[0] = ipAcct3_claimer;
accounts[1] = ipAcct[3];
accounts[1] = ipAcct3_claimer;
accounts[0] = ipAcct[3];

royaltyPolicyLS.distributeFunds(ipAcct[3], address(erc20), accounts, address(0));
}
Expand Down
4 changes: 2 additions & 2 deletions script/foundry/deployment/MockAssets.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { stdJson } from "forge-std/StdJson.sol";
import { BroadcastManager } from "../../../script/foundry/utils/BroadcastManager.s.sol";
import { JsonDeploymentHandler } from "../../../script/foundry/utils/JsonDeploymentHandler.s.sol";
// test
import { MockERC20 } from "test/foundry/mocks/MockERC20.sol";
import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
import { MockERC20 } from "test/foundry/mocks/token/MockERC20.sol";
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";

contract MockAssets is Script, BroadcastManager, JsonDeploymentHandler {
using stdJson for string;
Expand Down
6 changes: 3 additions & 3 deletions test/foundry/AccessController.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { AccessPermission } from "contracts/lib/AccessPermission.sol";
import { Errors } from "contracts/lib/Errors.sol";
import { IPAccountRegistry } from "contracts/registries/IPAccountRegistry.sol";
import { ModuleRegistry } from "contracts/registries/ModuleRegistry.sol";
import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
import { MockModule } from "test/foundry/mocks/MockModule.sol";
import { MockOrchestratorModule } from "test/foundry/mocks/MockOrchestratorModule.sol";
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";
import { MockModule } from "test/foundry/mocks/module/MockModule.sol";
import { MockOrchestratorModule } from "test/foundry/mocks/module/MockOrchestratorModule.sol";
import { Governance } from "contracts/governance/Governance.sol";

contract AccessControllerTest is Test {
Expand Down
6 changes: 3 additions & 3 deletions test/foundry/IPAccount.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { ModuleRegistry } from "contracts/registries/ModuleRegistry.sol";
import { Governance } from "contracts/governance/Governance.sol";
import { Errors } from "contracts/lib/Errors.sol";

import { MockAccessController } from "test/foundry/mocks/MockAccessController.sol";
import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
import { MockModule } from "test/foundry/mocks/MockModule.sol";
import { MockAccessController } from "test/foundry/mocks/access/MockAccessController.sol";
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";
import { MockModule } from "test/foundry/mocks/module/MockModule.sol";

contract IPAccountTest is Test {
IPAccountRegistry public registry;
Expand Down
6 changes: 3 additions & 3 deletions test/foundry/IPAccountMetaTx.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { AccessPermission } from "contracts/lib/AccessPermission.sol";
import { Governance } from "contracts/governance/Governance.sol";
import { Errors } from "contracts/lib/Errors.sol";

import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
import { MockModule } from "test/foundry/mocks/MockModule.sol";
import { MockMetaTxModule } from "test/foundry/mocks/MockMetaTxModule.sol";
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";
import { MockModule } from "test/foundry/mocks/module/MockModule.sol";
import { MockMetaTxModule } from "test/foundry/mocks/module/MockMetaTxModule.sol";

contract IPAccountMetaTxTest is Test {
IPAccountRegistry public registry;
Expand Down
2 changes: 1 addition & 1 deletion test/foundry/access/AccessControlled.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { AccessPermission } from "contracts/lib/AccessPermission.sol";
import { Errors } from "contracts/lib/Errors.sol";
import { IPAccountRegistry } from "contracts/registries/IPAccountRegistry.sol";
import { ModuleRegistry } from "contracts/registries/ModuleRegistry.sol";
import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";
import { Governance } from "contracts/governance/Governance.sol";
import { MockAccessControlledModule } from "test/foundry/mocks/MockAccessControlledModule.sol";

Expand Down
4 changes: 2 additions & 2 deletions test/foundry/governance/Governance.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { AccessPermission } from "contracts/lib/AccessPermission.sol";
import { Errors } from "contracts/lib/Errors.sol";
import { IPAccountRegistry } from "contracts/registries/IPAccountRegistry.sol";
import { ModuleRegistry } from "contracts/registries/ModuleRegistry.sol";
import { MockERC721 } from "test/foundry/mocks/MockERC721.sol";
import { MockModule } from "test/foundry/mocks/MockModule.sol";
import { MockERC721 } from "test/foundry/mocks/token/MockERC721.sol";
import { MockModule } from "test/foundry/mocks/module/MockModule.sol";
import { Governance } from "contracts/governance/Governance.sol";
import { IGovernable } from "contracts/interfaces/governance/IGovernable.sol";
import { GovernanceLib } from "contracts/lib/GovernanceLib.sol";
Expand Down
Loading
Loading