Files
smom-dbis-138/test/emoney/unit/ISO20022RouterTest.t.sol
defiQUG 1fb7266469 Add Oracle Aggregator and CCIP Integration
- 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.
2025-12-12 14:57:48 -08:00

102 lines
3.7 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "forge-std/Test.sol";
import "@emoney/ISO20022Router.sol";
import "@emoney/interfaces/IISO20022Router.sol";
import "@emoney/RailTriggerRegistry.sol";
import "@emoney/libraries/RailTypes.sol";
import "@emoney/libraries/ISO20022Types.sol";
contract ISO20022RouterTest is Test {
ISO20022Router public router;
RailTriggerRegistry public triggerRegistry;
address public admin;
address public railOperator;
address public token;
function setUp() public {
admin = address(0x1);
railOperator = address(0x2);
token = address(0x100);
triggerRegistry = new RailTriggerRegistry(admin);
router = new ISO20022Router(admin, address(triggerRegistry));
vm.startPrank(admin);
triggerRegistry.grantRole(triggerRegistry.RAIL_OPERATOR_ROLE(), address(router));
router.grantRole(router.RAIL_OPERATOR_ROLE(), railOperator);
vm.stopPrank();
}
function test_submitOutbound() public {
IISO20022Router.CanonicalMessage memory m = IISO20022Router.CanonicalMessage({
msgType: ISO20022Types.PAIN_001,
instructionId: keccak256("instruction1"),
endToEndId: keccak256("e2e1"),
accountRefId: keccak256("account1"),
counterpartyRefId: keccak256("counterparty1"),
token: token,
amount: 1000,
currencyCode: keccak256("USD"),
payloadHash: keccak256("payload1")
});
vm.expectEmit(true, true, false, true);
emit IISO20022Router.OutboundSubmitted(0, ISO20022Types.PAIN_001, keccak256("instruction1"), keccak256("account1"));
vm.prank(railOperator);
uint256 triggerId = router.submitOutbound(m);
assertEq(triggerId, 0);
IRailTriggerRegistry.Trigger memory trigger = triggerRegistry.getTrigger(triggerId);
assertEq(trigger.instructionId, keccak256("instruction1"));
assertEq(trigger.msgType, ISO20022Types.PAIN_001);
}
function test_submitInbound() public {
IISO20022Router.CanonicalMessage memory m = IISO20022Router.CanonicalMessage({
msgType: ISO20022Types.CAMT_054,
instructionId: keccak256("instruction2"),
endToEndId: keccak256("e2e2"),
accountRefId: keccak256("account2"),
counterpartyRefId: keccak256("counterparty2"),
token: token,
amount: 2000,
currencyCode: keccak256("EUR"),
payloadHash: keccak256("payload2")
});
vm.expectEmit(true, true, false, true);
emit IISO20022Router.InboundSubmitted(0, ISO20022Types.CAMT_054, keccak256("instruction2"), keccak256("account2"));
vm.prank(railOperator);
uint256 triggerId = router.submitInbound(m);
assertEq(triggerId, 0);
IRailTriggerRegistry.Trigger memory trigger = triggerRegistry.getTrigger(triggerId);
assertEq(trigger.instructionId, keccak256("instruction2"));
assertEq(trigger.msgType, ISO20022Types.CAMT_054);
}
function test_getTriggerIdByInstructionId() public {
IISO20022Router.CanonicalMessage memory m = IISO20022Router.CanonicalMessage({
msgType: ISO20022Types.PAIN_001,
instructionId: keccak256("instruction3"),
endToEndId: bytes32(0),
accountRefId: keccak256("account3"),
counterpartyRefId: bytes32(0),
token: token,
amount: 3000,
currencyCode: keccak256("USD"),
payloadHash: bytes32(0)
});
vm.prank(railOperator);
uint256 triggerId = router.submitOutbound(m);
assertEq(router.getTriggerIdByInstructionId(keccak256("instruction3")), triggerId);
}
}