Files
smom-dbis-138/services/financial-tokenization/tests/test_swift_fin_parser.py
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

68 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""
Tests for SWIFT FIN Parser
"""
import pytest
from parsers.swift_fin_parser import SWIFTFINParser
@pytest.fixture
def parser():
return SWIFTFINParser()
@pytest.fixture
def sample_mt103():
return """{1:F01BANKUS33AXXX1234567890}
{2:O1031200240101BANKUS33AXXX1234567890123456789012345678901234567890}
{3:{108:MT103}}
{4:
:20:REF123
:23B:CRED
:32A:240101USD1000,00
:50A:/US1234567890
BANK US
:59:/US9876543210
CREDITOR NAME
:70:Payment for services
:71A:SHA
-}
{5:{MAC:12345678}{CHK:ABCDEF123456}{TNG:}{PDE:}}
{S:{COP:P}}"""
def test_parse_mt103(parser, sample_mt103):
"""Test parsing MT103 message"""
result = parser.parse(sample_mt103)
assert result['type'] == 'SWIFT_FIN'
assert result['messageType'] == 'MT103'
assert 'parsed' in result
assert 'senderReference' in result['parsed']
assert 'amount' in result['parsed']
def test_extract_message_type(parser, sample_mt103):
"""Test message type extraction"""
lines = sample_mt103.strip().split('\n')
app_header = parser._parse_block(lines, 2)
message_type = parser._extract_message_type(app_header.get('raw', ''))
assert message_type == 'MT103'
def test_parse_swift_fields(parser):
"""Test SWIFT field parsing"""
text = ":20:REF123\n:32A:240101USD1000,00\n:50A:/US1234567890\nBANK US"
fields = parser._parse_swift_fields(text)
assert '20' in fields
assert '32A' in fields
assert '50A' in fields
def test_parse_balance(parser):
"""Test balance parsing"""
balance_str = "D230101USD1000,00"
balance = parser._parse_balance(balance_str)
assert balance['creditDebitIndicator'] == 'Debit'
assert balance['currency'] == 'USD'
assert balance['amount'] == '1000.00'
if __name__ == '__main__':
pytest.main([__file__])