194 lines
7.5 KiB
Markdown
194 lines
7.5 KiB
Markdown
# Test Failures Analysis - Gaps and Missing Code
|
|
|
|
**Date**: 2025-12-24
|
|
**Status**: ⚠️ **38 FAILING TESTS IDENTIFIED**
|
|
|
|
---
|
|
|
|
## 🔴 Critical Issues: Missing Code or Implementation Gaps
|
|
|
|
### 1. **Error Message Mismatches (Custom Errors vs String Errors)**
|
|
|
|
**Problem**: Contracts use custom errors, but tests expect string error messages.
|
|
|
|
#### **DebtRegistry** (4 failing tests)
|
|
- **Contract uses**: Custom errors (`DebtZeroDebtor()`, `DebtZeroAmount()`, `DebtLienNotActive()`, `DebtReduceByExceedsAmount()`)
|
|
- **Tests expect**: String errors like `"DebtRegistry: zero amount"`, `"DebtRegistry: zero debtor"`, etc.
|
|
- **Files affected**:
|
|
- `test/emoney/unit/DebtRegistryTest.t.sol`
|
|
- `test/emoney/fuzz/DebtRegistryFuzz.t.sol`
|
|
|
|
**Fix Required**: Update tests to use `vm.expectRevert(abi.encodeWithSelector(DebtZeroAmount.selector))` instead of string errors.
|
|
|
|
#### **PolicyManager** (1 failing test)
|
|
- **Contract uses**: Custom error `PolicyInvalidLienMode(uint8 mode)`
|
|
- **Test expects**: String error `"PolicyManager: invalid lien mode"`
|
|
- **File affected**: `test/emoney/unit/PolicyManagerTest.t.sol`
|
|
|
|
**Fix Required**: Update test to use custom error selector.
|
|
|
|
#### **TokenFactory138** (2 failing tests)
|
|
- **Contract uses**: Custom error `ZeroIssuer()` from `FactoryErrors.sol`
|
|
- **Tests expect**: String error `"TokenFactory138: zero issuer"`
|
|
- **File affected**: `test/emoney/unit/TokenFactoryTest.t.sol`
|
|
|
|
**Fix Required**: Update tests to use custom error selector.
|
|
|
|
#### **eMoneyToken** (1 failing test)
|
|
- **Contract uses**: Custom error `ToNotCompliant(address account)`
|
|
- **Test expects**: String error `"eMoneyToken: to not compliant"`
|
|
- **File affected**: `test/emoney/unit/eMoneyTokenTest.t.sol`
|
|
|
|
**Fix Required**: Update test to use custom error selector.
|
|
|
|
---
|
|
|
|
### 2. **Missing Validation Logic**
|
|
|
|
#### **RailTriggerRegistry** - Duplicate InstructionId Check
|
|
- **Issue**: Test `test_createTrigger_duplicateInstructionId()` expects revert, but contract **DOES** check for duplicates (line 43: `require(!instructionIdExists(t.instructionId), ...)`)
|
|
- **Problem**: Test may be incorrectly structured or `instructionIdExists()` function may have a bug
|
|
- **Files affected**:
|
|
- `test/emoney/unit/RailTriggerRegistryTest.t.sol`
|
|
- `test/emoney/fuzz/RailTriggerFuzz.t.sol`
|
|
|
|
**Action Required**: Review `instructionIdExists()` implementation and test logic.
|
|
|
|
---
|
|
|
|
### 3. **Test Setup Issues (Missing Configuration)**
|
|
|
|
#### **CCIPReceiver Tests** (2 failing tests)
|
|
- **Error**: `"CCIPReceiver: zero aggregator address"`
|
|
- **Problem**: Tests don't set up `ORACLE_AGGREGATOR_ADDRESS` in setUp
|
|
- **Files affected**:
|
|
- `test/ccip/CCIPErrorHandling.t.sol`
|
|
- `test/ccip/CCIPIntegration.t.sol`
|
|
|
|
**Fix Required**: Add oracle aggregator address setup in test setUp functions.
|
|
|
|
#### **CCIPSender Tests** (5 failing tests)
|
|
- **Error**: `"CCIPSender: destination not enabled"`
|
|
- **Problem**: Tests don't configure CCIP destinations before testing
|
|
- **File affected**: `test/ccip/CCIPFees.t.sol`
|
|
|
|
**Fix Required**: Add destination configuration in test setup.
|
|
|
|
#### **ReserveSystem Test** (1 failing test)
|
|
- **Error**: `AccessControlUnauthorizedAccount` in setUp
|
|
- **Problem**: Test doesn't grant required roles before setup
|
|
- **File affected**: `test/reserve/ReserveSystemTest.t.sol`
|
|
|
|
**Fix Required**: Grant necessary roles in setUp function.
|
|
|
|
#### **SettlementOrchestrator Tests** (3 failing tests)
|
|
- **Error**: `AccessControlUnauthorizedAccount` and log mismatches
|
|
- **Problem**: Missing role grants or incorrect event expectations
|
|
- **File affected**: `test/emoney/unit/SettlementOrchestratorTest.t.sol`
|
|
|
|
**Fix Required**: Review role grants and event helper definitions.
|
|
|
|
---
|
|
|
|
### 4. **Test Logic Errors**
|
|
|
|
#### **CompliantUSDT Burn Test** (1 failing test)
|
|
- **Error**: `assertion failed: 999000000000 != 1000000000000`
|
|
- **Problem**: Test transfers 1000 * 10^6 to user1, then burns it, but assertion checks wrong balance
|
|
- **File affected**: `test/compliance/CompliantUSDTTest.t.sol`
|
|
- **Line 79**: `assertEq(usdt.totalSupply(), 1000000 * 10**6 - amount);` - This is correct
|
|
- **Line 80**: `assertEq(usdt.balanceOf(user1), 0);` - This should pass if burn worked
|
|
|
|
**Action Required**: Review test logic - the assertion may be checking the wrong value.
|
|
|
|
---
|
|
|
|
### 5. **Missing Functionality or Implementation Gaps**
|
|
|
|
#### **WETH/WETH10 Withdraw Tests** (3 failing tests)
|
|
- **Error**: `EvmError: Revert` in `testWithdraw()`
|
|
- **Problem**: Withdraw functionality may be missing or incorrectly implemented
|
|
- **Files affected**:
|
|
- `test/WETH.t.sol`
|
|
- `test/WETH10.t.sol`
|
|
|
|
**Action Required**: Review WETH/WETH10 withdraw implementation.
|
|
|
|
#### **Bridge Cross-Chain Tests** (2 failing tests)
|
|
- **Error**: `EvmError: Revert` in `testSendCrossChain()`
|
|
- **Problem**: Bridge may not be properly configured or missing functionality
|
|
- **Files affected**:
|
|
- `test/CCIPWETH9Bridge.t.sol`
|
|
- `test/CCIPWETH10Bridge.t.sol`
|
|
|
|
**Action Required**: Review bridge configuration and cross-chain send functionality.
|
|
|
|
#### **Payment Rails Flow Tests** (4 failing tests)
|
|
- **Errors**: Various state and validation errors
|
|
- **Problem**: Integration tests may have incorrect state setup or missing validations
|
|
- **File affected**: `test/emoney/integration/PaymentRailsFlowTest.t.sol`
|
|
|
|
**Action Required**: Review integration test setup and state management.
|
|
|
|
---
|
|
|
|
### 6. **Fuzz Test Edge Cases**
|
|
|
|
#### **AggregatorFuzz Test** (1 failing test)
|
|
- **Error**: `assertion failed: 25100000000 != 25000000000`
|
|
- **Problem**: Fuzz test found edge case where price deviation logic may not work as expected
|
|
- **File affected**: `test/AggregatorFuzz.t.sol`
|
|
|
|
**Action Required**: Review price deviation threshold logic in Aggregator contract.
|
|
|
|
#### **NetworkResilience Test** (1 failing test)
|
|
- **Error**: `Oracle should recover after unpause: 25000000000 != 25100000000`
|
|
- **Problem**: Oracle may not properly recover state after unpause
|
|
- **File affected**: `test/e2e/NetworkResilience.t.sol`
|
|
|
|
**Action Required**: Review oracle pause/unpause state recovery logic.
|
|
|
|
---
|
|
|
|
## ✅ Summary of Issues by Category
|
|
|
|
| Category | Count | Severity | Action Required |
|
|
|----------|-------|----------|-----------------|
|
|
| **Error Message Mismatches** | 8 | 🔴 High | Update tests to use custom error selectors |
|
|
| **Missing Test Setup** | 11 | 🟡 Medium | Add proper configuration in setUp functions |
|
|
| **Missing Validation Logic** | 2 | 🟡 Medium | Review validation implementations |
|
|
| **Test Logic Errors** | 1 | 🟢 Low | Fix test assertions |
|
|
| **Missing Functionality** | 9 | 🔴 High | Review contract implementations |
|
|
| **Fuzz Test Edge Cases** | 2 | 🟡 Medium | Review edge case handling |
|
|
| **Other** | 5 | 🟡 Medium | Various issues |
|
|
|
|
---
|
|
|
|
## 🎯 Priority Fixes
|
|
|
|
### **Immediate (High Priority)**
|
|
1. **Fix error message mismatches** - Update all tests to use custom error selectors (8 tests)
|
|
2. **Review missing functionality** - WETH withdraw, bridge cross-chain, payment rails (9 tests)
|
|
3. **Fix test setup issues** - CCIPReceiver, CCIPSender, ReserveSystem, SettlementOrchestrator (11 tests)
|
|
|
|
### **Short Term (Medium Priority)**
|
|
4. **Review validation logic** - RailTriggerRegistry duplicate check (2 tests)
|
|
5. **Fix fuzz test edge cases** - Aggregator and NetworkResilience (2 tests)
|
|
|
|
### **Low Priority**
|
|
6. **Fix test logic errors** - CompliantUSDT burn test (1 test)
|
|
|
|
---
|
|
|
|
## 📝 Notes
|
|
|
|
- **165 tests passing** - Good coverage overall
|
|
- **38 tests failing** - Mostly test setup and error message mismatches
|
|
- **No compilation errors** - All contracts compile successfully
|
|
- **Most issues are test-related** - Not necessarily missing code, but missing test configuration
|
|
|
|
---
|
|
|
|
**Last Updated**: 2025-12-24
|
|
|