- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control. - Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities. - Created .gitmodules to include OpenZeppelin contracts as a submodule. - Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment. - Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks. - Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring. - Created scripts for resource import and usage validation across non-US regions. - Added tests for CCIP error handling and integration to ensure robust functionality. - Included various new files and directories for the orchestration portal and deployment scripts.
132 lines
4.1 KiB
Solidity
132 lines
4.1 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
import "forge-std/Test.sol";
|
|
import "@emoney/TokenFactory138.sol";
|
|
import "@emoney/eMoneyToken.sol";
|
|
import "@emoney/PolicyManager.sol";
|
|
import "@emoney/ComplianceRegistry.sol";
|
|
import "@emoney/DebtRegistry.sol";
|
|
import "@emoney/interfaces/ITokenFactory138.sol";
|
|
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
|
|
|
|
contract TokenFactoryTest is Test {
|
|
TokenFactory138 public factory;
|
|
eMoneyToken public implementation;
|
|
PolicyManager public policyManager;
|
|
ComplianceRegistry public complianceRegistry;
|
|
DebtRegistry public debtRegistry;
|
|
|
|
address public admin;
|
|
address public deployer;
|
|
address public issuer;
|
|
|
|
function setUp() public {
|
|
admin = address(0x1);
|
|
deployer = address(0x2);
|
|
issuer = address(0x3);
|
|
|
|
complianceRegistry = new ComplianceRegistry(admin);
|
|
debtRegistry = new DebtRegistry(admin);
|
|
policyManager = new PolicyManager(admin, address(complianceRegistry), address(debtRegistry));
|
|
|
|
implementation = new eMoneyToken();
|
|
|
|
factory = new TokenFactory138(
|
|
admin,
|
|
address(implementation),
|
|
address(policyManager),
|
|
address(debtRegistry),
|
|
address(complianceRegistry)
|
|
);
|
|
|
|
vm.startPrank(admin);
|
|
factory.grantRole(factory.TOKEN_DEPLOYER_ROLE(), deployer);
|
|
policyManager.grantRole(policyManager.POLICY_OPERATOR_ROLE(), address(factory));
|
|
vm.stopPrank();
|
|
}
|
|
|
|
function test_deployToken() public {
|
|
ITokenFactory138.TokenConfig memory config = ITokenFactory138.TokenConfig({
|
|
issuer: issuer,
|
|
decimals: 18,
|
|
defaultLienMode: 2,
|
|
bridgeOnly: false,
|
|
bridge: address(0)
|
|
});
|
|
|
|
vm.prank(deployer);
|
|
address token = factory.deployToken("My Token", "MTK", config);
|
|
|
|
assertTrue(token != address(0));
|
|
assertEq(eMoneyToken(token).decimals(), 18);
|
|
assertEq(eMoneyToken(token).name(), "My Token");
|
|
assertEq(eMoneyToken(token).symbol(), "MTK");
|
|
|
|
// Check policy configuration
|
|
assertEq(policyManager.lienMode(token), 2);
|
|
assertFalse(policyManager.bridgeOnly(token));
|
|
}
|
|
|
|
function test_deployToken_withBridge() public {
|
|
address bridge = address(0xB0);
|
|
|
|
ITokenFactory138.TokenConfig memory config = ITokenFactory138.TokenConfig({
|
|
issuer: issuer,
|
|
decimals: 6,
|
|
defaultLienMode: 1,
|
|
bridgeOnly: true,
|
|
bridge: bridge
|
|
});
|
|
|
|
vm.prank(deployer);
|
|
address token = factory.deployToken("Bridge Token", "BRT", config);
|
|
|
|
assertEq(policyManager.bridgeOnly(token), true);
|
|
assertEq(policyManager.bridge(token), bridge);
|
|
assertEq(policyManager.lienMode(token), 1);
|
|
}
|
|
|
|
function test_deployToken_unauthorized() public {
|
|
ITokenFactory138.TokenConfig memory config = ITokenFactory138.TokenConfig({
|
|
issuer: issuer,
|
|
decimals: 18,
|
|
defaultLienMode: 2,
|
|
bridgeOnly: false,
|
|
bridge: address(0)
|
|
});
|
|
|
|
vm.expectRevert();
|
|
factory.deployToken("Token", "TKN", config);
|
|
}
|
|
|
|
function test_deployToken_zeroIssuer() public {
|
|
ITokenFactory138.TokenConfig memory config = ITokenFactory138.TokenConfig({
|
|
issuer: address(0),
|
|
decimals: 18,
|
|
defaultLienMode: 2,
|
|
bridgeOnly: false,
|
|
bridge: address(0)
|
|
});
|
|
|
|
vm.prank(deployer);
|
|
vm.expectRevert("TokenFactory138: zero issuer");
|
|
factory.deployToken("Token", "TKN", config);
|
|
}
|
|
|
|
function test_deployToken_invalidLienMode() public {
|
|
ITokenFactory138.TokenConfig memory config = ITokenFactory138.TokenConfig({
|
|
issuer: issuer,
|
|
decimals: 18,
|
|
defaultLienMode: 0, // Invalid
|
|
bridgeOnly: false,
|
|
bridge: address(0)
|
|
});
|
|
|
|
vm.prank(deployer);
|
|
vm.expectRevert("TokenFactory138: invalid lien mode");
|
|
factory.deployToken("Token", "TKN", config);
|
|
}
|
|
}
|
|
|