3.6 KiB
3.6 KiB
CCIP Testing Guide for ChainID 138
Date: 2025-01-27
Network: ChainID 138 (DeFi Oracle Meta Mainnet)
Overview
This guide provides testing procedures and examples for CCIP infrastructure on ChainID 138.
Test Categories
1. Unit Tests
Test individual contract functions in isolation.
Files:
test/CCIPWETH9Bridge.t.soltest/CCIPWETH10Bridge.t.soltest/ccip/CCIPIntegration.t.soltest/ccip/CCIPErrorHandling.t.soltest/ccip/CCIPFees.t.sol
2. Integration Tests
Test end-to-end cross-chain flows.
Files:
test/ccip/CCIPIntegration.t.sol
3. Functional Tests
Test real-world usage scenarios.
Running Tests
Run All CCIP Tests
forge test --match-path "test/ccip/**" -vvv
forge test --match-path "test/CCIP*.t.sol" -vvv
Run Specific Test File
forge test --match-path "test/CCIPWETH9Bridge.t.sol" -vvv
Run Specific Test Function
forge test --match-test "testSendCrossChain" -vvv
Test Scenarios
Router Tests
function testRouterMessageSending() public {
// Test sending message via router
IRouterClient.EVM2AnyMessage memory message = ...;
(bytes32 messageId, uint256 fee) = router.ccipSend(destinationSelector, message);
assertTrue(messageId != bytes32(0));
}
function testRouterFeeCalculation() public {
// Test fee calculation
uint256 fee = router.getFee(destinationSelector, message);
assertTrue(fee > 0);
}
Bridge Tests
function testBridgeTransfer() public {
// Approve bridge
weth9.approve(address(bridge), amount);
// Send cross-chain
bytes32 messageId = bridge.sendCrossChain(destinationSelector, recipient, amount);
// Verify
assertTrue(messageId != bytes32(0));
}
function testBridgeFeeCalculation() public {
uint256 fee = bridge.calculateFee(destinationSelector, amount);
assertTrue(fee > 0);
}
Integration Tests
function testEndToEndTransfer() public {
// 1. Lock tokens on source chain
// 2. Send cross-chain message
// 3. Verify unlock on destination chain
// 4. Verify balances
}
Test Data
Test Addresses
address constant TEST_USER = address(0x1111);
address constant TEST_RECIPIENT = address(0x2222);
address constant TEST_ADMIN = address(0x3333);
Test Amounts
uint256 constant TEST_AMOUNT = 1 ether;
uint256 constant TEST_FEE = 0.001 ether;
Test Chain Selectors
uint64 constant CHAIN138_SELECTOR = 138;
uint64 constant ETH_MAINNET_SELECTOR = 5009297550715157269;
Mock Contracts
For testing without actual cross-chain connectivity:
contract MockRouter is IRouterClient {
function ccipSend(...) external payable returns (bytes32, uint256) {
// Mock implementation
}
function getFee(...) external view returns (uint256) {
// Mock fee calculation
}
}
Test Coverage Goals
- Unit Tests: >90% coverage
- Integration Tests: All critical paths
- Error Handling: All error cases
- Edge Cases: Boundary conditions
Continuous Integration
GitHub Actions Example
name: CCIP Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: foundry-actions/setup-foundry@v1
- run: forge test --match-path "test/ccip/**"
Related Documentation
Last Updated: 2025-01-27